コード例 #1
0
ファイル: RemoteConfigTests.cs プロジェクト: gilran/GitSharp
        public void test000_Simple()
        {
            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");
            System.Collections.Generic.List<URIish> allURIs = rc.URIs;
            RefSpec spec;

            Assert.AreEqual("spearce", rc.Name);
            Assert.IsNotNull(allURIs);
            Assert.IsNotNull(rc.Fetch);
            Assert.IsNotNull(rc.Push);
            Assert.IsNotNull(rc.TagOpt);
            Assert.AreSame(TagOpt.AUTO_FOLLOW, rc.TagOpt);

            Assert.AreEqual(1, allURIs.Count);
            Assert.AreEqual("http://www.spearce.org/egit.git", allURIs[0].ToString());

            Assert.AreEqual(1, rc.Fetch.Count);
            spec = rc.Fetch[0];
            Assert.IsTrue(spec.Force);
            Assert.IsTrue(spec.Wildcard);
            Assert.AreEqual("refs/heads/*", spec.Source);
            Assert.AreEqual("refs/remotes/spearce/*", spec.Destination);

            Assert.AreEqual(0, rc.Push.Count);
        }
コード例 #2
0
ファイル: Transport.cs プロジェクト: stephensong/GitSharp
 public static Transport Open(Repository local, string remote)
 {
     RemoteConfig cfg = new RemoteConfig(local.Config, remote);
     List<URIish> uris = cfg.URIs;
     if (uris.Count == 0)
         return Open(local, new URIish(remote));
     return Open(local, cfg);
 }
コード例 #3
0
ファイル: Transport.cs プロジェクト: stephensong/GitSharp
        public static Transport Open(Repository local, RemoteConfig cfg)
        {
            if (cfg.URIs.Count == 0)
                throw new ArgumentException("Remote config \"" + cfg.Name + "\" has no URIs associated");

            Transport tn = Open(local, cfg.URIs[0]);
            tn.ApplyConfig(cfg);
            return tn;
        }
コード例 #4
0
ファイル: Transport.cs プロジェクト: stephensong/GitSharp
        public static List<Transport> openAll(Repository local, string remote)
        {
            RemoteConfig cfg = new RemoteConfig(local.Config, remote);
            List<URIish> uris = cfg.URIs;
            if (uris.isEmpty())
            {
                List<Transport> transports = new List<Transport>(1);
                transports.Add(Open(local, new URIish(remote)));
                return transports;
            }

            return openAll(local, cfg);
        }
コード例 #5
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);
        }
コード例 #6
0
ファイル: RemoteConfigTests.cs プロジェクト: gilran/GitSharp
        public void test015_SaveRemoveFirstURI()
        {
            writeConfig("[remote \"spearce\"]\n"
                        + "url = http://www.spearce.org/egit.git\n"
                        + "url = /some/dir\n"
                        + "fetch = +refs/heads/*:refs/remotes/spearce/*\n");

            RemoteConfig rc = new RemoteConfig(db.Config, "spearce");
            Assert.AreEqual(2, rc.URIs.Count);
            rc.RemoveURI(new URIish("http://www.spearce.org/egit.git"));
            Assert.AreEqual(1, 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 = /some/dir\n"
                      + "\tfetch = +refs/heads/*:refs/remotes/spearce/*\n");
        }
コード例 #7
0
ファイル: RemoteConfigTests.cs プロジェクト: gilran/GitSharp
        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);
        }
コード例 #8
0
ファイル: RemoteConfigTests.cs プロジェクト: gilran/GitSharp
        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]);
        }
コード例 #9
0
ファイル: RemoteConfigTests.cs プロジェクト: gilran/GitSharp
        public void test006_Unknown()
        {
            writeConfig("");

            RemoteConfig rc = new RemoteConfig(db.Config, "backup");
            Assert.AreEqual(0, rc.URIs.Count);
            Assert.AreEqual(0, rc.Fetch.Count);
            Assert.AreEqual(0, rc.Push.Count);
            Assert.AreEqual("git-upload-pack", rc.UploadPack);
            Assert.AreEqual("git-receive-pack", rc.ReceivePack);
        }
コード例 #10
0
ファイル: RemoteConfigTests.cs プロジェクト: gilran/GitSharp
        public void test005_UploadPack()
        {
            writeConfig("[remote \"example\"]\n"
                        + "url = [email protected]:egit.git\n"
                        + "fetch = +refs/heads/*:refs/remotes/example/*\n"
                        + "uploadpack = /path/to/git/git-upload-pack\n"
                        + "receivepack = /path/to/git/git-receive-pack\n");

            RemoteConfig rc = new RemoteConfig(db.Config, "example");
            System.Collections.Generic.List<URIish> allURIs = rc.URIs;
            RefSpec spec;

            Assert.AreEqual("example", rc.Name);
            Assert.IsNotNull(allURIs);
            Assert.IsNotNull(rc.Fetch);
            Assert.IsNotNull(rc.Push);

            Assert.AreEqual(1, allURIs.Count);
            Assert.AreEqual("[email protected]:egit.git", allURIs[0].ToString());

            Assert.AreEqual(1, rc.Fetch.Count);
            spec = rc.Fetch[0];
            Assert.IsTrue(spec.Force);
            Assert.IsTrue(spec.Wildcard);
            Assert.AreEqual("refs/heads/*", spec.Source);
            Assert.AreEqual("refs/remotes/example/*", spec.Destination);

            Assert.AreEqual(0, rc.Push.Count);

            Assert.AreEqual("/path/to/git/git-upload-pack", rc.UploadPack);
            Assert.AreEqual("/path/to/git/git-receive-pack", rc.ReceivePack);
        }
コード例 #11
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);
        }
コード例 #12
0
 public void testSimpleAlwaysTags()
 {
     readConfig("[remote \"spearce\"]\n"
                 + "url = http://www.spearce.org/egit.git\n"
                 + "fetch = +refs/heads/*:refs/remotes/spearce/*\n"
                 + "tagopt = --tags\n");
     RemoteConfig rc = new RemoteConfig(config, "spearce");
     Assert.AreSame(TagOpt.FETCH_TAGS, rc.TagOpt);
 }
コード例 #13
0
        public void testSaveRemoveLastURI()
        {
            readConfig("[remote \"spearce\"]\n"
                        + "url = http://www.spearce.org/egit.git\n"
                        + "url = /some/dir\n"
                        + "fetch = +refs/heads/*:refs/remotes/spearce/*\n");

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

            checkConfig("[remote \"spearce\"]\n"
                    + "\turl = http://www.spearce.org/egit.git\n"
                    + "\tfetch = +refs/heads/*:refs/remotes/spearce/*\n");
        }
コード例 #14
0
ファイル: RemoteConfigTests.cs プロジェクト: gilran/GitSharp
 public void test001_SimpleNoTags()
 {
     writeConfig("[remote \"spearce\"]\n"
                 + "url = http://www.spearce.org/egit.git\n"
                 + "fetch = +refs/heads/*:refs/remotes/spearce/*\n"
                 + "tagopt = --no-tags\n");
     RemoteConfig rc = new RemoteConfig(db.Config, "spearce");
     Assert.AreSame(TagOpt.NO_TAGS, rc.TagOpt);
 }
コード例 #15
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);
        }
コード例 #16
0
        public void test003_Mirror()
        {
            writeConfig("[remote \"spearce\"]\n"
                        + "url = http://www.spearce.org/egit.git\n"
                        + "fetch = +refs/heads/*:refs/heads/*\n"
                        + "fetch = refs/tags/*:refs/tags/*\n");

            RemoteConfig rc = new RemoteConfig(db.Config, "spearce");
            System.Collections.Generic.List<URIish> allURIs = rc.URIs;
            RefSpec spec;

            Assert.AreEqual("spearce", rc.Name);
            Assert.NotNull(allURIs);
            Assert.NotNull(rc.Fetch);
            Assert.NotNull(rc.Push);

            Assert.AreEqual(1, allURIs.Count);
            Assert.AreEqual("http://www.spearce.org/egit.git", allURIs[0].ToString());

            Assert.AreEqual(2, rc.Fetch.Count);

            spec = rc.Fetch[0];
            Assert.True(spec.Force);
            Assert.True(spec.Wildcard);
            Assert.AreEqual("refs/heads/*", spec.Source);
            Assert.AreEqual("refs/heads/*", spec.Destination);

            spec = rc.Fetch[1];
            Assert.False(spec.Force);
            Assert.True(spec.Wildcard);
            Assert.AreEqual("refs/tags/*", spec.Source);
            Assert.AreEqual("refs/tags/*", spec.Destination);

            Assert.AreEqual(0, rc.Push.Count);
        }
コード例 #17
0
        public void testUnknown()
        {
            readConfig(string.Empty);

            RemoteConfig rc = new RemoteConfig(config, "backup");
            Assert.AreEqual(0, rc.URIs.Count);
            Assert.AreEqual(0, rc.Fetch.Count);
            Assert.AreEqual(0, rc.Push.Count);
            Assert.AreEqual("git-upload-pack", rc.UploadPack);
            Assert.AreEqual("git-receive-pack", rc.ReceivePack);
        }
コード例 #18
0
        public void testSimpleTimeout()
        {
            readConfig("[remote \"spearce\"]\n"
                    + "url = http://www.spearce.org/egit.git\n"
                    + "fetch = +refs/heads/*:refs/remotes/spearce/*\n"
                    + "timeout = 12\n");

            RemoteConfig rc = new RemoteConfig(config, "spearce");
            Assert.AreEqual(12, rc.Timeout);
        }
コード例 #19
0
ファイル: RemoteConfigTests.cs プロジェクト: gilran/GitSharp
        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");
        }
コード例 #20
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");
        }
コード例 #21
0
ファイル: Clone.cs プロジェクト: drothmaler/GitSharp
 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();
 }
コード例 #22
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");
 }
コード例 #23
0
ファイル: Transport.cs プロジェクト: stephensong/GitSharp
 public void ApplyConfig(RemoteConfig cfg)
 {
     OptionUploadPack = cfg.UploadPack;
     fetch = cfg.Fetch;
     TagOpt = cfg.TagOpt;
     OptionReceivePack = cfg.ReceivePack;
     push = cfg.Push;
 }
コード例 #24
0
        public void test014_SaveRemoveLastURI()
        {
            writeConfig("[remote \"spearce\"]\n"
                        + "url = http://www.spearce.org/egit.git\n"
                        + "url = /some/dir\n"
                        + "fetch = +refs/heads/*:refs/remotes/spearce/*\n");

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

            checkFile(db.Config.getFile(),
                      "[core]\n"
                      + "\trepositoryformatversion = 0\n" + "\tfilemode = true\n"
                      + "[remote \"spearce\"]\n"
                      + "\turl = http://www.spearce.org/egit.git\n"
                      + "\tfetch = +refs/heads/*:refs/remotes/spearce/*\n");
        }
コード例 #25
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");
        }
コード例 #26
0
ファイル: RemoteConfigTests.cs プロジェクト: gilran/GitSharp
        public void test004_Backup()
        {
            writeConfig("[remote \"backup\"]\n"
                        + "url = http://www.spearce.org/egit.git\n"
                        + "url = [email protected]:/srv/git/egit.git\n"
                        + "push = +refs/heads/*:refs/heads/*\n"
                        + "push = refs/tags/*:refs/tags/*\n");

            RemoteConfig rc = new RemoteConfig(db.Config, "backup");
            System.Collections.Generic.List<URIish> allURIs = rc.URIs;
            RefSpec spec;

            Assert.AreEqual("backup", rc.Name);
            Assert.IsNotNull(allURIs);
            Assert.IsNotNull(rc.Fetch);
            Assert.IsNotNull(rc.Push);

            Assert.AreEqual(2, allURIs.Count);
            Assert.AreEqual("http://www.spearce.org/egit.git", allURIs[0].ToString());
            Assert.AreEqual("[email protected]:/srv/git/egit.git", allURIs[1].ToString());

            Assert.AreEqual(0, rc.Fetch.Count);

            Assert.AreEqual(2, rc.Push.Count);
            spec = rc.Push[0];
            Assert.IsTrue(spec.Force);
            Assert.IsTrue(spec.Wildcard);
            Assert.AreEqual("refs/heads/*", spec.Source);
            Assert.AreEqual("refs/heads/*", spec.Destination);

            spec = rc.Push[1];
            Assert.IsFalse(spec.Force);
            Assert.IsTrue(spec.Wildcard);
            Assert.AreEqual("refs/tags/*", spec.Source);
            Assert.AreEqual("refs/tags/*", spec.Destination);
        }
コード例 #27
0
ファイル: Transport.cs プロジェクト: stephensong/GitSharp
 public static List<Transport> openAll(Repository local, RemoteConfig cfg)
 {
     List<URIish> uris = cfg.URIs;
     List<Transport> tranports = new List<Transport>(uris.Count);
     foreach (URIish uri in uris)
     {
         Transport tn = Open(local, uri);
         tn.ApplyConfig(cfg);
         tranports.Add(tn);
     }
     return tranports;
 }
コード例 #28
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]);
        }