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..046ada5e 100644 --- a/GitTfs/Core/GitRepository.cs +++ b/GitTfs/Core/GitRepository.cs @@ -342,6 +342,11 @@ namespace Sep.Git.Tfs.Core return GitTfsConstants.TfsCommitInfoRegex.Replace(message.ToString(), "").Trim(' ', '\r', '\n'); } + public string GetCommitMessage(string commitish) + { + return GetCommitMessage(commitish, commitish + "^"); + } + 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);