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())); }
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()); }
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)); }
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()); }
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()); }
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()); }
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()); }
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)); }