Search in sources :

Example 16 with SubmoduleSubscription

use of com.google.gerrit.entities.SubmoduleSubscription in project gerrit by GerritCodeReview.

the class SubmoduleSectionParserTest method withSectionOfNonexistingProject.

@Test
public void withSectionOfNonexistingProject() throws Exception {
    Config cfg = new Config();
    cfg.fromText("\n" + "[submodule \"a\"]\n" + "path = a\n" + "url = ssh://non-localhost/a\n" + // Project "a" doesn't exist
    "branch = .\\n");
    BranchNameKey targetBranch = BranchNameKey.create(Project.nameKey("project"), "master");
    Set<SubmoduleSubscription> res = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch).parseAllSections();
    assertThat(res).isEmpty();
}
Also used : BranchNameKey(com.google.gerrit.entities.BranchNameKey) Config(org.eclipse.jgit.lib.Config) SubmoduleSubscription(com.google.gerrit.entities.SubmoduleSubscription) Test(org.junit.Test)

Example 17 with SubmoduleSubscription

use of com.google.gerrit.entities.SubmoduleSubscription in project gerrit by GerritCodeReview.

the class SubmoduleSectionParserTest method withOverlyDeepRelativeURI.

@Test
public void withOverlyDeepRelativeURI() throws Exception {
    Project.NameKey p1 = Project.nameKey("nested/a");
    Config cfg = new Config();
    cfg.fromText("" + "[submodule \"a\"]\n" + "path = a\n" + "url = ../../" + p1.get() + "\n" + "branch = master\n");
    BranchNameKey targetBranch = BranchNameKey.create(Project.nameKey("nested/project"), "master");
    Set<SubmoduleSubscription> res = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch).parseAllSections();
    Set<SubmoduleSubscription> expected = Sets.newHashSet(new SubmoduleSubscription(targetBranch, BranchNameKey.create(p1, "master"), "a"));
    assertThat(res).containsExactlyElementsIn(expected);
}
Also used : Project(com.google.gerrit.entities.Project) BranchNameKey(com.google.gerrit.entities.BranchNameKey) Config(org.eclipse.jgit.lib.Config) SubmoduleSubscription(com.google.gerrit.entities.SubmoduleSubscription) Test(org.junit.Test)

Example 18 with SubmoduleSubscription

use of com.google.gerrit.entities.SubmoduleSubscription in project gerrit by GerritCodeReview.

the class SubmoduleSectionParserTest method followAnotherBranch.

@Test
public void followAnotherBranch() throws Exception {
    Project.NameKey p = Project.nameKey("a");
    Config cfg = new Config();
    cfg.fromText("" + "[submodule \"a\"]\n" + "path = a\n" + "url = ssh://localhost/" + p.get() + "\n" + "branch = anotherbranch\n");
    BranchNameKey targetBranch = BranchNameKey.create(Project.nameKey("project"), "master");
    Set<SubmoduleSubscription> res = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch).parseAllSections();
    Set<SubmoduleSubscription> expected = Sets.newHashSet(new SubmoduleSubscription(targetBranch, BranchNameKey.create(p, "anotherbranch"), "a"));
    assertThat(res).containsExactlyElementsIn(expected);
}
Also used : Project(com.google.gerrit.entities.Project) BranchNameKey(com.google.gerrit.entities.BranchNameKey) Config(org.eclipse.jgit.lib.Config) SubmoduleSubscription(com.google.gerrit.entities.SubmoduleSubscription) Test(org.junit.Test)

Example 19 with SubmoduleSubscription

use of com.google.gerrit.entities.SubmoduleSubscription in project gerrit by GerritCodeReview.

the class SubmoduleSectionParserTest method withRelativeURI.

@Test
public void withRelativeURI() throws Exception {
    Project.NameKey p1 = Project.nameKey("a");
    Config cfg = new Config();
    cfg.fromText("" + "[submodule \"a\"]\n" + "path = a\n" + "url = ../" + p1.get() + "\n" + "branch = master\n");
    BranchNameKey targetBranch = BranchNameKey.create(Project.nameKey("project"), "master");
    Set<SubmoduleSubscription> res = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch).parseAllSections();
    Set<SubmoduleSubscription> expected = Sets.newHashSet(new SubmoduleSubscription(targetBranch, BranchNameKey.create(p1, "master"), "a"));
    assertThat(res).containsExactlyElementsIn(expected);
}
Also used : Project(com.google.gerrit.entities.Project) BranchNameKey(com.google.gerrit.entities.BranchNameKey) Config(org.eclipse.jgit.lib.Config) SubmoduleSubscription(com.google.gerrit.entities.SubmoduleSubscription) Test(org.junit.Test)

Example 20 with SubmoduleSubscription

use of com.google.gerrit.entities.SubmoduleSubscription in project gerrit by GerritCodeReview.

the class SubmoduleSectionParserTest method withSlashesInPath.

@Test
public void withSlashesInPath() throws Exception {
    Project.NameKey p = Project.nameKey("a");
    Config cfg = new Config();
    cfg.fromText("" + "[submodule \"a\"]\n" + "path = a/b/c/d/e\n" + "url = http://localhost:80/" + p.get() + "\n" + "branch = master\n");
    BranchNameKey targetBranch = BranchNameKey.create(Project.nameKey("project"), "master");
    Set<SubmoduleSubscription> res = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch).parseAllSections();
    Set<SubmoduleSubscription> expected = Sets.newHashSet(new SubmoduleSubscription(targetBranch, BranchNameKey.create(p, "master"), "a/b/c/d/e"));
    assertThat(res).containsExactlyElementsIn(expected);
}
Also used : Project(com.google.gerrit.entities.Project) BranchNameKey(com.google.gerrit.entities.BranchNameKey) Config(org.eclipse.jgit.lib.Config) SubmoduleSubscription(com.google.gerrit.entities.SubmoduleSubscription) Test(org.junit.Test)

Aggregations

SubmoduleSubscription (com.google.gerrit.entities.SubmoduleSubscription)22 BranchNameKey (com.google.gerrit.entities.BranchNameKey)18 Test (org.junit.Test)18 Project (com.google.gerrit.entities.Project)16 Config (org.eclipse.jgit.lib.Config)16 CodeReviewCommit (com.google.gerrit.server.git.CodeReviewCommit)4 ObjectId (org.eclipse.jgit.lib.ObjectId)4 RevCommit (org.eclipse.jgit.revwalk.RevCommit)3 StorageException (com.google.gerrit.exceptions.StorageException)2 NoSuchProjectException (com.google.gerrit.server.project.NoSuchProjectException)2 OpenRepo (com.google.gerrit.server.submit.MergeOpRepoManager.OpenRepo)2 DefaultFactory (com.google.gerrit.server.submit.SubscriptionGraph.DefaultFactory)2 IOException (java.io.IOException)2 DirCache (org.eclipse.jgit.dircache.DirCache)2 DirCacheEditor (org.eclipse.jgit.dircache.DirCacheEditor)2 AnyObjectId (org.eclipse.jgit.lib.AnyObjectId)2 CommitBuilder (org.eclipse.jgit.lib.CommitBuilder)2 GerritPersonIdent (com.google.gerrit.server.GerritPersonIdent)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1