コード例 #1
0
ファイル: RefSpecTests.cs プロジェクト: stschake/GitSharp
 public void testCreateEmpty()
 {
     RefSpec rs = new RefSpec();
     Assert.IsFalse(rs.Force);
     Assert.IsFalse(rs.Wildcard);
     Assert.AreEqual("HEAD", rs.Source);
     Assert.IsNull(rs.Destination);
     Assert.AreEqual("HEAD", rs.ToString());
 }
コード例 #2
0
ファイル: FetchProcess.cs プロジェクト: kkl713/GitSharp
 private void expandWildcard(RefSpec spec, HashSet <Ref> matched)
 {
     foreach (Ref src in _connection.Refs)
     {
         if (spec.MatchSource(src) && matched.Add(src))
         {
             want(src, spec.ExpandFromSource((src)));
         }
     }
 }
コード例 #3
0
        public bool AddPushRefSpec(RefSpec s)
        {
            if (Push.Contains(s))
            {
                return(false);
            }

            Push.Add(s);
            return(true);
        }
コード例 #4
0
        public bool AddFetchRefSpec(RefSpec s)
        {
            if (Fetch.Contains(s))
            {
                return(false);
            }

            Fetch.Add(s);

            return(true);
        }
コード例 #5
0
ファイル: RefSpecTests.cs プロジェクト: dev218/GitSharp
 public void testSplitLastColon()
 {
     string lhs = ":m:a:i:n:t";
     string rhs = "refs/heads/maint";
     RefSpec rs = new RefSpec(lhs + ":" + rhs);
     Assert.IsFalse(rs.Force);
     Assert.IsFalse(rs.Wildcard);
     Assert.AreEqual(lhs, rs.Source);
     Assert.AreEqual(rhs, rs.Destination);
     Assert.AreEqual(lhs + ":" + rhs, rs.ToString());
     Assert.AreEqual(rs, new RefSpec(rs.ToString()));
 }
コード例 #6
0
ファイル: FetchProcess.cs プロジェクト: kkl713/GitSharp
        private void expandSingle(RefSpec spec, HashSet <Ref> matched)
        {
            Ref src = _connection.Refs.Find(x => x.Name == spec.Source);

            if (src == null)
            {
                throw new TransportException("Remote does not have " + spec.Source + " available for fetch.");
            }
            if (matched.Add(src))
            {
                want(src, spec);
            }
        }
コード例 #7
0
ファイル: RefSpec.cs プロジェクト: yhtsnda/Bonobo-Git-Server
        /// <summary>
        /// Create a new RefSpec with a different source name setting.
        /// </summary>
        /// <param name="source">new value for source in the returned instance.</param>
        /// <returns>a new RefSpec with source as specified.</returns>
        public RefSpec SetSource(string source)
        {
            var r = new RefSpec(this);

            r.Source = source;
            if (IsWildcard(r.Source) && r.Destination == null)
            {
                throw new InvalidOperationException("Destination is not a wildcard.");
            }
            if (IsWildcard(r.Source) != IsWildcard(r.Destination))
            {
                throw new InvalidOperationException("Source/Destination must match.");
            }
            return(r);
        }
コード例 #8
0
ファイル: RefSpec.cs プロジェクト: yhtsnda/Bonobo-Git-Server
        /// <summary>
        /// Create a new RefSpec with a different destination name setting.
        /// </summary>
        /// <param name="destination">new value for destination in the returned instance.</param>
        /// <returns>a new RefSpec with destination as specified.</returns>
        public RefSpec SetDestination(string destination)
        {
            RefSpec r = new RefSpec(this);

            r.Destination = destination;

            if (IsWildcard(r.Destination) && r.Source == null)
            {
                throw new InvalidOperationException("Source is not a wildcard.");
            }
            if (IsWildcard(r.Source) != IsWildcard(r.Destination))
            {
                throw new InvalidOperationException("Source/Destination must match.");
            }
            return(r);
        }
コード例 #9
0
ファイル: FetchProcess.cs プロジェクト: kkl713/GitSharp
        private void deleteStaleTrackingRefs(FetchResult result, RevWalk.RevWalk walk)
        {
            Repository db = _transport.Local;

            foreach (Ref @ref in db.getAllRefs().Values)
            {
                string refname = @ref.Name;
                foreach (RefSpec spec in _toFetch)
                {
                    if (spec.MatchDestination(refname))
                    {
                        RefSpec s = spec.ExpandFromDestination(refname);
                        if (result.GetAdvertisedRef(s.Source) == null)
                        {
                            deleteTrackingRef(result, db, walk, s, @ref);
                        }
                    }
                }
            }
        }
コード例 #10
0
ファイル: RefSpecTests.cs プロジェクト: stschake/GitSharp
        public void testDeleteMaster()
        {
            string sn = "refs/heads/master";
            RefSpec rs = new RefSpec(":" + sn);
            Assert.IsFalse(rs.Force);
            Assert.IsFalse(rs.Wildcard);
            Assert.AreEqual(sn, rs.Destination);
            Assert.IsNull(rs.Source);
            Assert.AreEqual(":" + sn, rs.ToString());
            Assert.AreEqual(rs, new RefSpec(rs.ToString()));

            Core.Ref r = new Core.Ref(Core.Ref.Storage.Loose, sn, null);
            Assert.IsFalse(rs.MatchSource(r));
            Assert.IsTrue(rs.MatchDestination(r));
            Assert.AreSame(rs, rs.ExpandFromSource(r));

            r = new Core.Ref(Core.Ref.Storage.Loose, sn + "-and-more", null);
            Assert.IsFalse(rs.MatchSource(r));
            Assert.IsFalse(rs.MatchDestination(r));
        }
コード例 #11
0
ファイル: RefSpecTests.cs プロジェクト: stschake/GitSharp
 public void testSetForceUpdate()
 {
     string s = "refs/heads/*:refs/remotes/origin/*";
     RefSpec a = new RefSpec(s);
     Assert.IsFalse(a.Force);
     RefSpec b = a.SetForce(true);
     Assert.AreNotSame(a, b);
     Assert.IsFalse(a.Force);
     Assert.IsTrue(b.Force);
     Assert.AreEqual(s, a.ToString());
     Assert.AreEqual("+" + s, b.ToString());
 }
コード例 #12
0
ファイル: RefSpecTests.cs プロジェクト: stschake/GitSharp
        public void testForceRemotesOrigin()
        {
            string srcn = "refs/heads/*";
            string dstn = "refs/remotes/origin/*";
            RefSpec rs = new RefSpec("+" + srcn + ":" + dstn);
            Assert.IsTrue(rs.Force);
            Assert.IsTrue(rs.Wildcard);
            Assert.AreEqual(srcn, rs.Source);
            Assert.AreEqual(dstn, rs.Destination);
            Assert.AreEqual("+" + srcn + ":" + dstn, rs.ToString());
            Assert.AreEqual(rs, new RefSpec(rs.ToString()));

            Core.Ref r;
            RefSpec expanded;

            r = new Core.Ref(Core.Ref.Storage.Loose, "refs/heads/master", null);
            Assert.IsTrue(rs.MatchSource(r));
            Assert.IsFalse(rs.MatchDestination(r));
            expanded = rs.ExpandFromSource(r);
            Assert.AreNotSame(rs, expanded);
            Assert.IsTrue(expanded.Force);
            Assert.IsFalse(expanded.Wildcard);
            Assert.AreEqual(r.Name, expanded.Source);
            Assert.AreEqual("refs/remotes/origin/master", expanded.Destination);

            r = new Core.Ref(Core.Ref.Storage.Loose, "refs/remotes/origin/next", null);
            Assert.IsFalse(rs.MatchSource(r));
            Assert.IsTrue(rs.MatchDestination(r));

            r = new Core.Ref(Core.Ref.Storage.Loose, "refs/tags/v1.0", null);
            Assert.IsFalse(rs.MatchSource(r));
            Assert.IsFalse(rs.MatchDestination(r));
        }
コード例 #13
0
ファイル: RefSpecTests.cs プロジェクト: stschake/GitSharp
        public void testSetDestination_SourceNull()
        {
            RefSpec a = new RefSpec();
            RefSpec b;

            b = a.SetDestination("refs/heads/master");
            b = b.SetSource(null);
            Assert.AreNotSame(a, b);
            Assert.AreEqual("HEAD", a.ToString());
            Assert.AreEqual(":refs/heads/master", b.ToString());
        }
コード例 #14
0
ファイル: FetchProcess.cs プロジェクト: jagregory/GitSharp
        private void want(Ref src, RefSpec spec)
        {
            ObjectId newId = src.ObjectId;
            if (spec.Destination != null)
            {
                try
                {
                    TrackingRefUpdate tru = createUpdate(spec, newId);
                    if (newId.Equals(tru.OldObjectId))
                    {
                        return;
                    }
                    _localUpdates.Add(tru);
                }
                catch (System.IO.IOException err)
                {
                    // Bad symbolic ref? That is the most likely cause.
                    throw new TransportException("Cannot resolve" + " local tracking ref " + spec.Destination + " for updating.", err);
                }
            }

            _askFor.Add(newId, src);

            FetchHeadRecord fhr = new FetchHeadRecord(newId, spec.Destination != null, src.Name, _transport.Uri);
            _fetchHeadUpdates.Add(fhr);
        }
コード例 #15
0
ファイル: TransportTest.cs プロジェクト: dev218/GitSharp
        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);
        }
コード例 #16
0
ファイル: RemoteConfig.cs プロジェクト: dev218/GitSharp
        /// <summary>
        /// Add a new push RefSpec to this remote.
        /// </summary>
        /// <param name="s">the new specification to add.</param>
        /// <returns>true if the specification was added; false if it already exists.</returns>
		public bool AddPushRefSpec(RefSpec s)
		{
			if (Push.Contains(s)) return false;

			Push.Add(s);
			return true;
		}
コード例 #17
0
ファイル: FetchProcess.cs プロジェクト: kkl713/GitSharp
 private TrackingRefUpdate createUpdate(RefSpec spec, ObjectId newId)
 {
     return(new TrackingRefUpdate(_transport.Local, spec, newId, "fetch"));
 }
コード例 #18
0
ファイル: RefSpec.cs プロジェクト: dev218/GitSharp
 /// <summary>
 /// Create a new RefSpec with a different source name setting.
 /// </summary>
 /// <param name="source">new value for source in the returned instance.</param>
 /// <returns>a new RefSpec with source as specified.</returns>
 public RefSpec SetSource(string source)
 {
     var r = new RefSpec(this);
     r.Source = source;
     if (IsWildcard(r.Source) && r.Destination == null)
         throw new InvalidOperationException("Destination is not a wildcard.");
     if (IsWildcard(r.Source) != IsWildcard(r.Destination))
         throw new InvalidOperationException("Source/Destination must match.");
     return r;
 }
コード例 #19
0
ファイル: RemoteConfig.cs プロジェクト: dev218/GitSharp
        /// <summary>
        /// Add a new fetch RefSpec to this remote.
        /// </summary>
        /// <param name="s">the new specification to add.</param>
        /// <returns>true if the specification was added; false if it already exists.</returns>
        public bool AddFetchRefSpec(RefSpec s)
        {
            if (Fetch.Contains(s))
            {
                return false;
            }

            Fetch.Add(s);

            return true;
        }
コード例 #20
0
ファイル: RefSpecTests.cs プロジェクト: stschake/GitSharp
 public void testExpandFromDestination_NonWildcard()
 {
     string src = "refs/heads/master";
     string dst = "refs/remotes/origin/master";
     RefSpec a = new RefSpec(src + ":" + dst);
     RefSpec r = a.ExpandFromDestination(dst);
     Assert.AreSame(a, r);
     Assert.IsFalse(r.Wildcard);
     Assert.AreEqual(src, r.Source);
     Assert.AreEqual(dst, r.Destination);
 }
コード例 #21
0
ファイル: FetchProcess.cs プロジェクト: kkl713/GitSharp
        private void deleteTrackingRef(FetchResult result, Repository db, RevWalk.RevWalk walk, RefSpec spec, Ref localRef)
        {
            string name = localRef.Name;

            try
            {
                TrackingRefUpdate u = new TrackingRefUpdate(db, name, spec.Source, true, ObjectId.ZeroId, "deleted");
                result.Add(u);
                if (_transport.DryRun)
                {
                    return;
                }

                u.Delete(walk);

                switch (u.Result)
                {
                case RefUpdate.RefUpdateResult.New:
                case RefUpdate.RefUpdateResult.NoChange:
                case RefUpdate.RefUpdateResult.FastForward:
                case RefUpdate.RefUpdateResult.Forced:
                    break;

                default:
                    throw new TransportException(_transport.Uri, "Cannot delete stale tracking ref " + name + ": " + u.Result.ToString());
                }
            }
            catch (System.IO.IOException e)
            {
                throw new TransportException(_transport.Uri, "Cannot delete stale tracking ref " + name, e);
            }
        }
コード例 #22
0
ファイル: RefSpecTests.cs プロジェクト: stschake/GitSharp
 public void testSetSource()
 {
     RefSpec a = new RefSpec();
     RefSpec b = a.SetSource("refs/heads/master");
     Assert.AreNotSame(a, b);
     Assert.AreEqual("HEAD", a.ToString());
     Assert.AreEqual("refs/heads/master", b.ToString());
 }
コード例 #23
0
 public bool RemoveFetchRefSpec(RefSpec s)
 {
     return(Fetch.Remove(s));
 }
コード例 #24
0
ファイル: FetchProcess.cs プロジェクト: dev218/GitSharp
        private void deleteTrackingRef(FetchResult result, Repository db, RevWalk.RevWalk walk, RefSpec spec, Ref localRef)
        {
            string name = localRef.Name;
            try
            {
                TrackingRefUpdate u = new TrackingRefUpdate(db, name, spec.Source, true, ObjectId.ZeroId, "deleted");
                result.Add(u);
                if (_transport.DryRun)
                {
                    return;
                }

                u.Delete(walk);

                switch (u.Result)
                {
                    case RefUpdate.RefUpdateResult.NEW:
                    case RefUpdate.RefUpdateResult.NO_CHANGE:
                    case RefUpdate.RefUpdateResult.FAST_FORWARD:
                    case RefUpdate.RefUpdateResult.FORCED:
                        break;

                    default:
                        throw new TransportException(_transport.Uri, "Cannot delete stale tracking ref " + name + ": " + Enum.GetName(typeof(RefUpdate.RefUpdateResult), u.Result));
                }
            }
            catch (IOException e)
            {
                throw new TransportException(_transport.Uri, "Cannot delete stale tracking ref " + name, e);
            }
        }
コード例 #25
0
ファイル: RefSpecTests.cs プロジェクト: stschake/GitSharp
 public void testSetSourceDestination()
 {
     RefSpec a = new RefSpec();
     RefSpec b;
     b = a.SetSourceDestination("refs/heads/*", "refs/remotes/origin/*");
     Assert.AreNotSame(a, b);
     Assert.AreEqual("HEAD", a.ToString());
     Assert.AreEqual("refs/heads/*:refs/remotes/origin/*", b.ToString());
 }
コード例 #26
0
 public bool RemovePushRefSpec(RefSpec s)
 {
     return(Push.Remove(s));
 }
コード例 #27
0
        private FetchResult fetchFromBundle(Core.Repository newRepo, byte[] bundle)
        {
            var uri = new URIish("in-memory://");
            var @in = new MemoryStream(bundle);
            var rs = new RefSpec("refs/heads/*:refs/heads/*");
            var refs = new List<RefSpec>{rs};
            var transportBundleStream = new TransportBundleStream(newRepo, uri, @in);

            _transportBundleStreams.Add(transportBundleStream);

            return transportBundleStream.fetch(NullProgressMonitor.Instance, refs);
        }
コード例 #28
0
ファイル: FetchProcess.cs プロジェクト: jagregory/GitSharp
 private TrackingRefUpdate createUpdate(RefSpec spec, ObjectId newId)
 {
     return new TrackingRefUpdate(_transport.Local, spec, newId, "fetch");
 }
コード例 #29
0
ファイル: RefSpec.cs プロジェクト: dev218/GitSharp
 private RefSpec(RefSpec p)
 {
     Force = p.Force;
     Wildcard = p.Wildcard;
     Source = p.Source;
     Destination = p.Destination;
 }
コード例 #30
0
ファイル: FetchProcess.cs プロジェクト: jagregory/GitSharp
        private void deleteTrackingRef(FetchResult result, Repository db, RevWalk.RevWalk walk, RefSpec spec, Ref localRef)
        {
            string name = localRef.Name;
            try
            {
                TrackingRefUpdate u = new TrackingRefUpdate(db, name, spec.Source, true, ObjectId.ZeroId, "deleted");
                result.Add(u);
                if (_transport.DryRun)
                {
                    return;
                }

                u.Delete(walk);

                switch (u.Result)
                {
                    case RefUpdate.RefUpdateResult.New:
                    case RefUpdate.RefUpdateResult.NoChange:
                    case RefUpdate.RefUpdateResult.FastForward:
                    case RefUpdate.RefUpdateResult.Forced:
                        break;

                    default:
                        throw new TransportException(_transport.Uri, "Cannot delete stale tracking ref " + name + ": " + u.Result.ToString());
                }
            }
            catch (System.IO.IOException e)
            {
                throw new TransportException(_transport.Uri, "Cannot delete stale tracking ref " + name, e);
            }
        }
コード例 #31
0
ファイル: RefSpec.cs プロジェクト: dev218/GitSharp
        /// <summary>
        /// Create a new RefSpec with a different destination name setting.
        /// </summary>
        /// <param name="destination">new value for destination in the returned instance.</param>
        /// <returns>a new RefSpec with destination as specified.</returns>
        public RefSpec SetDestination(string destination)
        {
            RefSpec r = new RefSpec(this);
            r.Destination = destination;

            if (IsWildcard(r.Destination) && r.Source == null)
            {
                throw new InvalidOperationException("Source is not a wildcard.");
            }
            if (IsWildcard(r.Source) != IsWildcard(r.Destination))
            {
                throw new InvalidOperationException("Source/Destination must match.");
            }
            return r;
        }
コード例 #32
0
ファイル: FetchProcess.cs プロジェクト: jagregory/GitSharp
 private void expandSingle(RefSpec spec, HashSet<Ref> matched)
 {
     Ref src = _connection.Refs.Find(x => x.Name == spec.Source);
     if (src == null)
     {
         throw new TransportException("Remote does not have " + spec.Source + " available for fetch.");
     }
     if (matched.Add(src))
     {
         want(src, spec);
     }
 }
コード例 #33
0
ファイル: RemoteConfig.cs プロジェクト: dev218/GitSharp
		/// <summary>
        /// Remove a fetch RefSpec from this remote.
		/// </summary>
        /// <param name="s">the specification to remove.</param>
        /// <returns>true if the specification existed and was removed.</returns>
        public bool RemoveFetchRefSpec(RefSpec s)
		{
			return Fetch.Remove(s);
		}
コード例 #34
0
ファイル: FetchProcess.cs プロジェクト: jagregory/GitSharp
 private void expandWildcard(RefSpec spec, HashSet<Ref> matched)
 {
     foreach (Ref src in _connection.Refs)
     {
         if (spec.MatchSource(src) && matched.Add(src))
             want(src, spec.ExpandFromSource((src)));
     }
 }
コード例 #35
0
ファイル: RemoteConfig.cs プロジェクト: dev218/GitSharp
        /// <summary>
        /// Remove a push RefSpec from this remote.
        /// </summary>
        /// <param name="s">the specification to remove.</param>
        /// <returns>true if the specification existed and was removed.</returns>
		public bool RemovePushRefSpec(RefSpec s)
		{
			return Push.Remove(s);
		}
コード例 #36
0
        private void deleteTrackingRef(FetchResult result, Repository db, RevWalk.RevWalk walk, RefSpec spec, Ref localRef)
        {
            string name = localRef.Name;

            try
            {
                TrackingRefUpdate u = new TrackingRefUpdate(db, name, spec.Source, true, ObjectId.ZeroId, "deleted");
                result.Add(u);
                if (_transport.DryRun)
                {
                    return;
                }

                u.Delete(walk);

                switch (u.Result)
                {
                case RefUpdate.RefUpdateResult.NEW:
                case RefUpdate.RefUpdateResult.NO_CHANGE:
                case RefUpdate.RefUpdateResult.FAST_FORWARD:
                case RefUpdate.RefUpdateResult.FORCED:
                    break;

                default:
                    throw new TransportException(_transport.Uri, "Cannot delete stale tracking ref " + name + ": " + Enum.GetName(typeof(RefUpdate.RefUpdateResult), u.Result));
                }
            }
            catch (IOException e)
            {
                throw new TransportException(_transport.Uri, "Cannot delete stale tracking ref " + name, e);
            }
        }