PageRenderTime 57ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/bitbucket_git.rb

https://bitbucket.org/ageis/redmine_bitbucket
Ruby | 25 lines | 18 code | 5 blank | 2 comment | 2 complexity | dbb978532f64d2c1490268b1c0290d4b MD5 | raw file
  1. class BitbucketGit < SystemCommand
  2. GIT_BIN = Redmine::Configuration['scm_git_command'] || "git"
  3. def self.scm_class
  4. Repository::Git
  5. end
  6. # Fetches updates from the remote repository
  7. def self.update_repository(local_url)
  8. command = "ionice -c2 -n7 nice -n19 " + GIT_BIN + " --git-dir='#{local_url}' fetch origin"
  9. if exec(command)
  10. command = "ionice -c2 -n7 nice -n19 " + GIT_BIN + " --git-dir='#{local_url}' fetch origin '+refs/heads/*:refs/heads/*'"
  11. exec(command)
  12. end
  13. end
  14. # Clone repository from Bitbucket
  15. def self.clone_repository(path, local_url)
  16. remote_url = "git@bitbucket.org:#{path}.git"
  17. command = GIT_BIN + " clone --mirror #{remote_url} #{local_url}"
  18. return exec(command)
  19. end
  20. end