Redmine で gitolite のリポジトリを扱いたい - 現状の確認
Redmine の lib/redmine/scm/adapters/git_adapters.rb を見ると,
基本的には,git コマンドで --git-dir 指定をして使っているような気がする.
$ egrep 'cmd = ' lib/redmine/scm/adapters/git_adapter.rb|perl -pe 's/^\s+//' cmd = "#{GIT_BIN} --git-dir #{target('')} branch --no-color" cmd = "#{GIT_BIN} --git-dir #{target('')} tag" cmd = "#{GIT_BIN} --git-dir #{target('')} ls-tree -l " cmd = "#{GIT_BIN} --git-dir #{target('')} log --no-color --date=iso --pretty=fuller --no-merges -n 1 " cmd = "#{GIT_BIN} --git-dir #{target('')} log --no-color --raw --date=iso --pretty=fuller " cmd = "#{GIT_BIN} --git-dir #{target('')} diff --no-color #{shell_quote identifier_to} #{shell_quote identifier_from}" cmd = "#{GIT_BIN} --git-dir #{target('')} show --no-color #{shell_quote identifier_from}" cmd = "#{GIT_BIN} --git-dir #{target('')} blame -p #{shell_quote identifier} -- #{shell_quote path}" cmd = "#{GIT_BIN} --git-dir #{target('')} show --no-color #{shell_quote(identifier + ':' + path)}"
git の --git-dir オプションは,ローカルリポジトリの .git ディレクトリを指定して,
カレントディレクトリじゃない場所に対してコマンドを実行するものと思えばいい.*1
なので,一応パスから変換して,ローカルのファイルシステムに git clone するようにすれば,
リモートリポジトリを指定して対応できるような気がするけど,
現状はそうなってないのかな?
テストが,test/unit/lib/redmine/scm/adapters/git_adapter_test.rb にあるようだ.
なんか,この辺を要求されたりした.
$ gem install mocha $ gem install edavis10-object_daddy $ gem install -v=2.10.3 shoulda
参考
- http://www.tsunematsu.cc/2010/03/21/2823/ - local にgit push すればいいんじゃねという意見
- http://wp.serpere.info/archives/581 - git clone --mirror だけで話が終われば楽なんだけどな
- http://d.hatena.ne.jp/yun_kichi/20100127/1264593665 - post-update の設定
- http://www.redmine.org/issues/779 - Multiple SCM per project
で,target() とかは,lib/redmine/scm/adapters/abstract_adapter.rb を読む流れか.
とりあえず,git clone --mirror すれば,bare リポジトリができるので,
git fetch をcron すれば一応できることは確認できた感じ.
hook かけるのかなー.