Class: Giternal::Repository
- Inherits:
-
Object
- Object
- Giternal::Repository
- Defined in:
- lib/giternal/repository.rb
Instance Method Summary collapse
-
#initialize(name, repo_url, rel_path) ⇒ Repository
constructor
A new instance of Repository.
- #update(target_dir) ⇒ Object
Constructor Details
#initialize(name, repo_url, rel_path) ⇒ Repository
Returns a new instance of Repository.
3 4 5 6 7 |
# File 'lib/giternal/repository.rb', line 3 def initialize(name, repo_url, rel_path) @name = name @repo_url = repo_url @rel_path = rel_path end |
Instance Method Details
#update(target_dir) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/giternal/repository.rb', line 9 def update(target_dir) target_path = File.(File.join(target_dir, @rel_path)) FileUtils.mkdir_p target_path unless File.exist?(target_path) if File.exist?(target_path + "/#{@name}") if !File.exist?(target_path + "/#{@name}/.git") raise "Directory '#{@name}' exists but is not a git repository" else `cd #{target_path}/#{@name} && git pull 2>&1` end else `cd #{target_path} && git clone #{@repo_url} #{@name}` end true end |