use of com.google.gerrit.server.project.ProjectState in project gerrit by GerritCodeReview.
the class CreateProjectIT method withValidGroupName.
@Test
public void withValidGroupName() throws Exception {
String newGroupName = "newGroup";
adminRestSession.put("/groups/" + newGroupName);
String newProjectName = "newProject";
adminSshSession.exec("gerrit create-project --branch master --owner " + newGroupName + " " + newProjectName);
assert_().withFailureMessage(adminSshSession.getError()).that(adminSshSession.hasError()).isFalse();
ProjectState projectState = projectCache.get(new Project.NameKey(newProjectName));
assertThat(projectState).isNotNull();
}
use of com.google.gerrit.server.project.ProjectState in project gerrit by GerritCodeReview.
the class CreateProjectIT method withInvalidGroupName.
@Test
public void withInvalidGroupName() throws Exception {
String newGroupName = "newGroup";
adminRestSession.put("/groups/" + newGroupName);
String wrongGroupName = "newG";
String newProjectName = "newProject";
adminSshSession.exec("gerrit create-project --branch master --owner " + wrongGroupName + " " + newProjectName);
assert_().withFailureMessage(adminSshSession.getError()).that(adminSshSession.hasError()).isTrue();
ProjectState projectState = projectCache.get(new Project.NameKey(newProjectName));
assertThat(projectState).isNull();
}
use of com.google.gerrit.server.project.ProjectState in project gerrit by GerritCodeReview.
the class MergeOpRepoManager method getRepo.
public OpenRepo getRepo(Project.NameKey project) throws NoSuchProjectException, IOException {
if (openRepos.containsKey(project)) {
return openRepos.get(project);
}
ProjectState projectState = projectCache.get(project);
if (projectState == null) {
throw new NoSuchProjectException(project);
}
try {
OpenRepo or = new OpenRepo(repoManager.openRepository(project), projectState);
openRepos.put(project, or);
return or;
} catch (RepositoryNotFoundException e) {
throw new NoSuchProjectException(project, e);
}
}
use of com.google.gerrit.server.project.ProjectState in project gerrit by GerritCodeReview.
the class FixReplacementInterpreter method toTreeModifications.
/**
* Transforms the given {@code FixReplacement}s into {@code TreeModification}s.
*
* @param repository the affected Git repository
* @param projectState the affected project
* @param patchSetCommitId the patch set which should be modified
* @param fixReplacements the replacements which should be applied
* @return a list of {@code TreeModification}s representing the given replacements
* @throws ResourceNotFoundException if a file to which one of the replacements refers doesn't
* exist
* @throws ResourceConflictException if the replacements can't be transformed into {@code
* TreeModification}s
*/
public List<TreeModification> toTreeModifications(Repository repository, ProjectState projectState, ObjectId patchSetCommitId, List<FixReplacement> fixReplacements) throws ResourceNotFoundException, IOException, ResourceConflictException {
checkNotNull(fixReplacements, "Fix replacements must not be null");
Map<String, List<FixReplacement>> fixReplacementsPerFilePath = fixReplacements.stream().collect(Collectors.groupingBy(fixReplacement -> fixReplacement.path));
List<TreeModification> treeModifications = new ArrayList<>();
for (Map.Entry<String, List<FixReplacement>> entry : fixReplacementsPerFilePath.entrySet()) {
TreeModification treeModification = toTreeModification(repository, projectState, patchSetCommitId, entry.getKey(), entry.getValue());
treeModifications.add(treeModification);
}
return treeModifications;
}
use of com.google.gerrit.server.project.ProjectState in project gerrit by GerritCodeReview.
the class EventBroker method isVisibleTo.
protected boolean isVisibleTo(Branch.NameKey branchName, CurrentUser user) {
ProjectState pe = projectCache.get(branchName.getParentKey());
if (pe == null) {
return false;
}
ProjectControl pc = pe.controlFor(user);
return pc.controlForRef(branchName).isVisible();
}
Aggregations