Defect #1319
git's "get_rev" API should use repo's current branch instead of hardwiring "master"
| Status: | Closed | Start: | 2008-05-28 | |
| Priority: | High | Due date: | ||
| Assigned to: | - | % Done: | 0% |
|
| Category: | SCM | |||
| Target version: | 0.7.2 | |||
| Affected version: | Resolution: | Fixed |
||
Description
@lib/redmine/scm/adapters/git_adapter.rb@ gets the revision (
If the repo does not use master, this won't work properly -- the "Browse" table will be stuck at "master" (assuming the branch exists) but the "Latest Revisions" table will show commits to the current branch. In effect, you will not be able to browse the tree to see the files changed in the commits you can see.
I propose the following instead:
This adds an additional shellout to get the current branch of the current repository and passes that to the cmd string (replacing the hard-wired "master").
git_rev -- line 31 in particular (lines 30-32 shown) using the following cmd:1 cmd="git --git-dir #{target('')} show #{shell_quote rev} -- #{shell_quote path}" if rev!='latest' and (! rev.nil?)
2 cmd="git --git-dir #{target('')} log -1 master -- #{shell_quote path}" if
3 rev=='latest' or rev.nil?
If the repo does not use master, this won't work properly -- the "Browse" table will be stuck at "master" (assuming the branch exists) but the "Latest Revisions" table will show commits to the current branch. In effect, you will not be able to browse the tree to see the files changed in the commits you can see.
I propose the following instead:
1 if rev!='latest' and (! rev.nil?)
2 cmd="git --git-dir #{target('')} show #{shell_quote rev} -- #{shell_quote path}"
3 else
4 branch = shellout("git --git-dir #{target('')} branch") { |io| io.grep(/\*/)[0].strip.match(/\* (.*)/)[1] }
5 cmd="git --git-dir #{target('')} log -1 #{branch} -- #{shell_quote path}"
6 end
This adds an additional shellout to get the current branch of the current repository and passes that to the cmd string (replacing the hard-wired "master").
Associated revisions
Fixed: GitAdapter#get_rev should use current branch instead of hardwiring master (#1319).