Пример #1
0
        public void testAddURI()
        {
            readConfig(string.Empty);

            URIish uri = new URIish("/some/dir");
            RemoteConfig rc = new RemoteConfig(config, "backup");
            Assert.AreEqual(0, rc.URIs.Count);

            Assert.IsTrue(rc.AddURI(uri));
            Assert.AreEqual(1, rc.URIs.Count);
            Assert.AreSame(uri, rc.URIs[0]);

            Assert.IsFalse(rc.AddURI(new URIish(uri.ToString())));
            Assert.AreEqual(1, rc.URIs.Count);
        }
Пример #2
0
        public void test017_SaveAllTags()
        {
            RemoteConfig rc = new RemoteConfig(db.Config, "origin");
            rc.AddURI(new URIish("/some/dir"));
            rc.AddFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/" + rc.Name + "/*"));
            rc.SetTagOpt(TagOpt.FETCH_TAGS);
            rc.Update(db.Config);
            db.Config.Save();

            checkFile(new FileInfo(Path.Combine(db.Directory.ToString(), "config")),
                      "[core]\n"
                      + "\trepositoryformatversion = 0\n" + "\tfilemode = true\n"
                      + "[remote \"origin\"]\n" + "\turl = /some/dir\n"
                      + "\tfetch = +refs/heads/*:refs/remotes/origin/*\n"
                      + "\ttagopt = --tags\n");
        }
Пример #3
0
        public void test013_SaveAddURI()
        {
            writeConfig("[remote \"spearce\"]\n"
                        + "url = http://www.spearce.org/egit.git\n"
                        + "fetch = +refs/heads/*:refs/remotes/spearce/*\n");

            RemoteConfig rc = new RemoteConfig(db.Config, "spearce");
            rc.AddURI(new URIish("/some/dir"));
            Assert.AreEqual(2, rc.URIs.Count);
            rc.Update(db.Config);
            db.Config.Save();

            checkFile(new FileInfo(Path.Combine(db.Directory.ToString(), "config")),
                      "[core]\n"
                      + "\trepositoryformatversion = 0\n" + "\tfilemode = true\n"
                      + "[remote \"spearce\"]\n"
                      + "\turl = http://www.spearce.org/egit.git\n"
                      + "\turl = /some/dir\n"
                      + "\tfetch = +refs/heads/*:refs/remotes/spearce/*\n");
        }
Пример #4
0
        public void test011_RemoveOnlyURI()
        {
            writeConfig("");

            URIish a = new URIish("/some/dir");
            RemoteConfig rc = new RemoteConfig(db.Config, "backup");
            Assert.IsTrue(rc.AddURI(a));

            Assert.AreEqual(1, rc.URIs.Count);
            Assert.AreSame(a, rc.URIs[0]);

            Assert.IsTrue(rc.RemoveURI(a));
            Assert.AreEqual(0, rc.URIs.Count);
        }
Пример #5
0
        public void test010_RemoveLastURI()
        {
            writeConfig("");

            URIish a = new URIish("/some/dir");
            URIish b = new URIish("/another/dir");
            URIish c = new URIish("/more/dirs");
            RemoteConfig rc = new RemoteConfig(db.Config, "backup");
            Assert.IsTrue(rc.AddURI(a));
            Assert.IsTrue(rc.AddURI(b));
            Assert.IsTrue(rc.AddURI(c));

            Assert.AreEqual(3, rc.URIs.Count);
            Assert.AreSame(a, rc.URIs[0]);
            Assert.AreSame(b, rc.URIs[1]);
            Assert.AreEqual(c, rc.URIs[2]);

            Assert.IsTrue(rc.RemoveURI(c));
            Assert.AreEqual(2, rc.URIs.Count);
            Assert.AreSame(a, rc.URIs[0]);
            Assert.AreSame(b, rc.URIs[1]);
        }
Пример #6
0
        public void test016_SaveNoTags()
        {
            RemoteConfig rc = new RemoteConfig(db.Config, "origin");
            rc.AddURI(new URIish("/some/dir"));
            rc.AddFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/" + rc.Name + "/*"));
            rc.SetTagOpt(TagOpt.NO_TAGS);
            rc.Update(db.Config);
            db.Config.save();

            checkFile(db.Config.getFile(),
                      "[core]\n"
                      + "\trepositoryformatversion = 0\n" + "\tfilemode = true\n"
                      + "[remote \"origin\"]\n" + "\turl = /some/dir\n"
                      + "\tfetch = +refs/heads/*:refs/remotes/origin/*\n"
                      + "\ttagopt = --no-tags\n");
        }
Пример #7
0
 private void saveRemote(URIish uri)
 {
     RemoteConfig rc = new RemoteConfig(db.Config, remoteName);
     rc.AddURI(uri);
     rc.AddFetchRefSpec(new RefSpec().SetForce(true).SetSourceDestination(Constants.R_HEADS + "*",
                                                                          Constants.R_REMOTES + remoteName + "/*"));
     rc.Update(db.Config);
     db.Config.save();
 }
Пример #8
0
        public void test007_AddURI()
        {
            writeConfig("");

            URIish uri = new URIish("/some/dir");
            RemoteConfig rc = new RemoteConfig(db.Config, "backup");
            Assert.AreEqual(0, rc.URIs.Count);

            Assert.True(rc.AddURI(uri));
            Assert.AreEqual(1, rc.URIs.Count);
            Assert.AreSame(uri, rc.URIs[0]);

            Assert.False(rc.AddURI(new URIish(uri.ToString())));
            Assert.AreEqual(1, rc.URIs.Count);
        }
Пример #9
0
 public void testSaveTimeout()
 {
     RemoteConfig rc = new RemoteConfig(config, "origin");
     rc.AddURI(new URIish("/some/dir"));
     rc.AddFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/" + rc.Name + "/*"));
     rc.Timeout = 60;
     rc.Update(config);
     checkConfig("[remote \"origin\"]\n" + "\turl = /some/dir\n"
             + "\tfetch = +refs/heads/*:refs/remotes/origin/*\n"
             + "\ttimeout = 60\n");
 }
Пример #10
0
        public void testSaveNoTags()
        {
            RemoteConfig rc = new RemoteConfig(config, "origin");
            rc.AddURI(new URIish("/some/dir"));
            rc.AddFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/" + rc.Name + "/*"));
            rc.SetTagOpt(TagOpt.NO_TAGS);
            rc.Update(config);

            checkConfig("[remote \"origin\"]\n" + "\turl = /some/dir\n"
                    + "\tfetch = +refs/heads/*:refs/remotes/origin/*\n"
                    + "\ttagopt = --no-tags\n");
        }
Пример #11
0
        public void testSaveAddURI()
        {
            readConfig("[remote \"spearce\"]\n"
                        + "url = http://www.spearce.org/egit.git\n"
                        + "fetch = +refs/heads/*:refs/remotes/spearce/*\n");

            RemoteConfig rc = new RemoteConfig(config, "spearce");
            rc.AddURI(new URIish("/some/dir"));
            Assert.AreEqual(2, rc.URIs.Count);
            rc.Update(config);

            checkConfig("[remote \"spearce\"]\n"
                    + "\turl = http://www.spearce.org/egit.git\n"
                    + "\turl = /some/dir\n"
                    + "\tfetch = +refs/heads/*:refs/remotes/spearce/*\n");
        }
Пример #12
0
        public void testRemoveOnlyURI()
        {
            readConfig(string.Empty);

            URIish a = new URIish("/some/dir");
            RemoteConfig rc = new RemoteConfig(config, "backup");
            Assert.IsTrue(rc.AddURI(a));

            Assert.AreEqual(1, rc.URIs.Count);
            Assert.AreSame(a, rc.URIs[0]);

            Assert.IsTrue(rc.RemoveURI(a));
            Assert.AreEqual(0, rc.URIs.Count);
        }
Пример #13
0
        public void testRemoveMiddleURI()
        {
            readConfig(string.Empty);

            URIish a = new URIish("/some/dir");
            URIish b = new URIish("/another/dir");
            URIish c = new URIish("/more/dirs");
            RemoteConfig rc = new RemoteConfig(config, "backup");
            Assert.IsTrue(rc.AddURI(a));
            Assert.IsTrue(rc.AddURI(b));
            Assert.IsTrue(rc.AddURI(c));

            Assert.AreEqual(3, rc.URIs.Count);
            Assert.AreSame(a, rc.URIs[0]);
            Assert.AreSame(b, rc.URIs[1]);
            Assert.AreEqual(c, rc.URIs[2]);

            Assert.IsTrue(rc.RemoveURI(b));
            Assert.AreEqual(2, rc.URIs.Count);
            Assert.AreSame(a, rc.URIs[0]);
            Assert.AreSame(c, rc.URIs[1]);
        }