public void testUpdateDelete() { RemoteRefUpdate rru = new RemoteRefUpdate(db, null, "refs/heads/master", false, null, null); Core.Ref @ref = new Unpeeled(Storage.Loose, "refs/heads/master", ObjectId.FromString("2c349335b7f797072cf729c4f3bb0914ecb6dec9")); testOneUpdateStatus(rru, @ref, RemoteRefUpdate.UpdateStatus.OK, true); }
public void testUpdateUpToDate() { RemoteRefUpdate rru = new RemoteRefUpdate(db, "2c349335b7f797072cf729c4f3bb0914ecb6dec9", "refs/heads/master", false, null, null); Core.Ref @ref = new Core.Ref(Core.Ref.Storage.Loose, "refs/heads/master", ObjectId.FromString("2c349335b7f797072cf729c4f3bb0914ecb6dec9")); testOneUpdateStatus(rru, @ref, RemoteRefUpdate.UpdateStatus.UP_TO_DATE, null); }
public void testUpdateCreateRef() { RemoteRefUpdate rru = new RemoteRefUpdate(db, "ac7e7e44c1885efb472ad54a78327d66bfc4ecef", "refs/heads/master", false, null, null); testOneUpdateStatus(rru, null, RemoteRefUpdate.UpdateStatus.OK, true); }
public void testUpdateNonFastForwardForced() { RemoteRefUpdate rru = new RemoteRefUpdate(db, "ac7e7e44c1885efb472ad54a78327d66bfc4ecef", "refs/heads/master", true, null, null); Core.Ref @ref = new Core.Ref(Core.Ref.Storage.Loose, "refs/heads/master", ObjectId.FromString("2c349335b7f797072cf729c4f3bb0914ecb6dec9")); testOneUpdateStatus(rru, @ref, RemoteRefUpdate.UpdateStatus.OK, false); }
public void testUpdateNonFastForwardUnknownObject() { RemoteRefUpdate rru = new RemoteRefUpdate(db, "2c349335b7f797072cf729c4f3bb0914ecb6dec9", "refs/heads/master", false, null, null); Core.Ref @ref = new Core.Ref(Core.Ref.Storage.Loose, "refs/heads/master", ObjectId.FromString("0000000000000000000000000000000000000001")); testOneUpdateStatus(rru, @ref, RemoteRefUpdate.UpdateStatus.REJECTED_NONFASTFORWARD, null); }
public void testUpdateRejectedByConnection() { connectionUpdateStatus = RemoteRefUpdate.UpdateStatus.REJECTED_OTHER_REASON; RemoteRefUpdate rru = new RemoteRefUpdate(db, "2c349335b7f797072cf729c4f3bb0914ecb6dec9", "refs/heads/master", false, null, null); Core.Ref @ref = new Core.Ref(Core.Ref.Storage.Loose, "refs/heads/master", ObjectId.FromString("ac7e7e44c1885efb472ad54a78327d66bfc4ecef")); testOneUpdateStatus(rru, @ref, RemoteRefUpdate.UpdateStatus.REJECTED_OTHER_REASON, null); }
public void testUpdateUnexpectedRemoteVsForce() { RemoteRefUpdate rru = new RemoteRefUpdate(db, "2c349335b7f797072cf729c4f3bb0914ecb6dec9", "refs/heads/master", true, null, ObjectId.FromString("0000000000000000000000000000000000000001")); Core.Ref @ref = new Core.Ref(Core.Ref.Storage.Loose, "refs/heads/master", ObjectId.FromString("ac7e7e44c1885efb472ad54a78327d66bfc4ecef")); testOneUpdateStatus(rru, @ref, RemoteRefUpdate.UpdateStatus.REJECTED_REMOTE_CHANGED, null); }
public void testUpdateExpectedRemote() { RemoteRefUpdate rru = new RemoteRefUpdate(db, "2c349335b7f797072cf729c4f3bb0914ecb6dec9", "refs/heads/master", false, null, ObjectId.FromString("ac7e7e44c1885efb472ad54a78327d66bfc4ecef")); Core.Ref @ref = new Unpeeled(Storage.Loose, "refs/heads/master", ObjectId.FromString("ac7e7e44c1885efb472ad54a78327d66bfc4ecef")); testOneUpdateStatus(rru, @ref, RemoteRefUpdate.UpdateStatus.OK, true); }
public void testTrackingRefUpdateOnReject() { RemoteRefUpdate rru = new RemoteRefUpdate(db, "ac7e7e44c1885efb472ad54a78327d66bfc4ecef", "refs/heads/master", false, null, null); Core.Ref @ref = new Core.Ref(Core.Ref.Storage.Loose, "refs/heads/master", ObjectId.FromString("2c349335b7f797072cf729c4f3bb0914ecb6dec9")); PushResult result = testOneUpdateStatus(rru, @ref, RemoteRefUpdate.UpdateStatus.REJECTED_NONFASTFORWARD, null); Assert.IsTrue(result.TrackingRefUpdates.Count == 0); }
public void testTrackingRefUpdateDisabled() { RemoteRefUpdate rru = new RemoteRefUpdate(db, "2c349335b7f797072cf729c4f3bb0914ecb6dec9", "refs/heads/master", false, null, null); Core.Ref @ref = new Core.Ref(Core.Ref.Storage.Loose, "refs/heads/master", ObjectId.FromString("ac7e7e44c1885efb472ad54a78327d66bfc4ecef")); refUpdates.Add(rru); advertisedRefs.Add(@ref); PushResult result = executePush(); Assert.IsTrue(result.TrackingRefUpdates.Count == 0); }
public void testTrackingRefUpdateEnabled() { RemoteRefUpdate rru = new RemoteRefUpdate(db, "2c349335b7f797072cf729c4f3bb0914ecb6dec9", "refs/heads/master", false, "refs/remotes/test/master", null); Core.Ref @ref = new Core.Ref(Core.Ref.Storage.Loose, "refs/heads/master", ObjectId.FromString("ac7e7e44c1885efb472ad54a78327d66bfc4ecef")); refUpdates.Add(rru); advertisedRefs.Add(@ref); PushResult result = executePush(); TrackingRefUpdate tru = result.GetTrackingRefUpdate("refs/remotes/test/master"); Assert.IsNotNull(tru); Assert.AreEqual("refs/remotes/test/master", tru.LocalName); Assert.AreEqual(RefUpdate.RefUpdateResult.New, tru.Result); }
public void testUpdateMixedCases() { RemoteRefUpdate rruOk = new RemoteRefUpdate(db, null, "refs/heads/master", false, null, null); Core.Ref refToChange = new Core.Ref(Core.Ref.Storage.Loose, "refs/heads/master", ObjectId.FromString("2c349335b7f797072cf729c4f3bb0914ecb6dec9")); RemoteRefUpdate rruReject = new RemoteRefUpdate(db, null, "refs/heads/nonexisting", false, null, null); refUpdates.Add(rruOk); refUpdates.Add(rruReject); advertisedRefs.Add(refToChange); executePush(); Assert.AreEqual(RemoteRefUpdate.UpdateStatus.OK, rruOk.Status); Assert.AreEqual(true, rruOk.FastForward); Assert.AreEqual(RemoteRefUpdate.UpdateStatus.NON_EXISTING, rruReject.Status); }
private PushResult testOneUpdateStatus(RemoteRefUpdate rru, Core.Ref advertisedRef, RemoteRefUpdate.UpdateStatus expectedStatus, bool?fastForward) { refUpdates.Add(rru); if (advertisedRef != null) { advertisedRefs.Add(advertisedRef); } PushResult result = executePush(); Assert.AreEqual(expectedStatus, rru.Status); if (fastForward.HasValue) { Assert.AreEqual(fastForward.Value, rru.FastForward); } return(result); }
public void testPushResult() { RemoteRefUpdate rru = new RemoteRefUpdate(db, "2c349335b7f797072cf729c4f3bb0914ecb6dec9", "refs/heads/master", false, "refs/remotes/test/master", null); Core.Ref @ref = new Unpeeled(Storage.Loose, "refs/heads/master", ObjectId.FromString("ac7e7e44c1885efb472ad54a78327d66bfc4ecef")); refUpdates.Add(rru); advertisedRefs.Add(@ref); PushResult result = executePush(); Assert.AreEqual(1, result.TrackingRefUpdates.Count); Assert.AreEqual(1, result.AdvertisedRefs.Count); Assert.AreEqual(1, result.RemoteUpdates.Count); Assert.IsNotNull(result.GetTrackingRefUpdate("refs/remotes/test/master")); Assert.IsNotNull(result.GetAdvertisedRef("refs/heads/master")); Assert.IsNotNull(result.GetRemoteUpdate("refs/heads/master")); }
public void testFindRemoteRefUpdatesNoWildcardNoDestination() { transport = GitSharp.Core.Transport.Transport.Open(db, remoteConfig); ICollection <RemoteRefUpdate> result = transport.findRemoteRefUpdatesFor(new List <RefSpec> { new RefSpec("+refs/heads/master") }); Assert.AreEqual(1, result.Count); RemoteRefUpdate rru = result.ToArray()[0]; Assert.AreEqual(null, rru.ExpectedOldObjectId); Assert.IsTrue(rru.ForceUpdate); Assert.AreEqual("refs/heads/master", rru.SourceRef); Assert.AreEqual(db.Resolve("refs/heads/master"), rru.NewObjectId); Assert.AreEqual("refs/heads/master", rru.RemoteName); }
private void printRefUpdateResult(URIish uri, OperationResult result, RemoteRefUpdate rru) { if (!shownUri) { shownUri = true; OutputStream.WriteLine("To " + uri); } string remoteName = rru.RemoteName; string srcRef = rru.IsDelete ? null : rru.SourceRef; switch (rru.Status) { case RemoteRefUpdate.UpdateStatus.OK: { if (rru.IsDelete) { printUpdateLine('-', "[deleted]", null, remoteName, null); } else { GitSharp.Core.Ref oldRef = result.GetAdvertisedRef(remoteName); if (oldRef == null) { string summary = remoteName.StartsWith(Constants.R_TAGS) ? "[new tag]" : "[new branch]"; printUpdateLine('*', summary, srcRef, remoteName, null); } else { bool fastForward = rru.FastForward; char flag = fastForward ? ' ' : '+'; string summary = oldRef.ObjectId.Abbreviate(Repository._internal_repo).name() + (fastForward ? ".." : "...") + rru.NewObjectId.Abbreviate(Repository._internal_repo).name(); string message = fastForward ? null : "forced update"; printUpdateLine(flag, summary, srcRef, remoteName, message); } } break; } case RemoteRefUpdate.UpdateStatus.NON_EXISTING: printUpdateLine('X', "[no match]", null, remoteName, null); break; case RemoteRefUpdate.UpdateStatus.REJECTED_NODELETE: printUpdateLine('!', "[rejected]", null, remoteName, "remote side does not support deleting refs"); break; case RemoteRefUpdate.UpdateStatus.REJECTED_NONFASTFORWARD: printUpdateLine('!', "[rejected]", srcRef, remoteName, "non-fast forward"); break; case RemoteRefUpdate.UpdateStatus.REJECTED_REMOTE_CHANGED: { string message = "remote ref object changed - is not expected one " + rru.ExpectedOldObjectId.Abbreviate(Repository._internal_repo).name(); printUpdateLine('!', "[rejected]", srcRef, remoteName, message); break; } case RemoteRefUpdate.UpdateStatus.REJECTED_OTHER_REASON: printUpdateLine('!', "[rejected]", srcRef, remoteName, rru.Message); break; case RemoteRefUpdate.UpdateStatus.UP_TO_DATE: if (Verbose) { printUpdateLine('=', "[up to date]", srcRef, remoteName, null); } break; case RemoteRefUpdate.UpdateStatus.NOT_ATTEMPTED: case RemoteRefUpdate.UpdateStatus.AWAITING_REPORT: printUpdateLine('?', "[unexpected push-process behavior]", srcRef, remoteName, rru.Message); break; } }
public void testUpdateDeleteNonExisting() { RemoteRefUpdate rru = new RemoteRefUpdate(db, null, "refs/heads/master", false, null, null); testOneUpdateStatus(rru, null, RemoteRefUpdate.UpdateStatus.NON_EXISTING, null); }
public void push(ProgressMonitor monitor, Map<String, RemoteRefUpdate> refsToUpdate)