/lib/bitbucket_git.rb

https://bitbucket.org/daenoor/redmine_bitbucket · Ruby · 25 lines · 18 code · 5 blank · 2 comment · 2 complexity · c5054cad97a20a80a1608871d70d9aa6 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 = GIT_BIN + " --git-dir='#{local_url}' fetch origin"
  9. if exec(command)
  10. command = 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