Skip to content

Commit 98329b5

Browse files
committed
Merge pull request git-tfs#324 from git-tfs/fix-rcheckin-ignores-no-build-default-comment
Fix: Rcheckin ignores --no-build-default-comment option
2 parents e8d3e6f + 8b921e4 commit 98329b5

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

GitTfs/Commands/Rcheckin.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ private int PerformRCheckin(TfsChangesetInfo parentChangeset)
9696
string target = strs[0];
9797
string[] gitParents = strs.AsEnumerable().Skip(1).Where(hash => hash != currentParent).ToArray();
9898

99-
string commitMessage = repo.GetCommitMessage(target, currentParent).Trim(' ', '\r', '\n');
99+
string commitMessage = _checkinOptions.NoGenerateCheckinComment
100+
? repo.GetCommitMessage(target)
101+
: repo.GetCommitMessage(target, currentParent);
100102
var commitSpecificCheckinOptions = _checkinOptionsFactory.BuildCommitSpecificCheckinOptions(_checkinOptions, commitMessage);
101103

102104
_stdout.WriteLine("Starting checkin of {0} '{1}'", target.Substring(0, 8), commitSpecificCheckinOptions.CheckinComment);
@@ -153,7 +155,9 @@ private int PerformRCheckin(TfsChangesetInfo parentChangeset)
153155
string target = strs[0];
154156
string[] gitParents = strs.AsEnumerable().Skip(1).Where(hash => hash != tfsLatest).ToArray();
155157

156-
string commitMessage = repo.GetCommitMessage(target, tfsLatest).Trim(' ', '\r', '\n');
158+
string commitMessage = _checkinOptions.NoGenerateCheckinComment
159+
? repo.GetCommitMessage(target)
160+
: repo.GetCommitMessage(target, tfsLatest);
157161
var commitSpecificCheckinOptions = _checkinOptionsFactory.BuildCommitSpecificCheckinOptions(_checkinOptions, commitMessage);
158162
_stdout.WriteLine("Starting checkin of {0} '{1}'", target.Substring(0, 8), commitSpecificCheckinOptions.CheckinComment);
159163
long newChangesetId = tfsRemote.Checkin(target, parentChangeset, commitSpecificCheckinOptions);

GitTfs/Core/GitRepository.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,11 @@ public string GetCommitMessage(string head, string parentCommitish)
342342
return GitTfsConstants.TfsCommitInfoRegex.Replace(message.ToString(), "").Trim(' ', '\r', '\n');
343343
}
344344

345+
public string GetCommitMessage(string commitish)
346+
{
347+
return GetCommitMessage(commitish, commitish + "^");
348+
}
349+
345350
private static string NormalizeLineEndings(string input)
346351
{
347352
return string.IsNullOrEmpty(input)

GitTfs/Core/IGitRepository.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public interface IGitRepository : IGitHelpers
2929
GitCommit GetCommit(string commitish);
3030
Dictionary<string, GitObject> GetObjects();
3131
string GetCommitMessage(string head, string parentCommitish);
32+
string GetCommitMessage(string commitish);
3233
string AssertValidBranchName(string gitBranchName);
3334
bool CreateBranch(string gitBranchName, string target);
3435
Branch RenameBranch(string oldName, string newName);

0 commit comments

Comments
 (0)