コード例 #1
0
ファイル: PushProcessTest.cs プロジェクト: shoff/ngit
		public override void SetUp()
		{
			base.SetUp();
			transport = new PushProcessTest.MockTransport(this, db, new URIish());
			refUpdates = new HashSet<RemoteRefUpdate>();
			advertisedRefs = new HashSet<Ref>();
			connectionUpdateStatus = RemoteRefUpdate.Status.OK;
		}
コード例 #2
0
 public override void SetUp()
 {
     base.SetUp();
     transport              = new PushProcessTest.MockTransport(this, db, new URIish());
     refUpdates             = new HashSet <RemoteRefUpdate>();
     advertisedRefs         = new HashSet <Ref>();
     connectionUpdateStatus = RemoteRefUpdate.Status.OK;
 }
コード例 #3
0
 /// <summary>Construct remote ref update request by providing an update specification.
 ///     </summary>
 /// <remarks>
 /// Construct remote ref update request by providing an update specification.
 /// Object is created with default
 /// <see cref="Status.NOT_ATTEMPTED">Status.NOT_ATTEMPTED</see>
 /// status and no
 /// message.
 /// </remarks>
 /// <param name="localDb">local repository to push from.</param>
 /// <param name="srcRef">
 /// source revision to label srcId with. If null srcId.name() will
 /// be used instead.
 /// </param>
 /// <param name="srcId">
 /// The new object that the caller wants remote ref to be after
 /// update. Use null or
 /// <see cref="NGit.ObjectId.ZeroId()">NGit.ObjectId.ZeroId()</see>
 /// for delete
 /// request.
 /// </param>
 /// <param name="remoteName">
 /// full name of a remote ref to update, e.g. "refs/heads/master"
 /// (no wildcard, no short name).
 /// </param>
 /// <param name="forceUpdate">
 /// true when caller want remote ref to be updated regardless
 /// whether it is fast-forward update (old object is ancestor of
 /// new object).
 /// </param>
 /// <param name="localName">
 /// optional full name of a local stored tracking branch, to
 /// update after push, e.g. "refs/remotes/zawir/dirty" (no
 /// wildcard, no short name); null if no local tracking branch
 /// should be updated.
 /// </param>
 /// <param name="expectedOldObjectId">
 /// optional object id that caller is expecting, requiring to be
 /// advertised by remote side before update; update will take
 /// place ONLY if remote side advertise exactly this expected id;
 /// null if caller doesn't care what object id remote side
 /// advertise. Use
 /// <see cref="NGit.ObjectId.ZeroId()">NGit.ObjectId.ZeroId()</see>
 /// when expecting no
 /// remote ref with this name.
 /// </param>
 /// <exception cref="System.IO.IOException">
 /// when I/O error occurred during creating
 /// <see cref="TrackingRefUpdate">TrackingRefUpdate</see>
 /// for local tracking branch or srcRef
 /// can't be resolved to any object.
 /// </exception>
 /// <exception cref="System.ArgumentException">if some required parameter was null</exception>
 public RemoteRefUpdate(Repository localDb, string srcRef, ObjectId srcId, string
                        remoteName, bool forceUpdate, string localName, ObjectId expectedOldObjectId)
 {
     if (remoteName == null)
     {
         throw new ArgumentException(JGitText.Get().remoteNameCantBeNull);
     }
     if (srcId == null && srcRef != null)
     {
         throw new IOException(MessageFormat.Format(JGitText.Get().sourceRefDoesntResolveToAnyObject
                                                    , srcRef));
     }
     if (srcRef != null)
     {
         this.srcRef = srcRef;
     }
     else
     {
         if (srcId != null && !srcId.Equals(ObjectId.ZeroId))
         {
             this.srcRef = srcId.Name;
         }
         else
         {
             this.srcRef = null;
         }
     }
     if (srcId != null)
     {
         this.newObjectId = srcId;
     }
     else
     {
         this.newObjectId = ObjectId.ZeroId;
     }
     this.remoteName  = remoteName;
     this.forceUpdate = forceUpdate;
     if (localName != null && localDb != null)
     {
         localUpdate = localDb.UpdateRef(localName);
         localUpdate.SetForceUpdate(true);
         localUpdate.SetRefLogMessage("push", true);
         localUpdate.SetNewObjectId(newObjectId);
         trackingRefUpdate = new TrackingRefUpdate(true, remoteName, localName, localUpdate
                                                   .GetOldObjectId() != null ? localUpdate.GetOldObjectId() : ObjectId.ZeroId, newObjectId
                                                   );
     }
     else
     {
         trackingRefUpdate = null;
     }
     this.localDb             = localDb;
     this.expectedOldObjectId = expectedOldObjectId;
     this.status = RemoteRefUpdate.Status.NOT_ATTEMPTED;
 }
コード例 #4
0
 private void UpdateSuccessStatus(RemoteRefUpdate.Status status)
 {
     if (status == RemoteRefUpdate.Status.OK || status == RemoteRefUpdate.Status.UP_TO_DATE)
     {
         Success = true;
     }
     else
     {
         Success = false;
     }
 }
コード例 #5
0
        public virtual void TestUpdateRejectedByConnection()
        {
            connectionUpdateStatus = RemoteRefUpdate.Status.REJECTED_OTHER_REASON;
            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"));

            TestOneUpdateStatus(rru, @ref, RemoteRefUpdate.Status.REJECTED_OTHER_REASON, null
                                );
        }
コード例 #6
0
 private void UpdateTrackingRefs()
 {
     foreach (RemoteRefUpdate rru in toPush.Values)
     {
         RemoteRefUpdate.Status status = rru.GetStatus();
         if (rru.HasTrackingRefUpdate() && (status == RemoteRefUpdate.Status.UP_TO_DATE ||
                                            status == RemoteRefUpdate.Status.OK))
         {
             // update local tracking branch only when there is a chance that
             // it has changed; this is possible for:
             // -updated (OK) status,
             // -up to date (UP_TO_DATE) status
             try
             {
                 rru.UpdateTrackingRef(walker);
             }
             catch (IOException)
             {
             }
         }
     }
 }
コード例 #7
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);
        }
コード例 #8
0
ファイル: PushProcessTest.cs プロジェクト: shoff/ngit
		public virtual void TestUpdateRejectedByConnection()
		{
			connectionUpdateStatus = RemoteRefUpdate.Status.REJECTED_OTHER_REASON;
			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"));
			TestOneUpdateStatus(rru, @ref, RemoteRefUpdate.Status.REJECTED_OTHER_REASON, null
				);
		}
コード例 #9
0
ファイル: RemoteRefUpdate.cs プロジェクト: shoff/ngit
 internal virtual void SetStatus(RemoteRefUpdate.Status status)
 {
     this.status = status;
 }
コード例 #10
0
		internal virtual void SetStatus(RemoteRefUpdate.Status status)
		{
			this.status = status;
		}
コード例 #11
0
		/// <summary>Construct remote ref update request by providing an update specification.
		/// 	</summary>
		/// <remarks>
		/// Construct remote ref update request by providing an update specification.
		/// Object is created with default
		/// <see cref="Status.NOT_ATTEMPTED">Status.NOT_ATTEMPTED</see>
		/// status and no
		/// message.
		/// </remarks>
		/// <param name="localDb">local repository to push from.</param>
		/// <param name="srcRef">
		/// source revision - any string resolvable by
		/// <see cref="NGit.Repository.Resolve(string)">NGit.Repository.Resolve(string)</see>
		/// . This resolves to the new
		/// object that the caller want remote ref to be after update. Use
		/// null or
		/// <see cref="NGit.ObjectId.ZeroId()">NGit.ObjectId.ZeroId()</see>
		/// string for delete request.
		/// </param>
		/// <param name="remoteName">
		/// full name of a remote ref to update, e.g. "refs/heads/master"
		/// (no wildcard, no short name).
		/// </param>
		/// <param name="forceUpdate">
		/// true when caller want remote ref to be updated regardless
		/// whether it is fast-forward update (old object is ancestor of
		/// new object).
		/// </param>
		/// <param name="localName">
		/// optional full name of a local stored tracking branch, to
		/// update after push, e.g. "refs/remotes/zawir/dirty" (no
		/// wildcard, no short name); null if no local tracking branch
		/// should be updated.
		/// </param>
		/// <param name="expectedOldObjectId">
		/// optional object id that caller is expecting, requiring to be
		/// advertised by remote side before update; update will take
		/// place ONLY if remote side advertise exactly this expected id;
		/// null if caller doesn't care what object id remote side
		/// advertise. Use
		/// <see cref="NGit.ObjectId.ZeroId()">NGit.ObjectId.ZeroId()</see>
		/// when expecting no
		/// remote ref with this name.
		/// </param>
		/// <exception cref="System.IO.IOException">
		/// when I/O error occurred during creating
		/// <see cref="TrackingRefUpdate">TrackingRefUpdate</see>
		/// for local tracking branch or srcRef
		/// can't be resolved to any object.
		/// </exception>
		/// <exception cref="System.ArgumentException">if some required parameter was null</exception>
		public RemoteRefUpdate(Repository localDb, string srcRef, string remoteName, bool
			 forceUpdate, string localName, ObjectId expectedOldObjectId)
		{
			if (remoteName == null)
			{
				throw new ArgumentException(JGitText.Get().remoteNameCantBeNull);
			}
			this.srcRef = srcRef;
			this.newObjectId = (srcRef == null ? ObjectId.ZeroId : localDb.Resolve(srcRef));
			if (newObjectId == null)
			{
				throw new IOException(MessageFormat.Format(JGitText.Get().sourceRefDoesntResolveToAnyObject
					, srcRef));
			}
			this.remoteName = remoteName;
			this.forceUpdate = forceUpdate;
			if (localName != null && localDb != null)
			{
				trackingRefUpdate = new TrackingRefUpdate(localDb, localName, remoteName, true, newObjectId
					, "push");
			}
			else
			{
				trackingRefUpdate = null;
			}
			this.localDb = localDb;
			this.expectedOldObjectId = expectedOldObjectId;
			this.status = RemoteRefUpdate.Status.NOT_ATTEMPTED;
		}
コード例 #12
0
ファイル: RemoteRefUpdate.cs プロジェクト: LunarLanding/ngit
		/// <summary>Construct remote ref update request by providing an update specification.
		/// 	</summary>
		/// <remarks>
		/// Construct remote ref update request by providing an update specification.
		/// Object is created with default
		/// <see cref="Status.NOT_ATTEMPTED">Status.NOT_ATTEMPTED</see>
		/// status and no
		/// message.
		/// </remarks>
		/// <param name="localDb">local repository to push from.</param>
		/// <param name="srcRef">
		/// source revision to label srcId with. If null srcId.name() will
		/// be used instead.
		/// </param>
		/// <param name="srcId">
		/// The new object that the caller wants remote ref to be after
		/// update. Use null or
		/// <see cref="NGit.ObjectId.ZeroId()">NGit.ObjectId.ZeroId()</see>
		/// for delete
		/// request.
		/// </param>
		/// <param name="remoteName">
		/// full name of a remote ref to update, e.g. "refs/heads/master"
		/// (no wildcard, no short name).
		/// </param>
		/// <param name="forceUpdate">
		/// true when caller want remote ref to be updated regardless
		/// whether it is fast-forward update (old object is ancestor of
		/// new object).
		/// </param>
		/// <param name="localName">
		/// optional full name of a local stored tracking branch, to
		/// update after push, e.g. "refs/remotes/zawir/dirty" (no
		/// wildcard, no short name); null if no local tracking branch
		/// should be updated.
		/// </param>
		/// <param name="expectedOldObjectId">
		/// optional object id that caller is expecting, requiring to be
		/// advertised by remote side before update; update will take
		/// place ONLY if remote side advertise exactly this expected id;
		/// null if caller doesn't care what object id remote side
		/// advertise. Use
		/// <see cref="NGit.ObjectId.ZeroId()">NGit.ObjectId.ZeroId()</see>
		/// when expecting no
		/// remote ref with this name.
		/// </param>
		/// <exception cref="System.IO.IOException">
		/// when I/O error occurred during creating
		/// <see cref="TrackingRefUpdate">TrackingRefUpdate</see>
		/// for local tracking branch or srcRef
		/// can't be resolved to any object.
		/// </exception>
		/// <exception cref="System.ArgumentException">if some required parameter was null</exception>
		public RemoteRefUpdate(Repository localDb, string srcRef, ObjectId srcId, string 
			remoteName, bool forceUpdate, string localName, ObjectId expectedOldObjectId)
		{
			if (remoteName == null)
			{
				throw new ArgumentException(JGitText.Get().remoteNameCantBeNull);
			}
			if (srcId == null && srcRef != null)
			{
				throw new IOException(MessageFormat.Format(JGitText.Get().sourceRefDoesntResolveToAnyObject
					, srcRef));
			}
			if (srcRef != null)
			{
				this.srcRef = srcRef;
			}
			else
			{
				if (srcId != null && !srcId.Equals(ObjectId.ZeroId))
				{
					this.srcRef = srcId.Name;
				}
				else
				{
					this.srcRef = null;
				}
			}
			if (srcId != null)
			{
				this.newObjectId = srcId;
			}
			else
			{
				this.newObjectId = ObjectId.ZeroId;
			}
			this.remoteName = remoteName;
			this.forceUpdate = forceUpdate;
			if (localName != null && localDb != null)
			{
				localUpdate = localDb.UpdateRef(localName);
				localUpdate.SetForceUpdate(true);
				localUpdate.SetRefLogMessage("push", true);
				localUpdate.SetNewObjectId(newObjectId);
				trackingRefUpdate = new TrackingRefUpdate(true, remoteName, localName, localUpdate
					.GetOldObjectId() != null ? localUpdate.GetOldObjectId() : ObjectId.ZeroId, newObjectId
					);
			}
			else
			{
				trackingRefUpdate = null;
			}
			this.localDb = localDb;
			this.expectedOldObjectId = expectedOldObjectId;
			this.status = RemoteRefUpdate.Status.NOT_ATTEMPTED;
		}