Beispiel #1
0
        public static ICollection <RemoteRefUpdate> findRemoteRefUpdatesFor(Repository db, List <RefSpec> specs, List <RefSpec> fetchSpecs)
        {
            if (fetchSpecs == null)
            {
                fetchSpecs = new List <RefSpec>();
            }

            ICollection <RemoteRefUpdate> result   = new List <RemoteRefUpdate>();
            ICollection <RefSpec>         procRefs = ExpandPushWildcardsFor(db, specs);

            foreach (RefSpec spec in procRefs)
            {
                string srcSpec = spec.Source;
                Ref    srcRef  = db.getRef(srcSpec);
                if (srcRef != null)
                {
                    srcSpec = srcRef.Name;
                }

                string destSpec = spec.Destination ?? srcSpec;

                if (srcRef != null && !destSpec.StartsWith(Constants.R_REFS))
                {
                    string n       = srcRef.Name;
                    int    kindEnd = n.IndexOf('/', Constants.R_REFS.Length);
                    destSpec = n.Slice(0, kindEnd + 1) + destSpec;
                }

                bool   forceUpdate = spec.Force;
                string localName   = FindTrackingRefName(destSpec, fetchSpecs);
                var    rru         = new RemoteRefUpdate(db, srcSpec, destSpec, forceUpdate, localName, null);
                result.Add(rru);
            }
            return(result);
        }
Beispiel #2
0
 private void UpdateCommand(RemoteRefUpdate u)
 {
     try
     {
         _dest.writeRef(u.RemoteName, u.NewObjectId);
         _newRefs.put(u.RemoteName, new Unpeeled(Storage.Loose, u.RemoteName, u.NewObjectId));
         u.Status = RemoteRefUpdate.UpdateStatus.OK;
     }
     catch (IOException e)
     {
         u.Status  = RemoteRefUpdate.UpdateStatus.REJECTED_OTHER_REASON;
         u.Message = e.Message;
     }
 }
Beispiel #3
0
 public void testPushResult()
 {
     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();
     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"));
 }
Beispiel #4
0
        private void DeleteCommand(RemoteRefUpdate u)
        {
            Ref r = null;

            foreach (string n in _newRefs.Keys)
            {
                if (n == u.RemoteName)
                {
                    r = _newRefs[n];
                    _newRefs.Remove(n);
                }
            }

            if (r == null)
            {
                u.Status = RemoteRefUpdate.UpdateStatus.OK;
                return;
            }

            if (r.StorageFormat.IsPacked)
            {
                _packedRefUpdates.Add(u);
            }

            if (r.StorageFormat.IsLoose)
            {
                try
                {
                    _dest.deleteRef(u.RemoteName);
                    u.Status = RemoteRefUpdate.UpdateStatus.OK;
                }
                catch (IOException e)
                {
                    u.Status  = RemoteRefUpdate.UpdateStatus.REJECTED_OTHER_REASON;
                    u.Message = e.Message;
                }
            }

            try
            {
                _dest.deleteRefLog(u.RemoteName);
            }
            catch (IOException e)
            {
                u.Status  = RemoteRefUpdate.UpdateStatus.REJECTED_OTHER_REASON;
                u.Message = e.Message;
            }
        }
Beispiel #5
0
        /// <summary>
        /// Convert push remote refs update specification from <see cref="RefSpec"/> form
        /// to <see cref="RemoteRefUpdate"/>. Conversion expands wildcards by matching
        /// source part to local refs. expectedOldObjectId in RemoteRefUpdate is
        /// always set as null. Tracking branch is configured if RefSpec destination
        /// matches source of any fetch ref spec for this transport remote
        /// configuration.
        /// </summary>
        /// <param name="db">local database.</param>
        /// <param name="specs">collection of RefSpec to convert.</param>
        /// <param name="fetchSpecs">
        /// fetch specifications used for finding localtracking refs. May
        /// be null or empty collection.
        /// </param>
        /// <returns>collection of set up <see cref="RemoteRefUpdate"/>.</returns>
        public static ICollection <RemoteRefUpdate> findRemoteRefUpdatesFor(Repository db, List <RefSpec> specs, List <RefSpec> fetchSpecs)
        {
            if (fetchSpecs == null)
            {
                fetchSpecs = new List <RefSpec>();
            }

            ICollection <RemoteRefUpdate> result   = new List <RemoteRefUpdate>();
            ICollection <RefSpec>         procRefs = ExpandPushWildcardsFor(db, specs);

            foreach (RefSpec spec in procRefs)
            {
                string srcSpec = spec.Source;
                Ref    srcRef  = db.getRef(srcSpec);
                if (srcRef != null)
                {
                    srcSpec = srcRef.Name;
                }

                String destSpec = spec.Destination;
                if (destSpec == null)
                {
                    // No destination (no-colon in ref-spec), DWIMery assumes src
                    //
                    destSpec = srcSpec;
                }

                if (srcRef != null && !destSpec.StartsWith(Constants.R_REFS))
                {
                    // Assume the same kind of ref at the destination, e.g.
                    // "refs/heads/foo:master", DWIMery assumes master is also
                    // under "refs/heads/".
                    //
                    string n       = srcRef.Name;
                    int    kindEnd = n.IndexOf('/', Constants.R_REFS.Length);
                    destSpec = n.Slice(0, kindEnd + 1) + destSpec;
                }

                bool   forceUpdate = spec.Force;
                string localName   = FindTrackingRefName(destSpec, fetchSpecs);
                var    rru         = new RemoteRefUpdate(db, srcSpec, destSpec, forceUpdate, localName, null);
                result.Add(rru);
            }
            return(result);
        }
Beispiel #6
0
        private void DeleteCommand(RemoteRefUpdate u)
        {
            Ref r = _newRefs.remove(u.RemoteName);

            if (r == null)
            {
                // Already gone.
                //
                u.Status = RemoteRefUpdate.UpdateStatus.OK;
                return;
            }

            if (r.StorageFormat.IsPacked)
            {
                _packedRefUpdates.Add(u);
            }

            if (r.StorageFormat.IsLoose)
            {
                try
                {
                    _dest.deleteRef(u.RemoteName);
                    u.Status = RemoteRefUpdate.UpdateStatus.OK;
                }
                catch (IOException e)
                {
                    u.Status  = RemoteRefUpdate.UpdateStatus.REJECTED_OTHER_REASON;
                    u.Message = e.Message;
                }
            }

            try
            {
                _dest.deleteRefLog(u.RemoteName);
            }
            catch (IOException e)
            {
                u.Status  = RemoteRefUpdate.UpdateStatus.REJECTED_OTHER_REASON;
                u.Message = e.Message;
            }
        }
Beispiel #7
0
        public static ICollection<RemoteRefUpdate> findRemoteRefUpdatesFor(Repository db, List<RefSpec> specs, List<RefSpec> fetchSpecs)
        {
            if (fetchSpecs == null)
            {
                fetchSpecs = new List<RefSpec>();
            }

            ICollection<RemoteRefUpdate> result = new List<RemoteRefUpdate>();
            ICollection<RefSpec> procRefs = ExpandPushWildcardsFor(db, specs);

            foreach (RefSpec spec in procRefs)
            {
                string srcSpec = spec.Source;
                Ref srcRef = db.getRef(srcSpec);
                if (srcRef != null)
                {
                    srcSpec = srcRef.Name;
                }

                string destSpec = spec.Destination ?? srcSpec;

                if (srcRef != null && !destSpec.StartsWith(Constants.R_REFS))
                {
                    string n = srcRef.Name;
                    int kindEnd = n.IndexOf('/', Constants.R_REFS.Length);
                    destSpec = n.Slice(0, kindEnd + 1) + destSpec;
                }

                bool forceUpdate = spec.Force;
                string localName = FindTrackingRefName(destSpec, fetchSpecs);
                var rru = new RemoteRefUpdate(db, srcSpec, destSpec, forceUpdate, localName, null);
                result.Add(rru);
            }
            return result;
        }
        private void DeleteCommand(RemoteRefUpdate u)
        {
            Ref r = _newRefs.remove(u.RemoteName);

            if (r == null)
            {
                // Already gone.
                //
                u.Status = RemoteRefUpdate.UpdateStatus.OK;
                return;
            }

            if (r.StorageFormat.IsPacked)
            {
                _packedRefUpdates.Add(u);
            }

            if (r.StorageFormat.IsLoose)
            {
                try
                {
                    _dest.deleteRef(u.RemoteName);
                    u.Status = RemoteRefUpdate.UpdateStatus.OK;
                }
                catch (IOException e)
                {
                    u.Status = RemoteRefUpdate.UpdateStatus.REJECTED_OTHER_REASON;
                    u.Message = e.Message;
                }
            }

            try
            {
                _dest.deleteRefLog(u.RemoteName);
            }
            catch (IOException e)
            {
                u.Status = RemoteRefUpdate.UpdateStatus.REJECTED_OTHER_REASON;
                u.Message = e.Message;
            }
        }
Beispiel #9
0
 public RemoteRefUpdate(RemoteRefUpdate baseUpdate, ObjectId newExpectedOldObjectId)
     : this(baseUpdate._localDb, baseUpdate.SourceRef, baseUpdate.RemoteName, baseUpdate.ForceUpdate, (baseUpdate.TrackingRefUpdate == null ? null : baseUpdate.TrackingRefUpdate.LocalName), newExpectedOldObjectId)
 {
 }
Beispiel #10
0
 public void testTrackingRefUpdateDisabled()
 {
     RemoteRefUpdate rru = new RemoteRefUpdate(db, "2c349335b7f797072cf729c4f3bb0914ecb6dec9", "refs/heads/master", false, null, null);
     Core.Ref @ref = new Unpeeled(Storage.Loose, "refs/heads/master", ObjectId.FromString("ac7e7e44c1885efb472ad54a78327d66bfc4ecef"));
     refUpdates.Add(rru);
     advertisedRefs.Add(@ref);
     PushResult result = executePush();
     Assert.IsTrue(result.TrackingRefUpdates.Count == 0);
 }
Beispiel #11
0
 public void testUpdateMixedCases()
 {
     RemoteRefUpdate rruOk = new RemoteRefUpdate(db, null, "refs/heads/master", false, null, null);
     Core.Ref refToChange = new Unpeeled(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);
 }
Beispiel #12
0
 public void testUpdateNonFastForward()
 {
     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"));
     testOneUpdateStatus(rru, @ref, RemoteRefUpdate.UpdateStatus.REJECTED_NONFASTFORWARD, null);
 }
Beispiel #13
0
 public void testUpdateExpectedRemote()
 {
     RemoteRefUpdate rru = new RemoteRefUpdate(db, "2c349335b7f797072cf729c4f3bb0914ecb6dec9",
                                               "refs/heads/master", false, null,
                                               ObjectId.FromString("ac7e7e44c1885efb472ad54a78327d66bfc4ecef"));
     Core.Ref @ref = new Core.Ref(Core.Ref.Storage.Loose, "refs/heads/master", ObjectId.FromString("ac7e7e44c1885efb472ad54a78327d66bfc4ecef"));
     testOneUpdateStatus(rru, @ref, RemoteRefUpdate.UpdateStatus.OK, true);
 }
Beispiel #14
0
 public void testUpdateDelete()
 {
     RemoteRefUpdate rru = new RemoteRefUpdate(db, null, "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.OK, true);
 }
Beispiel #15
0
        /// <summary>
        /// Convert push remote refs update specification from <see cref="RefSpec"/> form
        /// to <see cref="RemoteRefUpdate"/>. Conversion expands wildcards by matching
        /// source part to local refs. expectedOldObjectId in RemoteRefUpdate is
        /// always set as null. Tracking branch is configured if RefSpec destination
        /// matches source of any fetch ref spec for this transport remote
        /// configuration.
        /// </summary>
        /// <param name="db">local database.</param>
        /// <param name="specs">collection of RefSpec to convert.</param>
        /// <param name="fetchSpecs">
        /// fetch specifications used for finding localtracking refs. May
        /// be null or empty collection.
        /// </param>
        /// <returns>collection of set up <see cref="RemoteRefUpdate"/>.</returns>
        public static ICollection<RemoteRefUpdate> findRemoteRefUpdatesFor(Repository db, List<RefSpec> specs, List<RefSpec> fetchSpecs)
        {
            if (fetchSpecs == null)
            {
                fetchSpecs = new List<RefSpec>();
            }

            ICollection<RemoteRefUpdate> result = new List<RemoteRefUpdate>();
            ICollection<RefSpec> procRefs = ExpandPushWildcardsFor(db, specs);

            foreach (RefSpec spec in procRefs)
            {
                string srcSpec = spec.Source;
                Ref srcRef = db.getRef(srcSpec);
                if (srcRef != null)
                {
                    srcSpec = srcRef.Name;
                }

                String destSpec = spec.Destination;
                if (destSpec == null)
                {
                    // No destination (no-colon in ref-spec), DWIMery assumes src
                    //
                    destSpec = srcSpec;
                }

                if (srcRef != null && !destSpec.StartsWith(Constants.R_REFS))
                {
                    // Assume the same kind of ref at the destination, e.g.
                    // "refs/heads/foo:master", DWIMery assumes master is also
                    // under "refs/heads/".
                    //
                    string n = srcRef.Name;
                    int kindEnd = n.IndexOf('/', Constants.R_REFS.Length);
                    destSpec = n.Slice(0, kindEnd + 1) + destSpec;
                }

                bool forceUpdate = spec.Force;
                string localName = FindTrackingRefName(destSpec, fetchSpecs);
                var rru = new RemoteRefUpdate(db, srcSpec, destSpec, forceUpdate, localName, null);
                result.Add(rru);
            }
            return result;
        }
Beispiel #16
0
 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 Unpeeled(Storage.Loose, "refs/heads/master", ObjectId.FromString("ac7e7e44c1885efb472ad54a78327d66bfc4ecef"));
     testOneUpdateStatus(rru, @ref, RemoteRefUpdate.UpdateStatus.REJECTED_OTHER_REASON, null);
 }
Beispiel #17
0
        private void readStatusReport(IDictionary <string, RemoteRefUpdate> refUpdates)
        {
            string unpackLine = readStringLongTimeout();

            if (!unpackLine.StartsWith("unpack "))
            {
                throw new PackProtocolException(uri, "unexpected report line: " + unpackLine);
            }
            string unpackStatus = unpackLine.Substring("unpack ".Length);

            if (!unpackStatus.Equals("ok"))
            {
                throw new TransportException(uri, "error occoured during unpacking on the remote end: " + unpackStatus);
            }

            String refLine;

            while ((refLine = pckIn.ReadString()) != PacketLineIn.END)
            {
                bool ok         = false;
                int  refNameEnd = -1;
                if (refLine.StartsWith("ok "))
                {
                    ok         = true;
                    refNameEnd = refLine.Length;
                }
                else if (refLine.StartsWith("ng "))
                {
                    refNameEnd = refLine.IndexOf(' ', 3);
                }
                if (refNameEnd == -1)
                {
                    throw new PackProtocolException(uri + ": unexpected report line: " + refLine);
                }
                string          refName = refLine.Slice(3, refNameEnd);
                string          message = (ok ? null : refLine.Substring(refNameEnd + 1));
                RemoteRefUpdate rru     = refUpdates.get(refName);
                if (rru == null)
                {
                    throw new PackProtocolException(uri
                                                    + ": unexpected ref report: " + refName);
                }
                if (ok)
                {
                    rru.Status = RemoteRefUpdate.UpdateStatus.OK;
                }
                else
                {
                    rru.Status  = RemoteRefUpdate.UpdateStatus.REJECTED_OTHER_REASON;
                    rru.Message = message;
                }
            }

            foreach (RemoteRefUpdate rru in refUpdates.Values)
            {
                if (rru.Status == RemoteRefUpdate.UpdateStatus.AWAITING_REPORT)
                {
                    throw new PackProtocolException(uri + ": expected report for ref " + rru.RemoteName +
                                                    " not received");
                }
            }
        }
Beispiel #18
0
 public void testTrackingRefUpdateEnabled()
 {
     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();
     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);
 }
Beispiel #19
0
 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;
 }
Beispiel #20
0
 public void testTrackingRefUpdateOnReject()
 {
     RemoteRefUpdate rru = new RemoteRefUpdate(db, "ac7e7e44c1885efb472ad54a78327d66bfc4ecef", "refs/heads/master", false, null, null);
     Core.Ref @ref = new Unpeeled(Storage.Loose, "refs/heads/master", ObjectId.FromString("2c349335b7f797072cf729c4f3bb0914ecb6dec9"));
     PushResult result = testOneUpdateStatus(rru, @ref, RemoteRefUpdate.UpdateStatus.REJECTED_NONFASTFORWARD, null);
     Assert.IsTrue(result.TrackingRefUpdates.Count == 0);
 }
Beispiel #21
0
 public void testUpdateNonFastForwardUnknownObject()
 {
     RemoteRefUpdate rru = new RemoteRefUpdate(db, "2c349335b7f797072cf729c4f3bb0914ecb6dec9",
                                               "refs/heads/master", false, null, null);
     Core.Ref @ref = new Unpeeled(Storage.Loose, "refs/heads/master", ObjectId.FromString("0000000000000000000000000000000000000001"));
     testOneUpdateStatus(rru, @ref, RemoteRefUpdate.UpdateStatus.REJECTED_NONFASTFORWARD, null);
 }
Beispiel #22
0
        private void DeleteCommand(RemoteRefUpdate u)
        {
            Ref r = null;
            foreach (string n in _newRefs.Keys)
            {
                if (n == u.RemoteName)
                {
                    r = _newRefs[n];
                    _newRefs.Remove(n);
                }
            }

            if (r == null)
            {
                u.Status = RemoteRefUpdate.UpdateStatus.OK;
                return;
            }

            if (r.StorageFormat.IsPacked)
            {
                _packedRefUpdates.Add(u);
            }

            if (r.StorageFormat.IsLoose)
            {
                try
                {
                    _dest.deleteRef(u.RemoteName);
                    u.Status = RemoteRefUpdate.UpdateStatus.OK;
                }
                catch (IOException e)
                {
                    u.Status = RemoteRefUpdate.UpdateStatus.REJECTED_OTHER_REASON;
                    u.Message = e.Message;
                }
            }

            try
            {
                _dest.deleteRefLog(u.RemoteName);
            }
            catch (IOException e)
            {
                u.Status = RemoteRefUpdate.UpdateStatus.REJECTED_OTHER_REASON;
                u.Message = e.Message;
            }
        }
Beispiel #23
0
 public void testUpdateNonFastForwardForced()
 {
     RemoteRefUpdate rru = new RemoteRefUpdate(db, "ac7e7e44c1885efb472ad54a78327d66bfc4ecef",
                                   "refs/heads/master", true, null, null);
     Core.Ref @ref = new Unpeeled(Storage.Loose, "refs/heads/master", ObjectId.FromString("2c349335b7f797072cf729c4f3bb0914ecb6dec9"));
     testOneUpdateStatus(rru, @ref, RemoteRefUpdate.UpdateStatus.OK, false);
 }
Beispiel #24
0
 /// <summary>
 /// Create a new instance of this object basing on existing instance for
 /// configuration. State (like <see cref="get_Message"/>, <see cref="get_Status"/>)
 /// of base object is not shared. Expected old object id is set up from
 /// scratch, as this constructor may be used for 2-stage push: first one
 /// being dry run, second one being actual push.
 /// </summary>
 /// <param name="baseUpdate">configuration base.</param>
 /// <param name="newExpectedOldObjectId">new expected object id value.</param>
 public RemoteRefUpdate(RemoteRefUpdate baseUpdate, ObjectId newExpectedOldObjectId)
     : this(baseUpdate._localDb, baseUpdate.SourceRef, baseUpdate.RemoteName, baseUpdate.ForceUpdate, (baseUpdate.TrackingRefUpdate == null ? null : baseUpdate.TrackingRefUpdate.LocalName), newExpectedOldObjectId)
 {
 }
Beispiel #25
0
 public void testUpdateCreateRef()
 {
     RemoteRefUpdate rru = new RemoteRefUpdate(db, "ac7e7e44c1885efb472ad54a78327d66bfc4ecef",
                       "refs/heads/master", false, null, null);
     testOneUpdateStatus(rru, null, RemoteRefUpdate.UpdateStatus.OK, true);
 }
Beispiel #26
0
 private void UpdateCommand(RemoteRefUpdate u)
 {
     try
     {
         _dest.writeRef(u.RemoteName, u.NewObjectId);
         _newRefs.put(u.RemoteName, new Unpeeled(Storage.Loose, u.RemoteName, u.NewObjectId));
         u.Status = RemoteRefUpdate.UpdateStatus.OK;
     }
     catch (IOException e)
     {
         u.Status = RemoteRefUpdate.UpdateStatus.REJECTED_OTHER_REASON;
         u.Message = e.Message;
     }
 }
Beispiel #27
0
 public void testUpdateDeleteNonExisting()
 {
     RemoteRefUpdate rru = new RemoteRefUpdate(db, null, "refs/heads/master", false, null, null);
     testOneUpdateStatus(rru, null, RemoteRefUpdate.UpdateStatus.NON_EXISTING, null);
 }
Beispiel #28
0
 public void testUpdateUpToDate()
 {
     RemoteRefUpdate rru = new RemoteRefUpdate(db, "2c349335b7f797072cf729c4f3bb0914ecb6dec9", "refs/heads/master", false, null, null);
     Core.Ref @ref = new Unpeeled(Storage.Loose, "refs/heads/master", ObjectId.FromString("2c349335b7f797072cf729c4f3bb0914ecb6dec9"));
     testOneUpdateStatus(rru, @ref, RemoteRefUpdate.UpdateStatus.UP_TO_DATE, null);
 }
Beispiel #29
0
 public void testUpdateUnexpectedRemoteVsForce()
 {
     RemoteRefUpdate rru = new RemoteRefUpdate(db, "2c349335b7f797072cf729c4f3bb0914ecb6dec9",
                                   "refs/heads/master", true, null,
                                   ObjectId.FromString("0000000000000000000000000000000000000001"));
     Core.Ref @ref = new Unpeeled(Storage.Loose, "refs/heads/master", ObjectId.FromString("ac7e7e44c1885efb472ad54a78327d66bfc4ecef"));
     testOneUpdateStatus(rru, @ref, RemoteRefUpdate.UpdateStatus.REJECTED_REMOTE_CHANGED, null);
 }
Beispiel #30
0
        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;
            }
        }
Beispiel #31
0
 public RemoteRefUpdate(RemoteRefUpdate baseUpdate, ObjectId newExpectedOldObjectId)
     : this(baseUpdate._localDb, baseUpdate.SourceRef, baseUpdate.RemoteName, baseUpdate.ForceUpdate, (baseUpdate.TrackingRefUpdate == null ? null : baseUpdate.TrackingRefUpdate.LocalName), newExpectedOldObjectId)
 {
     if (baseUpdate == null)
         throw new ArgumentNullException ("baseUpdate");
 }