public virtual void TestTrackingRefUpdateEnabled() { RemoteRefUpdate rru = new RemoteRefUpdate(db, "2c349335b7f797072cf729c4f3bb0914ecb6dec9" , "refs/heads/master", false, "refs/remotes/test/master", null); Ref @ref = new ObjectIdRef.Unpeeled(RefStorage.LOOSE, "refs/heads/master", ObjectId .FromString("ac7e7e44c1885efb472ad54a78327d66bfc4ecef")); refUpdates.AddItem(rru); advertisedRefs.AddItem(@ref); PushResult result = ExecutePush(); TrackingRefUpdate tru = result.GetTrackingRefUpdate("refs/remotes/test/master"); NUnit.Framework.Assert.IsNotNull(tru); NUnit.Framework.Assert.AreEqual("refs/remotes/test/master", tru.GetLocalName()); NUnit.Framework.Assert.AreEqual(RefUpdate.Result.NEW, tru.GetResult()); }
/// <exception cref="NGit.Errors.TransportException"></exception> private void DeleteTrackingRef(FetchResult result, Repository db, RevWalk walk, RefSpec spec, Ref localRef) { string name = localRef.GetName(); try { TrackingRefUpdate u = new TrackingRefUpdate(db, name, spec.GetSource(), true, ObjectId .ZeroId, "deleted"); result.Add(u); if (transport.IsDryRun()) { return; } u.Delete(walk); switch (u.GetResult()) { case RefUpdate.Result.NEW: case RefUpdate.Result.NO_CHANGE: case RefUpdate.Result.FAST_FORWARD: case RefUpdate.Result.FORCED: { break; } default: { throw new TransportException(transport.GetURI(), MessageFormat.Format(JGitText.Get ().cannotDeleteStaleTrackingRef2, name, u.GetResult().ToString())); } } } catch (IOException e) { throw new TransportException(transport.GetURI(), MessageFormat.Format(JGitText.Get ().cannotDeleteStaleTrackingRef, name), e); } }
/// <exception cref="NGit.Errors.TransportException"></exception> private void DeleteTrackingRef(FetchResult result, Repository db, RevWalk walk, RefSpec spec, Ref localRef) { string name = localRef.GetName(); try { TrackingRefUpdate u = new TrackingRefUpdate(db, name, spec.GetSource(), true, ObjectId .ZeroId, "deleted"); result.Add(u); if (transport.IsDryRun()) { return; } u.Delete(walk); switch (u.GetResult()) { case RefUpdate.Result.NEW: case RefUpdate.Result.NO_CHANGE: case RefUpdate.Result.FAST_FORWARD: case RefUpdate.Result.FORCED: { break; } default: { throw new TransportException(transport.GetURI(), MessageFormat.Format(JGitText.Get ().cannotDeleteStaleTrackingRef2, name, u.GetResult().ToString())); } } } catch (IOException e) { throw new TransportException(transport.GetURI(), MessageFormat.Format(JGitText.Get ().cannotDeleteStaleTrackingRef, name), e); } }