プロジェクト

全般

プロフィール

Vote #79952

完了

Garbage lines in the output of 'git branch' break git adapter

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
SCM_3
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
3
version_id:
150
issue_org_id:
31120
author_id:
273455
assigned_to_id:
332
comments:
9
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

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.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

Admin Redmine さんが約4年前に更新

  • カテゴリSCM_3 にセット
  • 対象バージョン3.4.11_150 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0