findRemoteRefUpdatesFor() public method

public findRemoteRefUpdatesFor ( List specs ) : ICollection
specs List
return ICollection
Beispiel #1
0
        public void testFindRemoteRefUpdatesTwoRefSpecs()
        {
            transport = GitSharp.Core.Transport.Transport.Open(db, remoteConfig);
            RefSpec        specA = new RefSpec("+refs/heads/a:refs/heads/b");
            RefSpec        specC = new RefSpec("+refs/heads/c:refs/heads/d");
            List <RefSpec> specs = new List <RefSpec> {
                specA, specC
            };
            ICollection <RemoteRefUpdate> result = transport.findRemoteRefUpdatesFor(specs);

            Assert.AreEqual(2, result.Count);
            bool foundA = false;
            bool foundC = false;

            foreach (RemoteRefUpdate rru in result)
            {
                if ("refs/heads/a".Equals(rru.SourceRef) && "refs/heads/b".Equals(rru.RemoteName))
                {
                    foundA = true;
                }
                if ("refs/heads/c".Equals(rru.SourceRef) && "refs/heads/d".Equals(rru.RemoteName))
                {
                    foundC = true;
                }
            }
            Assert.IsTrue(foundA);
            Assert.IsTrue(foundC);
        }
Beispiel #2
0
        public void testFindRemoteRefUpdatesWildcardNoTracking()
        {
            transport = GitSharp.Core.Transport.Transport.Open(db, remoteConfig);
            ICollection <RemoteRefUpdate> result =
                transport.findRemoteRefUpdatesFor(new List <RefSpec> {
                new RefSpec("+refs/heads/*:refs/heads/test/*")
            });

            Assert.AreEqual(12, result.Count);
            bool foundA = false;
            bool foundB = false;

            foreach (RemoteRefUpdate rru in result)
            {
                if ("refs/heads/a".Equals(rru.SourceRef) && "refs/heads/test/a".Equals(rru.RemoteName))
                {
                    foundA = true;
                }
                if ("refs/heads/b".Equals(rru.SourceRef) && "refs/heads/test/b".Equals(rru.RemoteName))
                {
                    foundB = true;
                }
            }
            Assert.IsTrue(foundA);
            Assert.IsTrue(foundB);
        }
Beispiel #3
0
        public void testFindRemoteRefUpdatesNoWildcardNoTracking()
        {
            transport = GitSharp.Core.Transport.Transport.open(db, remoteConfig);
            ICollection<RemoteRefUpdate> result =
                transport.findRemoteRefUpdatesFor(new List<RefSpec> {new RefSpec("refs/heads/master:refs/heads/x")});

            Assert.AreEqual(1, result.Count);
            RemoteRefUpdate rru = result.ToArray()[0];
            Assert.AreEqual(null, rru.ExpectedOldObjectId);
            Assert.IsFalse(rru.ForceUpdate);
            Assert.AreEqual("refs/heads/master", rru.SourceRef);
            Assert.AreEqual(db.Resolve("refs/heads/master"), rru.NewObjectId);
            Assert.AreEqual("refs/heads/x", rru.RemoteName);
        }
Beispiel #4
0
        public void testFindRemoteRefUpdatesNoWildcardNoDestination()
        {
            transport = GitSharp.Core.Transport.Transport.Open(db, remoteConfig);
            ICollection <RemoteRefUpdate> result =
                transport.findRemoteRefUpdatesFor(new List <RefSpec> {
                new RefSpec("+refs/heads/master")
            });

            Assert.AreEqual(1, result.Count);
            RemoteRefUpdate rru = result.ToArray()[0];

            Assert.AreEqual(null, rru.ExpectedOldObjectId);
            Assert.IsTrue(rru.ForceUpdate);
            Assert.AreEqual("refs/heads/master", rru.SourceRef);
            Assert.AreEqual(db.Resolve("refs/heads/master"), rru.NewObjectId);
            Assert.AreEqual("refs/heads/master", rru.RemoteName);
        }
Beispiel #5
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);
        }
Beispiel #6
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);
        }
Beispiel #7
0
        public void testFindRemoteRefUpdatesTwoRefSpecs()
        {
            transport = GitSharp.Core.Transport.Transport.open(db, remoteConfig);
            RefSpec specA = new RefSpec("+refs/heads/a:refs/heads/b");
            RefSpec specC = new RefSpec("+refs/heads/c:refs/heads/d");
            List<RefSpec> specs = new List<RefSpec>{specA, specC};
            ICollection<RemoteRefUpdate> result = transport.findRemoteRefUpdatesFor(specs);

            Assert.AreEqual(2, result.Count);
            bool foundA = false;
            bool foundC = false;
            foreach (RemoteRefUpdate rru in result)
            {
                if ("refs/heads/a".Equals(rru.SourceRef) && "refs/heads/b".Equals(rru.RemoteName))
                    foundA = true;
                if ("refs/heads/c".Equals(rru.SourceRef) && "refs/heads/d".Equals(rru.RemoteName))
                    foundC = true;
            }
            Assert.IsTrue(foundA);
            Assert.IsTrue(foundC);
        }
Beispiel #8
0
        public void testFindRemoteRefUpdatesWildcardNoTracking()
        {
            transport = GitSharp.Core.Transport.Transport.open(db, remoteConfig);
            ICollection<RemoteRefUpdate> result =
                transport.findRemoteRefUpdatesFor(new List<RefSpec> { new RefSpec("+refs/heads/*:refs/heads/test/*") });

            Assert.AreEqual(12, result.Count);
            bool foundA = false;
            bool foundB = false;
            foreach (RemoteRefUpdate rru in result)
            {
                if ("refs/heads/a".Equals(rru.SourceRef) && "refs/heads/test/a".Equals(rru.RemoteName))
                {
                	foundA = true;
                }
                if ("refs/heads/b".Equals(rru.SourceRef) && "refs/heads/test/b".Equals(rru.RemoteName))
                {
                	foundB = true;
                }
            }
            Assert.IsTrue(foundA);
            Assert.IsTrue(foundB);
        }