Search in sources :

Example 51 with BranchNameKey

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

the class PermissionBackendConditionIT method refPermissions_sameResourceAndDifferentUserDoesNotEqual.

@Test
public void refPermissions_sameResourceAndDifferentUserDoesNotEqual() throws Exception {
    BranchNameKey branch = BranchNameKey.create(project, "branch");
    BooleanCondition cond1 = pb.user(user()).ref(branch).testCond(RefPermission.READ);
    BooleanCondition cond2 = pb.user(admin()).ref(branch).testCond(RefPermission.READ);
    assertNotEquals(cond1, cond2);
    assertNotEquals(cond1.hashCode(), cond2.hashCode());
}
Also used : BranchNameKey(com.google.gerrit.entities.BranchNameKey) BooleanCondition(com.google.gerrit.extensions.conditions.BooleanCondition) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 52 with BranchNameKey

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

the class SubmoduleCommitsTest method amendGitlinksCommit_subprojectMoved.

@Test
public void amendGitlinksCommit_subprojectMoved() throws Exception {
    createRepo(subProject, MASTER);
    createRepo(superProject, MASTER);
    when(mockProjectCache.get(any())).thenReturn(Optional.of(mockProjectState));
    mergeOpRepoManager = new MergeOpRepoManager(repoManager, mockProjectCache, null, null);
    ObjectId subprojectCommit = getTip(subProject, MASTER);
    CodeReviewCommit superprojectTip = directUpdateSubmodule(superProject, MASTER, Project.nameKey("dir-x"), subprojectCommit);
    assertThat(readGitLink(superProject, superprojectTip, "dir-x")).isEqualTo(subprojectCommit);
    RevCommit newSubprojectCommit = addCommit(subProject, MASTER);
    BranchNameKey superBranch = BranchNameKey.create(superProject, MASTER);
    BranchNameKey subBranch = BranchNameKey.create(subProject, MASTER);
    SubmoduleSubscription ss = new SubmoduleSubscription(superBranch, subBranch, "dir-x");
    SubmoduleCommits helper = new SubmoduleCommits(mergeOpRepoManager, ident, new Config());
    CodeReviewCommit amendedCommit = helper.amendGitlinksCommit(BranchNameKey.create(superProject, MASTER), superprojectTip, ImmutableList.of(ss));
    assertThat(amendedCommit.getParent(0)).isEqualTo(superprojectTip.getParent(0));
    assertThat(readGitLink(superProject, amendedCommit, "dir-x")).isEqualTo(newSubprojectCommit);
}
Also used : BranchNameKey(com.google.gerrit.entities.BranchNameKey) AnyObjectId(org.eclipse.jgit.lib.AnyObjectId) ObjectId(org.eclipse.jgit.lib.ObjectId) Config(org.eclipse.jgit.lib.Config) SubmoduleSubscription(com.google.gerrit.entities.SubmoduleSubscription) CodeReviewCommit(com.google.gerrit.server.git.CodeReviewCommit) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test)

Example 53 with BranchNameKey

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

the class SubmoduleSectionParserTest method followMasterBranch.

@Test
public void followMasterBranch() throws Exception {
    Project.NameKey p = Project.nameKey("proj");
    Config cfg = new Config();
    cfg.fromText("" + "[submodule \"a\"]\n" + "path = localpath-to-a\n" + "url = ssh://localhost/" + 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"), "localpath-to-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 54 with BranchNameKey

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

the class SubmoduleSectionParserTest method withAnInvalidSection.

@Test
public void withAnInvalidSection() throws Exception {
    Project.NameKey p1 = Project.nameKey("a");
    Project.NameKey p2 = Project.nameKey("b");
    Project.NameKey p3 = Project.nameKey("d");
    Project.NameKey p4 = Project.nameKey("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");
    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"), new SubmoduleSubscription(targetBranch, BranchNameKey.create(p4, "master"), "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)

Example 55 with BranchNameKey

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

the class SubmoduleSectionParserTest method withSectionToOtherServer.

@Test
public void withSectionToOtherServer() throws Exception {
    Project.NameKey p1 = Project.nameKey("a");
    Config cfg = new Config();
    cfg.fromText("" + "[submodule \"a\"]" + "path = a" + "url = ssh://non-localhost/" + p1.get() + "\n" + "branch = .");
    BranchNameKey targetBranch = BranchNameKey.create(Project.nameKey("project"), "master");
    Set<SubmoduleSubscription> res = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch).parseAllSections();
    assertThat(res).isEmpty();
}
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

BranchNameKey (com.google.gerrit.entities.BranchNameKey)75 Test (org.junit.Test)48 Project (com.google.gerrit.entities.Project)26 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)25 Config (org.eclipse.jgit.lib.Config)19 SubmoduleSubscription (com.google.gerrit.entities.SubmoduleSubscription)18 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)16 RevCommit (org.eclipse.jgit.revwalk.RevCommit)16 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)15 AuthException (com.google.gerrit.extensions.restapi.AuthException)13 Change (com.google.gerrit.entities.Change)12 IOException (java.io.IOException)11 ObjectId (org.eclipse.jgit.lib.ObjectId)11 StorageException (com.google.gerrit.exceptions.StorageException)10 ChangeData (com.google.gerrit.server.query.change.ChangeData)9 Repository (org.eclipse.jgit.lib.Repository)9 PatchSet (com.google.gerrit.entities.PatchSet)8 CodeReviewCommit (com.google.gerrit.server.git.CodeReviewCommit)8 HashMap (java.util.HashMap)7 Ref (org.eclipse.jgit.lib.Ref)7