Vote #79952
完了Garbage lines in the output of 'git branch' break git adapter
0%
説明
I found that adding an if condition around line 84-89 solves the issue.
change:
branch_rev = line.match('\s*(\*?)\s*(.*?)\s*([0-9a-f]{40}).*$')
bran = GitBranch.new(branch_rev[2])
bran.revision = branch_rev[3]
bran.scmid = branch_rev[3]
bran.is_default = ( branch_rev[1] == '*' )
@branches << bran
To:
if branch_rev = line.match('\s*(\*?)\s*(.*?)\s*([0-9a-f]{40}).*$')
bran = GitBranch.new(branch_rev[2])
bran.revision = branch_rev[3]
bran.scmid = branch_rev[3]
bran.is_default = ( branch_rev[1] == '*' )
@branches << bran
end
journals
The file is {redmineroot}\lib\redmine\scm\adapters\git_adapter.rb
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
I have generated a patch file from Chad Petersen's post.
--------------------------------------------------------------------------------
The fixed code looks correct but I was not able to reproduce the situation that 'git branch --no-color --verbose --no-abbrev' outputs a single branch using two or more lines even if the commit log consists of multiple lines.
Could you tell me the operations to make a repository that causes the problem?
--------------------------------------------------------------------------------
It's a bit of an odd setup. This particular team is using TFS as its source control. So in order to pull it across to git, I'm using the git-TFS integration found here: https://github.com/git-tfs/git-tfs. This appends git commit messages with a new line including the TFS commit so you can trace them back.
--------------------------------------------------------------------------------
Chad Petersen wrote:
> It's a bit of an odd setup. This particular team is using TFS as its source control. So in order to pull it across to git, I'm using the git-TFS integration found here: https://github.com/git-tfs/git-tfs. This appends git commit messages with a new line including the TFS commit so you can trace them back.
I understand. Thank you for clarifying.
I cannot reproduce the problem because I don't use TFS, but the code after line 86 ('@bran = GitBranch...@') must not be executed if @branch_rev@ is nil. I am setting the target version to 3.4.11.
<pre><code class="diff">
diff --git a/lib/redmine/scm/adapters/git_adapter.rb b/lib/redmine/scm/adapters/git_adapter.rb
index e0c5d4763..0733cbc40 100644
--- a/lib/redmine/scm/adapters/git_adapter.rb
+++ b/lib/redmine/scm/adapters/git_adapter.rb
@@ -84,6 +84,7 @@ module Redmine
git_cmd(cmd_args) do |io|
io.each_line do |line|
branch_rev = line.match('\s*(\*?)\s*(.*?)\s*([0-9a-f]{40}).*$')
+ next unless branch_rev
bran = GitBranch.new(branch_rev[2])
bran.revision = branch_rev[3]
bran.scmid = branch_rev[3]
</code></pre>
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Fixed in r18046. Thank you for your contribution.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------