From e74170291a72dcb2811a74e9a7e9193ce5e2d50b Mon Sep 17 00:00:00 2001 From: "ivan.danilov-econ" Date: Mon, 11 Mar 2013 15:33:43 +0200 Subject: [PATCH 1/2] Fix: Rcheckin ignores --no-build-default-comment option (during rcheckin of merge commit prevents including all comments from merged commits below original merge-commit comment in git) --- GitTfs/Commands/Rcheckin.cs | 8 ++++++-- GitTfs/Core/GitRepository.cs | 6 ++++++ GitTfs/Core/IGitRepository.cs | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/GitTfs/Commands/Rcheckin.cs b/GitTfs/Commands/Rcheckin.cs index 4a11dff6..67c3a2c7 100644 --- a/GitTfs/Commands/Rcheckin.cs +++ b/GitTfs/Commands/Rcheckin.cs @@ -96,7 +96,9 @@ namespace Sep.Git.Tfs.Commands string target = strs[0]; string[] gitParents = strs.AsEnumerable().Skip(1).Where(hash => hash != currentParent).ToArray(); - string commitMessage = repo.GetCommitMessage(target, currentParent).Trim(' ', '\r', '\n'); + string commitMessage = _checkinOptions.NoGenerateCheckinComment + ? repo.GetCommitMessage(target) + : repo.GetCommitMessage(target, currentParent); var commitSpecificCheckinOptions = _checkinOptionsFactory.BuildCommitSpecificCheckinOptions(_checkinOptions, commitMessage); _stdout.WriteLine("Starting checkin of {0} '{1}'", target.Substring(0, 8), commitSpecificCheckinOptions.CheckinComment); @@ -153,7 +155,9 @@ namespace Sep.Git.Tfs.Commands string target = strs[0]; string[] gitParents = strs.AsEnumerable().Skip(1).Where(hash => hash != tfsLatest).ToArray(); - string commitMessage = repo.GetCommitMessage(target, tfsLatest).Trim(' ', '\r', '\n'); + string commitMessage = _checkinOptions.NoGenerateCheckinComment + ? repo.GetCommitMessage(target) + : repo.GetCommitMessage(target, tfsLatest); var commitSpecificCheckinOptions = _checkinOptionsFactory.BuildCommitSpecificCheckinOptions(_checkinOptions, commitMessage); _stdout.WriteLine("Starting checkin of {0} '{1}'", target.Substring(0, 8), commitSpecificCheckinOptions.CheckinComment); long newChangesetId = tfsRemote.Checkin(target, parentChangeset, commitSpecificCheckinOptions); diff --git a/GitTfs/Core/GitRepository.cs b/GitTfs/Core/GitRepository.cs index 55da335e..d04e9c1d 100644 --- a/GitTfs/Core/GitRepository.cs +++ b/GitTfs/Core/GitRepository.cs @@ -342,6 +342,12 @@ namespace Sep.Git.Tfs.Core return GitTfsConstants.TfsCommitInfoRegex.Replace(message.ToString(), "").Trim(' ', '\r', '\n'); } + public string GetCommitMessage(string commitish) + { + var commit = _repository.Lookup(commitish); + return GitTfsConstants.TfsCommitInfoRegex.Replace(commit.Message, "").Trim(' ', '\r', '\n'); + } + private static string NormalizeLineEndings(string input) { return string.IsNullOrEmpty(input) diff --git a/GitTfs/Core/IGitRepository.cs b/GitTfs/Core/IGitRepository.cs index 4f4601fa..f5b74917 100644 --- a/GitTfs/Core/IGitRepository.cs +++ b/GitTfs/Core/IGitRepository.cs @@ -29,6 +29,7 @@ namespace Sep.Git.Tfs.Core GitCommit GetCommit(string commitish); Dictionary GetObjects(); string GetCommitMessage(string head, string parentCommitish); + string GetCommitMessage(string commitish); string AssertValidBranchName(string gitBranchName); bool CreateBranch(string gitBranchName, string target); Branch RenameBranch(string oldName, string newName); From 8b921e4cf3c6d5cb2f72b8b409c4126b38d01151 Mon Sep 17 00:00:00 2001 From: ivan-danilov Date: Thu, 21 Mar 2013 14:52:55 +0200 Subject: [PATCH 2/2] Removed duplicated line after Matt's review. --- GitTfs/Core/GitRepository.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/GitTfs/Core/GitRepository.cs b/GitTfs/Core/GitRepository.cs index d04e9c1d..046ada5e 100644 --- a/GitTfs/Core/GitRepository.cs +++ b/GitTfs/Core/GitRepository.cs @@ -344,8 +344,7 @@ namespace Sep.Git.Tfs.Core public string GetCommitMessage(string commitish) { - var commit = _repository.Lookup(commitish); - return GitTfsConstants.TfsCommitInfoRegex.Replace(commit.Message, "").Trim(' ', '\r', '\n'); + return GetCommitMessage(commitish, commitish + "^"); } private static string NormalizeLineEndings(string input)