예제 #1
0
 public void test001_SplitLastColon()
 {
     string lhs = ":m:a:i:n:t";
     string rhs = "refs/heads/maint";
     RefSpec rs = new RefSpec(lhs + ":" + rhs);
     Assert.False(rs.Force);
     Assert.False(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()));
 }
예제 #2
0
        public void test000_MasterMaster()
        {
            string sn = "refs/heads/master";
            RefSpec rs = new RefSpec(sn + ":" + sn);
            Assert.False(rs.Force);
            Assert.False(rs.Wildcard);
            Assert.AreEqual(sn, rs.Source);
            Assert.AreEqual(sn, rs.Destination);
            Assert.AreEqual(sn + ":" + sn, rs.ToString());
            Assert.AreEqual(rs, new RefSpec(rs.ToString()));

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

            r = new Ref(Ref.Storage.Loose, sn + "-and-more", null);
            Assert.False(rs.MatchSource(r));
            Assert.False(rs.MatchDestination(r));
        }
예제 #3
0
        public void test010_SetDestination_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());
        }
예제 #4
0
 public void test011_SetSourceDestination()
 {
     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());
 }
예제 #5
0
 public void test010_SetDestination()
 {
     RefSpec a = new RefSpec();
     RefSpec b = a.SetDestination("refs/heads/master");
     Assert.AreNotSame(a, b);
     Assert.AreEqual("HEAD", a.ToString());
     Assert.AreEqual("HEAD:refs/heads/master", b.ToString());
 }
예제 #6
0
 public void test009_SetSource()
 {
     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());
 }
예제 #7
0
 public void test008_SetForceUpdate()
 {
     string s = "refs/heads/*:refs/remotes/origin/*";
     RefSpec a = new RefSpec(s);
     Assert.False(a.Force);
     RefSpec b = a.SetForce(true);
     Assert.AreNotSame(a, b);
     Assert.False(a.Force);
     Assert.True(b.Force);
     Assert.AreEqual(s, a.ToString());
     Assert.AreEqual("+" + s, b.ToString());
 }
예제 #8
0
 public void test007_CreateEmpty()
 {
     RefSpec rs = new RefSpec();
     Assert.False(rs.Force);
     Assert.False(rs.Wildcard);
     Assert.AreEqual("HEAD", rs.Source);
     Assert.Null(rs.Destination);
     Assert.AreEqual("HEAD", rs.ToString());
 }
예제 #9
0
        public void test006_ForceRemotesOrigin()
        {
            string srcn = "refs/heads/*";
            string dstn = "refs/remotes/origin/*";
            RefSpec rs = new RefSpec("+" + srcn + ":" + dstn);
            Assert.True(rs.Force);
            Assert.True(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()));

            Ref r;
            RefSpec expanded;

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

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

            r = new Ref(Ref.Storage.Loose, "refs/tags/v1.0", null);
            Assert.False(rs.MatchSource(r));
            Assert.False(rs.MatchDestination(r));
        }