Exemplo n.º 1
0
        private string longTypeOf(TrackingRefUpdate u)
        {
            RefUpdate.RefUpdateResult r = u.Result;
            if (r == RefUpdate.RefUpdateResult.LockFailure)
            {
                return("[lock fail]");
            }
            if (r == RefUpdate.RefUpdateResult.IOFailure)
            {
                return("[i/o error]");
            }
            if (r == RefUpdate.RefUpdateResult.Rejected)
            {
                return("[rejected]");
            }
            if (ObjectId.ZeroId.Equals(u.NewObjectId))
            {
                return("[deleted]");
            }

            if (r == RefUpdate.RefUpdateResult.New)
            {
                if (u.RemoteName.StartsWith(Constants.R_HEADS))
                {
                    return("[new branch]");
                }
                if (u.LocalName.StartsWith(Constants.R_TAGS))
                {
                    return("[new tag]");
                }
                return("[new]");
            }

            if (r == RefUpdate.RefUpdateResult.Forced)
            {
                string aOld = u.OldObjectId.Abbreviate(Repository._internal_repo).name();
                string aNew = u.NewObjectId.Abbreviate(Repository._internal_repo).name();
                return(aOld + "..." + aNew);
            }

            if (r == RefUpdate.RefUpdateResult.FastForward)
            {
                string aOld = u.OldObjectId.Abbreviate(Repository._internal_repo).name();
                string aNew = u.NewObjectId.Abbreviate(Repository._internal_repo).name();
                return(aOld + ".." + aNew);
            }

            if (r == RefUpdate.RefUpdateResult.NoChange)
            {
                return("[up to date]");
            }

            return("[" + r + "]");
        }
        private string longTypeOf(TrackingRefUpdate u)
        {
            RefUpdate.RefUpdateResult r = u.Result;
            if (r == RefUpdate.RefUpdateResult.LOCK_FAILURE)
            {
                return("[lock fail]");
            }
            if (r == RefUpdate.RefUpdateResult.IO_FAILURE)
            {
                return("[i/o error]");
            }
            if (r == RefUpdate.RefUpdateResult.REJECTED)
            {
                return("[rejected]");
            }
            if (ObjectId.ZeroId.Equals(u.NewObjectId))
            {
                return("[deleted]");
            }

            if (r == RefUpdate.RefUpdateResult.NEW)
            {
                if (u.RemoteName.StartsWith(Constants.R_HEADS))
                {
                    return("[new branch]");
                }
                if (u.LocalName.StartsWith(Constants.R_TAGS))
                {
                    return("[new tag]");
                }
                return("[new]");
            }

            if (r == RefUpdate.RefUpdateResult.FORCED)
            {
                string aOld = u.OldObjectId.Abbreviate(Repository).name();
                string aNew = u.NewObjectId.Abbreviate(Repository).name();
                return(aOld + "..." + aNew);
            }

            if (r == RefUpdate.RefUpdateResult.FAST_FORWARD)
            {
                string aOld = u.OldObjectId.Abbreviate(Repository).name();
                string aNew = u.NewObjectId.Abbreviate(Repository).name();
                return(aOld + ".." + aNew);
            }

            if (r == RefUpdate.RefUpdateResult.NO_CHANGE)
            {
                return("[up to date]");
            }

            return("[" + r + "]");
        }
Exemplo n.º 3
0
        public void testTrackingRefUpdateEnabled()
        {
            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();
            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);
        }
Exemplo n.º 4
0
        public void testFindRemoteRefUpdatesTrackingRef()
        {
            remoteConfig.AddFetchRefSpec(new RefSpec("refs/heads/*:refs/remotes/test/*"));
            transport = GitSharp.Core.Transport.Transport.Open(db, remoteConfig);
            ICollection <RemoteRefUpdate> result =
                transport.findRemoteRefUpdatesFor(new List <RefSpec> {
                new RefSpec("+refs/heads/a:refs/heads/a")
            });

            Assert.AreEqual(1, result.Count);
            TrackingRefUpdate tru = result.ToArray()[0].TrackingRefUpdate;

            Assert.AreEqual("refs/remotes/test/a", tru.LocalName);
            Assert.AreEqual("refs/heads/a", tru.RemoteName);
            Assert.AreEqual(db.Resolve("refs/heads/a"), tru.NewObjectId);
            Assert.AreEqual(null, tru.OldObjectId);
        }
Exemplo n.º 5
0
        public virtual void TestTrackingUpdate()
        {
            Repository db2             = CreateBareRepository();
            string     remote          = "origin";
            string     branch          = "refs/heads/master";
            string     trackingBranch  = "refs/remotes/" + remote + "/master";
            Git        git             = new Git(db);
            RevCommit  commit1         = git.Commit().SetMessage("Initial commit").Call();
            RefUpdate  branchRefUpdate = db.UpdateRef(branch);

            branchRefUpdate.SetNewObjectId(commit1.Id);
            branchRefUpdate.Update();
            RefUpdate trackingBranchRefUpdate = db.UpdateRef(trackingBranch);

            trackingBranchRefUpdate.SetNewObjectId(commit1.Id);
            trackingBranchRefUpdate.Update();
            StoredConfig config       = ((FileBasedConfig)db.GetConfig());
            RemoteConfig remoteConfig = new RemoteConfig(config, remote);
            URIish       uri          = new URIish(db2.Directory.ToURI().ToURL());

            remoteConfig.AddURI(uri);
            remoteConfig.AddFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/" + remote +
                                                     "/*"));
            remoteConfig.Update(config);
            config.Save();
            RevCommit             commit2        = git.Commit().SetMessage("Commit to push").Call();
            RefSpec               spec           = new RefSpec(branch + ":" + branch);
            Iterable <PushResult> resultIterable = git.Push().SetRemote(remote).SetRefSpecs(spec
                                                                                            ).Call();
            PushResult        result            = resultIterable.Iterator().Next();
            TrackingRefUpdate trackingRefUpdate = result.GetTrackingRefUpdate(trackingBranch);

            NUnit.Framework.Assert.IsNotNull(trackingRefUpdate);
            NUnit.Framework.Assert.AreEqual(trackingBranch, trackingRefUpdate.GetLocalName());
            NUnit.Framework.Assert.AreEqual(branch, trackingRefUpdate.GetRemoteName());
            NUnit.Framework.Assert.AreEqual(commit2.Id, trackingRefUpdate.GetNewObjectId());
            NUnit.Framework.Assert.AreEqual(commit2.Id, db.Resolve(trackingBranch));
            NUnit.Framework.Assert.AreEqual(commit2.Id, db2.Resolve(branch));
        }