コード例 #1
0
ファイル: RefSpecTest.cs プロジェクト: ststeiger/ngit-core
        public virtual void TestSetForceUpdate()
        {
            string  s = "refs/heads/*:refs/remotes/origin/*";
            RefSpec a = new RefSpec(s);

            NUnit.Framework.Assert.IsFalse(a.IsForceUpdate());
            RefSpec b = a.SetForceUpdate(true);

            NUnit.Framework.Assert.AreNotSame(a, b);
            NUnit.Framework.Assert.IsFalse(a.IsForceUpdate());
            NUnit.Framework.Assert.IsTrue(b.IsForceUpdate());
            NUnit.Framework.Assert.AreEqual(s, a.ToString());
            NUnit.Framework.Assert.AreEqual("+" + s, b.ToString());
        }
コード例 #2
0
ファイル: RefSpecTest.cs プロジェクト: ststeiger/ngit-core
        public virtual void TestForceRemotesOrigin()
        {
            string  srcn = "refs/heads/*";
            string  dstn = "refs/remotes/origin/*";
            RefSpec rs   = new RefSpec("+" + srcn + ":" + dstn);

            NUnit.Framework.Assert.IsTrue(rs.IsForceUpdate());
            NUnit.Framework.Assert.IsTrue(rs.IsWildcard());
            NUnit.Framework.Assert.AreEqual(srcn, rs.GetSource());
            NUnit.Framework.Assert.AreEqual(dstn, rs.GetDestination());
            NUnit.Framework.Assert.AreEqual("+" + srcn + ":" + dstn, rs.ToString());
            NUnit.Framework.Assert.AreEqual(rs, new RefSpec(rs.ToString()));
            Ref     r;
            RefSpec expanded;

            r = new ObjectIdRef.Unpeeled(RefStorage.LOOSE, "refs/heads/master", null);
            NUnit.Framework.Assert.IsTrue(rs.MatchSource(r));
            NUnit.Framework.Assert.IsFalse(rs.MatchDestination(r));
            expanded = rs.ExpandFromSource(r);
            NUnit.Framework.Assert.AreNotSame(rs, expanded);
            NUnit.Framework.Assert.IsTrue(expanded.IsForceUpdate());
            NUnit.Framework.Assert.IsFalse(expanded.IsWildcard());
            NUnit.Framework.Assert.AreEqual(r.GetName(), expanded.GetSource());
            NUnit.Framework.Assert.AreEqual("refs/remotes/origin/master", expanded.GetDestination
                                                ());
            r = new ObjectIdRef.Unpeeled(RefStorage.LOOSE, "refs/remotes/origin/next", null);
            NUnit.Framework.Assert.IsFalse(rs.MatchSource(r));
            NUnit.Framework.Assert.IsTrue(rs.MatchDestination(r));
            r = new ObjectIdRef.Unpeeled(RefStorage.LOOSE, "refs/tags/v1.0", null);
            NUnit.Framework.Assert.IsFalse(rs.MatchSource(r));
            NUnit.Framework.Assert.IsFalse(rs.MatchDestination(r));
        }
コード例 #3
0
        /// <exception cref="NGit.Errors.TransportException"></exception>
        private TrackingRefUpdate CreateUpdate(RefSpec spec, ObjectId newId)
        {
            Ref      @ref  = LocalRefs().Get(spec.GetDestination());
            ObjectId oldId = @ref != null && @ref.GetObjectId() != null? @ref.GetObjectId() :
                                 ObjectId.ZeroId;

            return(new TrackingRefUpdate(spec.IsForceUpdate(), spec.GetSource(), spec.GetDestination
                                             (), oldId, newId));
        }
コード例 #4
0
ファイル: RefSpecTest.cs プロジェクト: ststeiger/ngit-core
        public virtual void TestCreateEmpty()
        {
            RefSpec rs = new RefSpec();

            NUnit.Framework.Assert.IsFalse(rs.IsForceUpdate());
            NUnit.Framework.Assert.IsFalse(rs.IsWildcard());
            NUnit.Framework.Assert.AreEqual("HEAD", rs.GetSource());
            NUnit.Framework.Assert.IsNull(rs.GetDestination());
            NUnit.Framework.Assert.AreEqual("HEAD", rs.ToString());
        }
コード例 #5
0
ファイル: RefSpecTest.cs プロジェクト: LunarLanding/ngit
		public virtual void TestSplitLastColon()
		{
			string lhs = ":m:a:i:n:t";
			string rhs = "refs/heads/maint";
			RefSpec rs = new RefSpec(lhs + ":" + rhs);
			NUnit.Framework.Assert.IsFalse(rs.IsForceUpdate());
			NUnit.Framework.Assert.IsFalse(rs.IsWildcard());
			NUnit.Framework.Assert.AreEqual(lhs, rs.GetSource());
			NUnit.Framework.Assert.AreEqual(rhs, rs.GetDestination());
			NUnit.Framework.Assert.AreEqual(lhs + ":" + rhs, rs.ToString());
			NUnit.Framework.Assert.AreEqual(rs, new RefSpec(rs.ToString()));
		}
コード例 #6
0
ファイル: RefSpecTest.cs プロジェクト: ststeiger/ngit-core
        public virtual void TestSplitLastColon()
        {
            string  lhs = ":m:a:i:n:t";
            string  rhs = "refs/heads/maint";
            RefSpec rs  = new RefSpec(lhs + ":" + rhs);

            NUnit.Framework.Assert.IsFalse(rs.IsForceUpdate());
            NUnit.Framework.Assert.IsFalse(rs.IsWildcard());
            NUnit.Framework.Assert.AreEqual(lhs, rs.GetSource());
            NUnit.Framework.Assert.AreEqual(rhs, rs.GetDestination());
            NUnit.Framework.Assert.AreEqual(lhs + ":" + rhs, rs.ToString());
            NUnit.Framework.Assert.AreEqual(rs, new RefSpec(rs.ToString()));
        }
コード例 #7
0
ファイル: RefSpecTest.cs プロジェクト: LunarLanding/ngit
		public virtual void TestMasterMaster()
		{
			string sn = "refs/heads/master";
			RefSpec rs = new RefSpec(sn + ":" + sn);
			NUnit.Framework.Assert.IsFalse(rs.IsForceUpdate());
			NUnit.Framework.Assert.IsFalse(rs.IsWildcard());
			NUnit.Framework.Assert.AreEqual(sn, rs.GetSource());
			NUnit.Framework.Assert.AreEqual(sn, rs.GetDestination());
			NUnit.Framework.Assert.AreEqual(sn + ":" + sn, rs.ToString());
			NUnit.Framework.Assert.AreEqual(rs, new RefSpec(rs.ToString()));
			Ref r = new ObjectIdRef.Unpeeled(RefStorage.LOOSE, sn, null);
			NUnit.Framework.Assert.IsTrue(rs.MatchSource(r));
			NUnit.Framework.Assert.IsTrue(rs.MatchDestination(r));
			NUnit.Framework.Assert.AreSame(rs, rs.ExpandFromSource(r));
			r = new ObjectIdRef.Unpeeled(RefStorage.LOOSE, sn + "-and-more", null);
			NUnit.Framework.Assert.IsFalse(rs.MatchSource(r));
			NUnit.Framework.Assert.IsFalse(rs.MatchDestination(r));
		}
コード例 #8
0
ファイル: RefSpecTest.cs プロジェクト: ststeiger/ngit-core
        public virtual void TestForceMasterMaster()
        {
            string  sn = "refs/heads/master";
            RefSpec rs = new RefSpec("+" + sn + ":" + sn);

            NUnit.Framework.Assert.IsTrue(rs.IsForceUpdate());
            NUnit.Framework.Assert.IsFalse(rs.IsWildcard());
            NUnit.Framework.Assert.AreEqual(sn, rs.GetSource());
            NUnit.Framework.Assert.AreEqual(sn, rs.GetDestination());
            NUnit.Framework.Assert.AreEqual("+" + sn + ":" + sn, rs.ToString());
            NUnit.Framework.Assert.AreEqual(rs, new RefSpec(rs.ToString()));
            Ref r = new ObjectIdRef.Unpeeled(RefStorage.LOOSE, sn, null);

            NUnit.Framework.Assert.IsTrue(rs.MatchSource(r));
            NUnit.Framework.Assert.IsTrue(rs.MatchDestination(r));
            NUnit.Framework.Assert.AreSame(rs, rs.ExpandFromSource(r));
            r = new ObjectIdRef.Unpeeled(RefStorage.LOOSE, sn + "-and-more", null);
            NUnit.Framework.Assert.IsFalse(rs.MatchSource(r));
            NUnit.Framework.Assert.IsFalse(rs.MatchDestination(r));
        }
コード例 #9
0
ファイル: RefSpecTest.cs プロジェクト: LunarLanding/ngit
		public virtual void TestSetForceUpdate()
		{
			string s = "refs/heads/*:refs/remotes/origin/*";
			RefSpec a = new RefSpec(s);
			NUnit.Framework.Assert.IsFalse(a.IsForceUpdate());
			RefSpec b = a.SetForceUpdate(true);
			NUnit.Framework.Assert.AreNotSame(a, b);
			NUnit.Framework.Assert.IsFalse(a.IsForceUpdate());
			NUnit.Framework.Assert.IsTrue(b.IsForceUpdate());
			NUnit.Framework.Assert.AreEqual(s, a.ToString());
			NUnit.Framework.Assert.AreEqual("+" + s, b.ToString());
		}
コード例 #10
0
ファイル: RefSpecTest.cs プロジェクト: LunarLanding/ngit
		public virtual void TestCreateEmpty()
		{
			RefSpec rs = new RefSpec();
			NUnit.Framework.Assert.IsFalse(rs.IsForceUpdate());
			NUnit.Framework.Assert.IsFalse(rs.IsWildcard());
			NUnit.Framework.Assert.AreEqual("HEAD", rs.GetSource());
			NUnit.Framework.Assert.IsNull(rs.GetDestination());
			NUnit.Framework.Assert.AreEqual("HEAD", rs.ToString());
		}
コード例 #11
0
ファイル: RefSpecTest.cs プロジェクト: LunarLanding/ngit
		public virtual void TestForceRemotesOrigin()
		{
			string srcn = "refs/heads/*";
			string dstn = "refs/remotes/origin/*";
			RefSpec rs = new RefSpec("+" + srcn + ":" + dstn);
			NUnit.Framework.Assert.IsTrue(rs.IsForceUpdate());
			NUnit.Framework.Assert.IsTrue(rs.IsWildcard());
			NUnit.Framework.Assert.AreEqual(srcn, rs.GetSource());
			NUnit.Framework.Assert.AreEqual(dstn, rs.GetDestination());
			NUnit.Framework.Assert.AreEqual("+" + srcn + ":" + dstn, rs.ToString());
			NUnit.Framework.Assert.AreEqual(rs, new RefSpec(rs.ToString()));
			Ref r;
			RefSpec expanded;
			r = new ObjectIdRef.Unpeeled(RefStorage.LOOSE, "refs/heads/master", null);
			NUnit.Framework.Assert.IsTrue(rs.MatchSource(r));
			NUnit.Framework.Assert.IsFalse(rs.MatchDestination(r));
			expanded = rs.ExpandFromSource(r);
			NUnit.Framework.Assert.AreNotSame(rs, expanded);
			NUnit.Framework.Assert.IsTrue(expanded.IsForceUpdate());
			NUnit.Framework.Assert.IsFalse(expanded.IsWildcard());
			NUnit.Framework.Assert.AreEqual(r.GetName(), expanded.GetSource());
			NUnit.Framework.Assert.AreEqual("refs/remotes/origin/master", expanded.GetDestination
				());
			r = new ObjectIdRef.Unpeeled(RefStorage.LOOSE, "refs/remotes/origin/next", null);
			NUnit.Framework.Assert.IsFalse(rs.MatchSource(r));
			NUnit.Framework.Assert.IsTrue(rs.MatchDestination(r));
			r = new ObjectIdRef.Unpeeled(RefStorage.LOOSE, "refs/tags/v1.0", null);
			NUnit.Framework.Assert.IsFalse(rs.MatchSource(r));
			NUnit.Framework.Assert.IsFalse(rs.MatchDestination(r));
		}
コード例 #12
0
ファイル: TrackingRefUpdate.cs プロジェクト: sharwell/ngit
        /// <exception cref="System.IO.IOException"></exception>
        internal TrackingRefUpdate(Repository db, RefSpec spec, AnyObjectId nv, string msg
			)
            : this(db, spec.GetDestination(), spec.GetSource(), spec.IsForceUpdate(), nv, 
			msg)
        {
        }
コード例 #13
0
ファイル: FetchProcess.cs プロジェクト: LunarLanding/ngit
		/// <exception cref="NGit.Errors.TransportException"></exception>
		private TrackingRefUpdate CreateUpdate(RefSpec spec, ObjectId newId)
		{
			Ref @ref = LocalRefs().Get(spec.GetDestination());
			ObjectId oldId = @ref != null && @ref.GetObjectId() != null ? @ref.GetObjectId() : 
				ObjectId.ZeroId;
			return new TrackingRefUpdate(spec.IsForceUpdate(), spec.GetSource(), spec.GetDestination
				(), oldId, newId);
		}
コード例 #14
0
ファイル: TrackingRefUpdate.cs プロジェクト: shoff/ngit
 /// <exception cref="System.IO.IOException"></exception>
 internal TrackingRefUpdate(Repository db, RefSpec spec, AnyObjectId nv, string msg
                            ) : this(db, spec.GetDestination(), spec.GetSource(), spec.IsForceUpdate(), nv,
                                     msg)
 {
 }