private void UpdateCommand(RemoteRefUpdate u) { try { dest.WriteRef(u.GetRemoteName(), u.GetNewObjectId()); newRefs.Put(u.GetRemoteName(), new ObjectIdRef.Unpeeled(RefStorage.LOOSE, u.GetRemoteName (), u.GetNewObjectId())); u.SetStatus(RemoteRefUpdate.Status.OK); } catch (IOException e) { u.SetStatus(RemoteRefUpdate.Status.REJECTED_OTHER_REASON); u.SetMessage(e.Message); } }
public virtual void TestFindRemoteRefUpdatesNoWildcardNoTracking() { transport = NGit.Transport.Transport.Open(db, remoteConfig); ICollection <RemoteRefUpdate> result = transport.FindRemoteRefUpdatesFor(Collections .NCopies(1, new RefSpec("refs/heads/master:refs/heads/x"))); NUnit.Framework.Assert.AreEqual(1, result.Count); RemoteRefUpdate rru = result.Iterator().Next(); NUnit.Framework.Assert.IsNull(rru.GetExpectedOldObjectId()); NUnit.Framework.Assert.IsFalse(rru.IsForceUpdate()); NUnit.Framework.Assert.AreEqual("refs/heads/master", rru.GetSrcRef()); NUnit.Framework.Assert.AreEqual(db.Resolve("refs/heads/master"), rru.GetNewObjectId ()); NUnit.Framework.Assert.AreEqual("refs/heads/x", rru.GetRemoteName()); }
public void Push (IProgressMonitor monitor, string remote, string remoteBranch) { RemoteConfig remoteConfig = new RemoteConfig (RootRepository.GetConfig (), remote); Transport tp = Transport.Open (RootRepository, remoteConfig); string remoteRef = "refs/heads/" + remoteBranch; RemoteRefUpdate rr = new RemoteRefUpdate (RootRepository, RootRepository.GetBranch (), remoteRef, false, null, null); List<RemoteRefUpdate> list = new List<RemoteRefUpdate> (); list.Add (rr); using (var gm = new GitMonitor (monitor)) tp.Push (gm, list); switch (rr.GetStatus ()) { case RemoteRefUpdate.Status.UP_TO_DATE: monitor.ReportSuccess (GettextCatalog.GetString ("Remote branch is up to date.")); break; case RemoteRefUpdate.Status.REJECTED_NODELETE: monitor.ReportError (GettextCatalog.GetString ("The server is configured to deny deletion of the branch"), null); break; case RemoteRefUpdate.Status.REJECTED_NONFASTFORWARD: monitor.ReportError (GettextCatalog.GetString ("The update is a non-fast-forward update. Merge the remote changes before pushing again."), null); break; case RemoteRefUpdate.Status.OK: monitor.ReportSuccess (GettextCatalog.GetString ("Push operation successfully completed.")); // Update the remote branch ObjectId headId = rr.GetNewObjectId (); RefUpdate updateRef = RootRepository.UpdateRef (Constants.R_REMOTES + remote + "/" + remoteBranch); updateRef.SetNewObjectId(headId); updateRef.Update(); break; default: string msg = rr.GetMessage (); msg = !string.IsNullOrEmpty (msg) ? msg : GettextCatalog.GetString ("Push operation failed"); monitor.ReportError (msg, null); break; } }
private void UpdateCommand(RemoteRefUpdate u) { try { dest.WriteRef(u.GetRemoteName(), u.GetNewObjectId()); newRefs.Put(u.GetRemoteName(), new ObjectIdRef.Unpeeled(RefStorage.LOOSE, u.GetRemoteName (), u.GetNewObjectId())); u.SetStatus(RemoteRefUpdate.Status.OK); } catch (IOException e) { u.SetStatus(RemoteRefUpdate.Status.REJECTED_OTHER_REASON); u.SetMessage(e.Message); } }