Class: GitCopy
- Inherits:
-
Object
- Object
- GitCopy
- Defined in:
- lib/gitcopy.rb
Class Method Summary collapse
- .copyRepo(repoPath, destPath = ".") ⇒ Object
- .ensureValidRepo(repoPath) ⇒ Object
- .fatalError(error) ⇒ Object
Class Method Details
.copyRepo(repoPath, destPath = ".") ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/gitcopy.rb', line 6 def self.copyRepo(repoPath, destPath = ".") if destPath == "" || destPath == nil destPath = "." end ensureValidRepo(repoPath) `git clone #{repoPath} #{@tempDir}` `rm -rf #{@tempDir}/.git` `mkdir -p #{destPath}` `mv #{@tempDir}/* #{destPath}` `mv #{@tempDir}/.[!.]* #{destPath}` `rm -rf #{@tempDir}` end |
.ensureValidRepo(repoPath) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/gitcopy.rb', line 20 def self.ensureValidRepo(repoPath) if !repoPath fatalError("Please provide a valid github repo") end repoProtocol = GitProperties.repoProtocol(repoPath) repoExtension = GitProperties.repoExtension(repoPath) if (repoProtocol != "http" || repoProtocol != "git@") && repoExtension != ".git" fatalError("Please provide a valid github repo") end end |
.fatalError(error) ⇒ Object
33 34 35 36 |
# File 'lib/gitcopy.rb', line 33 def self.fatalError(error) puts "Error: #{error}" exit(false) end |