Search in sources :

Example 16 with SubmoduleSubscription

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

the class SubmoduleSectionParserIT method withMoreSections.

@Test
public void withMoreSections() throws Exception {
    Project.NameKey p1 = createProject("a");
    Project.NameKey p2 = createProject("b");
    Config cfg = new Config();
    cfg.fromText("" + "[submodule \"a\"]\n" + "     path = a\n" + "     url = ssh://localhost/" + p1.get() + "\n" + "     branch = .\n" + "[submodule \"b\"]\n" + "		path = b\n" + "		url = http://localhost:80/" + p2.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(p1, "master"), "a"), new SubmoduleSubscription(targetBranch, new Branch.NameKey(p2, "master"), "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 17 with SubmoduleSubscription

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

the class SubmoduleSectionParserIT method followAnotherBranch.

@Test
public void followAnotherBranch() 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 = anotherbranch\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, "anotherbranch"), "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 18 with SubmoduleSubscription

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

the class SubmoduleSectionParserIT method withAnInvalidSection.

@Test
public void withAnInvalidSection() throws Exception {
    Project.NameKey p1 = createProject("a");
    Project.NameKey p2 = createProject("b");
    Project.NameKey p3 = createProject("d");
    Project.NameKey p4 = createProject("e");
    Config cfg = new Config();
    cfg.fromText("\n" + "[submodule \"a\"]\n" + "    path = a\n" + "    url = ssh://localhost/" + p1.get() + "\n" + "    branch = .\n" + "[submodule \"b\"]\n" + // path missing
    "    url = http://localhost:80/" + p2.get() + "\n" + "    branch = master\n" + "[submodule \"c\"]\n" + "    path = c\n" + // url missing
    "    branch = .\n" + "[submodule \"d\"]\n" + "    path = d-parent/the-d-folder\n" + "    url = ssh://localhost/" + p3.get() + "\n" + // branch missing
    "[submodule \"e\"]\n" + "    path = e\n" + "    url = ssh://localhost/" + p4.get() + "\n" + "    branch = refs/heads/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(p1, "master"), "a"), new SubmoduleSubscription(targetBranch, new Branch.NameKey(p4, "master"), "e"));
    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 19 with SubmoduleSubscription

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

the class GitModules method subscribedTo.

public Collection<SubmoduleSubscription> subscribedTo(Branch.NameKey src) {
    logDebug("Checking for a subscription of " + src);
    Collection<SubmoduleSubscription> ret = new ArrayList<>();
    for (SubmoduleSubscription s : subscriptions) {
        if (s.getSubmodule().equals(src)) {
            logDebug("Found " + s);
            ret.add(s);
        }
    }
    return ret;
}
Also used : ArrayList(java.util.ArrayList) SubmoduleSubscription(com.google.gerrit.reviewdb.client.SubmoduleSubscription)

Example 20 with SubmoduleSubscription

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

the class SubmoduleOp method searchForSuperprojects.

private void searchForSuperprojects(Branch.NameKey current, LinkedHashSet<Branch.NameKey> currentVisited, LinkedHashSet<Branch.NameKey> allVisited) throws SubmoduleException {
    logDebug("Now processing " + current);
    if (currentVisited.contains(current)) {
        throw new SubmoduleException("Branch level circular subscriptions detected:  " + printCircularPath(currentVisited, current));
    }
    if (allVisited.contains(current)) {
        return;
    }
    currentVisited.add(current);
    try {
        Collection<SubmoduleSubscription> subscriptions = superProjectSubscriptionsForSubmoduleBranch(current);
        for (SubmoduleSubscription sub : subscriptions) {
            Branch.NameKey superBranch = sub.getSuperProject();
            searchForSuperprojects(superBranch, currentVisited, allVisited);
            targets.put(superBranch, sub);
            branchesByProject.put(superBranch.getParentKey(), superBranch);
            affectedBranches.add(superBranch);
            affectedBranches.add(sub.getSubmodule());
        }
    } catch (IOException e) {
        throw new SubmoduleException("Cannot find superprojects for " + current, e);
    }
    currentVisited.remove(current);
    allVisited.add(current);
}
Also used : Branch(com.google.gerrit.reviewdb.client.Branch) SubmoduleSubscription(com.google.gerrit.reviewdb.client.SubmoduleSubscription) IOException(java.io.IOException)

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