/lib/bitbucket_git.rb

https://bitbucket.org/yuji_developer/redmine_bitbucket · Ruby · 26 lines · 19 code · 5 blank · 2 comment · 2 complexity · 212888dd71b6b53f050351742d278e1f 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. fetch_opts = Setting.plugin_redmine_bitbucket[:git_fetch_with_prune] ? '--prune' : ''
  9. command = GIT_BIN + " --git-dir='#{local_url}' fetch #{fetch_opts} origin"
  10. if exec(command)
  11. command = GIT_BIN + " --git-dir='#{local_url}' fetch #{fetch_opts} origin '+refs/heads/*:refs/heads/*'"
  12. exec(command)
  13. end
  14. end
  15. # Clone repository from Bitbucket
  16. def self.clone_repository(path, local_url)
  17. remote_url = "git@bitbucket.org:#{path}.git"
  18. command = GIT_BIN + " clone --mirror #{remote_url} #{local_url}"
  19. return exec(command)
  20. end
  21. end