#446: added comments

This commit is contained in:
Vokhmin Alexey V 2015-01-13 02:16:46 +03:00
parent 8580b9a80d
commit fe8d24eb99
1 changed files with 6 additions and 0 deletions

View File

@ -152,16 +152,22 @@ module Git
end end
end end
# Creates fork/alias for GIT repo
def fork_git_repo def fork_git_repo
dummy = Grit::Repo.new(path) rescue nil dummy = Grit::Repo.new(path) rescue nil
# Do nothing if GIT repo already exist
unless dummy unless dummy
if alias_from_id if alias_from_id
aliases_path = File.join(APP_CONFIG['git_path'], 'git_projects', '.aliases') aliases_path = File.join(APP_CONFIG['git_path'], 'git_projects', '.aliases')
FileUtils.mkdir_p(aliases_path) FileUtils.mkdir_p(aliases_path)
alias_path = File.join(aliases_path, "#{alias_from_id}.git") alias_path = File.join(aliases_path, "#{alias_from_id}.git")
if !Dir.exists?(alias_path) && alias_from if !Dir.exists?(alias_path) && alias_from
# Move GIT repo into aliases
FileUtils.mv(alias_from.path, alias_path, force: true) FileUtils.mv(alias_from.path, alias_path, force: true)
# Create link for GIT
FileUtils.ln_sf alias_path, alias_from.path
end end
# Create link for GIT
FileUtils.ln_sf alias_path, path FileUtils.ln_sf alias_path, path
else else
parent.repo.fork_bare(path, shared: false) parent.repo.fork_bare(path, shared: false)