Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Updated from JGit

----------------------------------------------------
JGit commit 770c733
PullCommand: Use short ref name in merge message

Add a test case for PullCommand for the successful merge case and test
that the short ref name is used.

Change-Id: I16cbbc88595f73e5512f984e67f93f87ee0fe242
Signed-off-by: Robin Stocker <robin@nibor.org>
  • Loading branch information...
commit 7cf5227411bdd13cbe47a7ea2fd32a3800e98976 1 parent 9ab4d09
Lluis Sanchez authored March 23, 2011
37  NGit.Test/NGit.Api/PullCommandTest.cs
@@ -43,6 +43,7 @@ written permission.
43 43
 
44 44
 using NGit;
45 45
 using NGit.Api;
  46
+using NGit.Revwalk;
46 47
 using NGit.Storage.File;
47 48
 using NGit.Transport;
48 49
 using Sharpen;
@@ -93,6 +94,36 @@ public virtual void TestPullFastForward()
93 94
 
94 95
 		/// <exception cref="System.Exception"></exception>
95 96
 		[NUnit.Framework.Test]
  97
+		public virtual void TestPullMerge()
  98
+		{
  99
+			PullResult res = target.Pull().Call();
  100
+			// nothing to update since we don't have different data yet
  101
+			NUnit.Framework.Assert.IsTrue(res.GetFetchResult().GetTrackingRefUpdates().IsEmpty
  102
+				());
  103
+			NUnit.Framework.Assert.IsTrue(res.GetMergeResult().GetMergeStatus().Equals(MergeStatus
  104
+				.ALREADY_UP_TO_DATE));
  105
+			WriteToFile(sourceFile, "Source change");
  106
+			source.Add().AddFilepattern("SomeFile.txt");
  107
+			RevCommit sourceCommit = source.Commit().SetMessage("Source change in remote").Call
  108
+				();
  109
+			FilePath targetFile2 = new FilePath(dbTarget.WorkTree, "OtherFile.txt");
  110
+			WriteToFile(targetFile2, "Unconflicting change");
  111
+			target.Add().AddFilepattern("OtherFile.txt").Call();
  112
+			RevCommit targetCommit = target.Commit().SetMessage("Unconflicting change in local"
  113
+				).Call();
  114
+			res = target.Pull().Call();
  115
+			MergeCommandResult mergeResult = res.GetMergeResult();
  116
+			ObjectId[] mergedCommits = mergeResult.GetMergedCommits();
  117
+			NUnit.Framework.Assert.AreEqual(targetCommit.Id, mergedCommits[0]);
  118
+			NUnit.Framework.Assert.AreEqual(sourceCommit.Id, mergedCommits[1]);
  119
+			RevCommit mergeCommit = new RevWalk(dbTarget).ParseCommit(mergeResult.GetNewHead(
  120
+				));
  121
+			string message = "Merge branch 'master' of " + db.WorkTree;
  122
+			NUnit.Framework.Assert.AreEqual(message, mergeCommit.GetShortMessage());
  123
+		}
  124
+
  125
+		/// <exception cref="System.Exception"></exception>
  126
+		[NUnit.Framework.Test]
96 127
 		public virtual void TestPullConflict()
97 128
 		{
98 129
 			PullResult res = target.Pull().Call();
@@ -111,8 +142,8 @@ public virtual void TestPullConflict()
111 142
 			target.Add().AddFilepattern("SomeFile.txt").Call();
112 143
 			target.Commit().SetMessage("Target change in local").Call();
113 144
 			res = target.Pull().Call();
114  
-			string sourceChangeString = "Source change\n>>>>>>> branch 'refs/heads/master' of "
115  
-				 + target.GetRepository().GetConfig().GetString("remote", "origin", "url");
  145
+			string sourceChangeString = "Source change\n>>>>>>> branch 'master' of " + target
  146
+				.GetRepository().GetConfig().GetString("remote", "origin", "url");
116 147
 			NUnit.Framework.Assert.IsFalse(res.GetFetchResult().GetTrackingRefUpdates().IsEmpty
117 148
 				());
118 149
 			NUnit.Framework.Assert.AreEqual(res.GetMergeResult().GetMergeStatus(), MergeStatus
@@ -147,7 +178,7 @@ public virtual void TestPullLocalConflict()
147 178
 			target.Add().AddFilepattern("SomeFile.txt").Call();
148 179
 			target.Commit().SetMessage("Source change in based on master").Call();
149 180
 			res = target.Pull().Call();
150  
-			string sourceChangeString = "Master change\n>>>>>>> branch 'refs/heads/master' of local repository";
  181
+			string sourceChangeString = "Master change\n>>>>>>> branch 'master' of local repository";
151 182
 			NUnit.Framework.Assert.IsNull(res.GetFetchResult());
152 183
 			NUnit.Framework.Assert.AreEqual(res.GetMergeResult().GetMergeStatus(), MergeStatus
153 184
 				.CONFLICTING);
5  NGit/NGit.Api/PullCommand.cs
@@ -277,8 +277,9 @@ public override PullResult Call()
277 277
 			else
278 278
 			{
279 279
 				MergeCommand merge = new MergeCommand(repo);
280  
-				merge.Include("branch \'" + remoteBranchName + "\' of " + remoteUri, commitToMerge
281  
-					);
  280
+				string name = "branch \'" + Repository.ShortenRefName(remoteBranchName) + "\' of "
  281
+					 + remoteUri;
  282
+				merge.Include(name, commitToMerge);
282 283
 				MergeCommandResult mergeRes;
283 284
 				try
284 285
 				{
11  gen/cs.patch
@@ -931,9 +931,18 @@ index 3ba79a5..96758c2 100644
931 931
  						if (merger is ResolveMerger)
932 932
  						{
933 933
 diff --git a/NGit/NGit.Api/MergeCommandResult.cs b/NGit/NGit.Api/MergeCommandResult.cs
934  
-index a24aef5..df27a4c 100644
  934
+index a24aef5..6352029 100644
935 935
 --- a/NGit/NGit.Api/MergeCommandResult.cs
936 936
 +++ b/NGit/NGit.Api/MergeCommandResult.cs
  937
+@@ -92,7 +92,7 @@ namespace NGit.Api
  938
+ 		/// <see cref="NGit.Merge.MergeStrategy">NGit.Merge.MergeStrategy</see>
  939
+ 		/// </param>
  940
+ 		public MergeCommandResult(ObjectId newHead, ObjectId @base, ObjectId[] mergedCommits
  941
+-			, MergeStatus mergeStatus, IDictionary<string, NGit.Merge.MergeResult<object>> lowLevelResults
  942
++			, MergeStatus mergeStatus, IDictionary<string, NGit.Merge.MergeResult<Sequence>> lowLevelResults
  943
+ 			, MergeStrategy mergeStrategy) : this(newHead, @base, mergedCommits, mergeStatus
  944
+ 			, mergeStrategy, lowLevelResults, null)
  945
+ 		{
937 946
 @@ -118,7 +118,7 @@ namespace NGit.Api
938 947
  		/// <param name="description">a user friendly description of the merge result</param>
939 948
  		public MergeCommandResult(ObjectId newHead, ObjectId @base, ObjectId[] mergedCommits
2  gen/lastrev
... ...
@@ -1 +1 @@
1  
-dcf7bd9a8f7acafbd1461dc0414aded2db030983
  1
+770c733687d9f2f71f30822f9691427bf83b7577

0 notes on commit 7cf5227

Please sign in to comment.
Something went wrong with that request. Please try again.