Search in sources :

Example 1 with SubmoduleSubscription

use of com.google.gerrit.reviewdb.client.SubmoduleSubscription in project gerrit by GerritCodeReview.

the class SubmoduleSectionParserIT method withSubProjectFound.

@Test
public void withSubProjectFound() throws Exception {
    Project.NameKey p1 = createProject("a/b");
    Project.NameKey p2 = createProject("b");
    Config cfg = new Config();
    cfg.fromText("\n" + "[submodule \"a/b\"]\n" + "path = a/b\n" + "url = ssh://localhost/" + p1.get() + "\n" + "branch = .\n" + "[submodule \"b\"]\n" + "path = b\n" + "url = http://localhost/" + p2.get() + "\n" + "branch = .\n");
    Branch.NameKey targetBranch = new Branch.NameKey(new Project.NameKey("project"), "master");
    Set<SubmoduleSubscription> res = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch).parseAllSections();
    Set<SubmoduleSubscription> expected = Sets.newHashSet(new SubmoduleSubscription(targetBranch, new Branch.NameKey(p2, "master"), "b"), new SubmoduleSubscription(targetBranch, new Branch.NameKey(p1, "master"), "a/b"));
    assertThat(res).containsExactlyElementsIn(expected);
}
Also used : Project(com.google.gerrit.reviewdb.client.Project) Config(org.eclipse.jgit.lib.Config) Branch(com.google.gerrit.reviewdb.client.Branch) SubmoduleSubscription(com.google.gerrit.reviewdb.client.SubmoduleSubscription) SubmoduleSectionParser(com.google.gerrit.server.util.SubmoduleSectionParser) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 2 with SubmoduleSubscription

use of com.google.gerrit.reviewdb.client.SubmoduleSubscription in project gerrit by GerritCodeReview.

the class SubmoduleSectionParserIT method withSectionToOtherServer.

@Test
public void withSectionToOtherServer() throws Exception {
    Project.NameKey p1 = createProject("a");
    Config cfg = new Config();
    cfg.fromText("" + "[submodule \"a\"]" + "path = a" + "url = ssh://non-localhost/" + p1.get() + "\n" + "branch = .");
    Branch.NameKey targetBranch = new Branch.NameKey(new Project.NameKey("project"), "master");
    Set<SubmoduleSubscription> res = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch).parseAllSections();
    assertThat(res).isEmpty();
}
Also used : Project(com.google.gerrit.reviewdb.client.Project) Config(org.eclipse.jgit.lib.Config) Branch(com.google.gerrit.reviewdb.client.Branch) SubmoduleSubscription(com.google.gerrit.reviewdb.client.SubmoduleSubscription) SubmoduleSectionParser(com.google.gerrit.server.util.SubmoduleSectionParser) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 3 with SubmoduleSubscription

use of com.google.gerrit.reviewdb.client.SubmoduleSubscription in project gerrit by GerritCodeReview.

the class SubmoduleSectionParserIT method followMasterBranch.

@Test
public void followMasterBranch() throws Exception {
    Project.NameKey p = createProject("a");
    Config cfg = new Config();
    cfg.fromText("" + "[submodule \"a\"]\n" + "path = localpath-to-a\n" + "url = ssh://localhost/" + p.get() + "\n" + "branch = master\n");
    Branch.NameKey targetBranch = new Branch.NameKey(new Project.NameKey("project"), "master");
    Set<SubmoduleSubscription> res = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch).parseAllSections();
    Set<SubmoduleSubscription> expected = Sets.newHashSet(new SubmoduleSubscription(targetBranch, new Branch.NameKey(p, "master"), "localpath-to-a"));
    assertThat(res).containsExactlyElementsIn(expected);
}
Also used : Project(com.google.gerrit.reviewdb.client.Project) Config(org.eclipse.jgit.lib.Config) Branch(com.google.gerrit.reviewdb.client.Branch) SubmoduleSubscription(com.google.gerrit.reviewdb.client.SubmoduleSubscription) SubmoduleSectionParser(com.google.gerrit.server.util.SubmoduleSectionParser) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 4 with SubmoduleSubscription

use of com.google.gerrit.reviewdb.client.SubmoduleSubscription in project gerrit by GerritCodeReview.

the class SubmoduleSectionParserIT method withAnotherURI.

@Test
public void withAnotherURI() throws Exception {
    Project.NameKey p = createProject("a");
    Config cfg = new Config();
    cfg.fromText("" + "[submodule \"a\"]\n" + "path = a\n" + "url = http://localhost:80/" + p.get() + "\n" + "branch = master\n");
    Branch.NameKey targetBranch = new Branch.NameKey(new Project.NameKey("project"), "master");
    Set<SubmoduleSubscription> res = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch).parseAllSections();
    Set<SubmoduleSubscription> expected = Sets.newHashSet(new SubmoduleSubscription(targetBranch, new Branch.NameKey(p, "master"), "a"));
    assertThat(res).containsExactlyElementsIn(expected);
}
Also used : Project(com.google.gerrit.reviewdb.client.Project) Config(org.eclipse.jgit.lib.Config) Branch(com.google.gerrit.reviewdb.client.Branch) SubmoduleSubscription(com.google.gerrit.reviewdb.client.SubmoduleSubscription) SubmoduleSectionParser(com.google.gerrit.server.util.SubmoduleSectionParser) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 5 with SubmoduleSubscription

use of com.google.gerrit.reviewdb.client.SubmoduleSubscription in project gerrit by GerritCodeReview.

the class SubmoduleSectionParserIT method followMatchingBranch.

@Test
public void followMatchingBranch() throws Exception {
    Project.NameKey p = createProject("a");
    Config cfg = new Config();
    cfg.fromText("" + "[submodule \"a\"]\n" + "path = a\n" + "url = ssh://localhost/" + p.get() + "\n" + "branch = .\n");
    Branch.NameKey targetBranch1 = new Branch.NameKey(new Project.NameKey("project"), "master");
    Set<SubmoduleSubscription> res1 = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch1).parseAllSections();
    Set<SubmoduleSubscription> expected1 = Sets.newHashSet(new SubmoduleSubscription(targetBranch1, new Branch.NameKey(p, "master"), "a"));
    assertThat(res1).containsExactlyElementsIn(expected1);
    Branch.NameKey targetBranch2 = new Branch.NameKey(new Project.NameKey("project"), "somebranch");
    Set<SubmoduleSubscription> res2 = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch2).parseAllSections();
    Set<SubmoduleSubscription> expected2 = Sets.newHashSet(new SubmoduleSubscription(targetBranch2, new Branch.NameKey(p, "somebranch"), "a"));
    assertThat(res2).containsExactlyElementsIn(expected2);
}
Also used : Project(com.google.gerrit.reviewdb.client.Project) Config(org.eclipse.jgit.lib.Config) Branch(com.google.gerrit.reviewdb.client.Branch) SubmoduleSubscription(com.google.gerrit.reviewdb.client.SubmoduleSubscription) SubmoduleSectionParser(com.google.gerrit.server.util.SubmoduleSectionParser) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

SubmoduleSubscription (com.google.gerrit.reviewdb.client.SubmoduleSubscription)21 Branch (com.google.gerrit.reviewdb.client.Branch)18 Project (com.google.gerrit.reviewdb.client.Project)17 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)14 SubmoduleSectionParser (com.google.gerrit.server.util.SubmoduleSectionParser)14 Config (org.eclipse.jgit.lib.Config)14 Test (org.junit.Test)14 OpenRepo (com.google.gerrit.server.git.MergeOpRepoManager.OpenRepo)3 NoSuchProjectException (com.google.gerrit.server.project.NoSuchProjectException)3 IOException (java.io.IOException)3 ObjectId (org.eclipse.jgit.lib.ObjectId)3 ArrayList (java.util.ArrayList)2 DirCache (org.eclipse.jgit.dircache.DirCache)2 DirCacheEditor (org.eclipse.jgit.dircache.DirCacheEditor)2 CommitBuilder (org.eclipse.jgit.lib.CommitBuilder)2 SubscribeSection (com.google.gerrit.common.data.SubscribeSection)1 GerritPersonIdent (com.google.gerrit.server.GerritPersonIdent)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 HashSet (java.util.HashSet)1