예제 #1
0
        public virtual void TestTrackingRefUpdateOnReject()
        {
            RemoteRefUpdate rru = new RemoteRefUpdate(db, "ac7e7e44c1885efb472ad54a78327d66bfc4ecef"
                                                      , "refs/heads/master", false, null, null);
            Ref @ref = new ObjectIdRef.Unpeeled(RefStorage.LOOSE, "refs/heads/master", ObjectId
                                                .FromString("2c349335b7f797072cf729c4f3bb0914ecb6dec9"));
            PushResult result = TestOneUpdateStatus(rru, @ref, RemoteRefUpdate.Status.REJECTED_NONFASTFORWARD
                                                    , null);

            NUnit.Framework.Assert.IsTrue(result.GetTrackingRefUpdates().IsEmpty());
        }
예제 #2
0
        public virtual void TestTrackingRefUpdateDisabled()
        {
            RemoteRefUpdate rru = new RemoteRefUpdate(db, "2c349335b7f797072cf729c4f3bb0914ecb6dec9"
                                                      , "refs/heads/master", false, null, null);
            Ref @ref = new ObjectIdRef.Unpeeled(RefStorage.LOOSE, "refs/heads/master", ObjectId
                                                .FromString("ac7e7e44c1885efb472ad54a78327d66bfc4ecef"));

            refUpdates.AddItem(rru);
            advertisedRefs.AddItem(@ref);
            PushResult result = ExecutePush();

            NUnit.Framework.Assert.IsTrue(result.GetTrackingRefUpdates().IsEmpty());
        }
예제 #3
0
 /// <summary>
 /// Perform push operation between local and remote repository - set remote
 /// refs appropriately, send needed objects and update local tracking refs.
 /// </summary>
 /// <remarks>
 /// Perform push operation between local and remote repository - set remote
 /// refs appropriately, send needed objects and update local tracking refs.
 /// <p>
 /// When
 /// <see cref="Transport.IsDryRun()">Transport.IsDryRun()</see>
 /// is true, result of this operation is
 /// just estimation of real operation result, no real action is performed.
 /// </remarks>
 /// <param name="monitor">progress monitor used for feedback about operation.</param>
 /// <returns>result of push operation with complete status description.</returns>
 /// <exception cref="System.NotSupportedException">when push operation is not supported by provided transport.
 ///     </exception>
 /// <exception cref="NGit.Errors.TransportException">
 /// when some error occurred during operation, like I/O, protocol
 /// error, or local database consistency error.
 /// </exception>
 internal virtual PushResult Execute(ProgressMonitor monitor)
 {
     try
     {
         monitor.BeginTask(PROGRESS_OPENING_CONNECTION, ProgressMonitor.UNKNOWN);
         PushResult res = new PushResult();
         connection = transport.OpenPush();
         try
         {
             res.SetAdvertisedRefs(transport.GetURI(), connection.GetRefsMap());
             res.SetRemoteUpdates(toPush);
             monitor.EndTask();
             IDictionary <string, RemoteRefUpdate> preprocessed = PrepareRemoteUpdates();
             if (transport.IsDryRun())
             {
                 ModifyUpdatesForDryRun();
             }
             else
             {
                 if (!preprocessed.IsEmpty())
                 {
                     connection.Push(monitor, preprocessed);
                 }
             }
         }
         finally
         {
             connection.Close();
             res.AddMessages(connection.GetMessages());
         }
         if (!transport.IsDryRun())
         {
             UpdateTrackingRefs();
         }
         foreach (RemoteRefUpdate rru in toPush.Values)
         {
             TrackingRefUpdate tru = rru.GetTrackingRefUpdate();
             if (tru != null)
             {
                 res.Add(tru);
             }
         }
         return(res);
     }
     finally
     {
         walker.Release();
     }
 }
예제 #4
0
        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());
        }
예제 #5
0
        /// <exception cref="System.NotSupportedException"></exception>
        /// <exception cref="NGit.Errors.TransportException"></exception>
        private PushResult TestOneUpdateStatus(RemoteRefUpdate rru, Ref advertisedRef, RemoteRefUpdate.Status
                                               expectedStatus, bool?fastForward)
        {
            refUpdates.AddItem(rru);
            if (advertisedRef != null)
            {
                advertisedRefs.AddItem(advertisedRef);
            }
            PushResult result = ExecutePush();

            NUnit.Framework.Assert.AreEqual(expectedStatus, rru.GetStatus());
            if (fastForward != null)
            {
                NUnit.Framework.Assert.AreEqual(fastForward.Value, rru.IsFastForward());
            }
            return(result);
        }
예제 #6
0
		/// <summary>
		/// Perform push operation between local and remote repository - set remote
		/// refs appropriately, send needed objects and update local tracking refs.
		/// </summary>
		/// <remarks>
		/// Perform push operation between local and remote repository - set remote
		/// refs appropriately, send needed objects and update local tracking refs.
		/// <p>
		/// When
		/// <see cref="Transport.IsDryRun()">Transport.IsDryRun()</see>
		/// is true, result of this operation is
		/// just estimation of real operation result, no real action is performed.
		/// </remarks>
		/// <param name="monitor">progress monitor used for feedback about operation.</param>
		/// <returns>result of push operation with complete status description.</returns>
		/// <exception cref="System.NotSupportedException">when push operation is not supported by provided transport.
		/// 	</exception>
		/// <exception cref="NGit.Errors.TransportException">
		/// when some error occurred during operation, like I/O, protocol
		/// error, or local database consistency error.
		/// </exception>
		internal virtual PushResult Execute(ProgressMonitor monitor)
		{
			try
			{
				monitor.BeginTask(PROGRESS_OPENING_CONNECTION, ProgressMonitor.UNKNOWN);
				PushResult res = new PushResult();
				connection = transport.OpenPush();
				try
				{
					res.SetAdvertisedRefs(transport.GetURI(), connection.GetRefsMap());
					res.SetRemoteUpdates(toPush);
					monitor.EndTask();
					IDictionary<string, RemoteRefUpdate> preprocessed = PrepareRemoteUpdates();
					if (transport.IsDryRun())
					{
						ModifyUpdatesForDryRun();
					}
					else
					{
						if (!preprocessed.IsEmpty())
						{
							connection.Push(monitor, preprocessed);
						}
					}
				}
				finally
				{
					connection.Close();
					res.AddMessages(connection.GetMessages());
				}
				if (!transport.IsDryRun())
				{
					UpdateTrackingRefs();
				}
				foreach (RemoteRefUpdate rru in toPush.Values)
				{
					TrackingRefUpdate tru = rru.GetTrackingRefUpdate();
					if (tru != null)
					{
						res.Add(tru);
					}
				}
				return res;
			}
			finally
			{
				walker.Release();
			}
		}