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)); }
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)); }
/// <exception cref="NGit.Errors.TransportException"></exception> private void ExpandWildcard(RefSpec spec, ICollection <Ref> matched) { foreach (Ref src in conn.GetRefs()) { if (spec.MatchSource(src) && matched.AddItem(src)) { Want(src, spec.ExpandFromSource(src)); } } }
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)); }
/// <exception cref="NGit.Errors.TransportException"></exception> private void ExpandWildcard(RefSpec spec, ICollection<Ref> matched) { foreach (Ref src in conn.GetRefs()) { if (spec.MatchSource(src) && matched.AddItem(src)) { Want(src, spec.ExpandFromSource(src)); } } }