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); }
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); }
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; }
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); }
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); }
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"); }
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); }
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]); }
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); }
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); }
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); }
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); }
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"); }
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); }
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); }
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); }
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); }
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); }
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"); }
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"); }
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(); }
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"); }
public void ApplyConfig(RemoteConfig cfg) { OptionUploadPack = cfg.UploadPack; fetch = cfg.Fetch; TagOpt = cfg.TagOpt; OptionReceivePack = cfg.ReceivePack; push = cfg.Push; }
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"); }
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"); }
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); }
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; }
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]); }