use of org.eclipse.jgit.internal.storage.file.FileRepository in project gerrit by GerritCodeReview.
the class ConvertRefStorage method run.
@Override
public void run() throws Exception {
enableGracefulStop();
Project.NameKey projectName = projectState.getNameKey();
try (Repository repo = repoManager.openRepository(projectName)) {
if (repo instanceof DelegateRepository) {
((DelegateRepository) repo).convertRefStorage(storageFormat.name(), writeLogs, backup);
} else {
checkState(repo instanceof FileRepository, "Repository is not an instance of FileRepository!");
((FileRepository) repo).convertRefStorage(storageFormat.name(), writeLogs, backup);
}
} catch (RepositoryNotFoundException e) {
throw die("'" + projectName + "': not a git archive", e);
} catch (IOException e) {
throw die("Error converting: '" + projectName + "': " + e.getMessage(), e);
}
}
use of org.eclipse.jgit.internal.storage.file.FileRepository in project gerrit by GerritCodeReview.
the class CommitRewriter method newPackInserter.
private static ObjectInserter newPackInserter(Repository repo) {
if (!(repo instanceof FileRepository)) {
return repo.newObjectInserter();
}
PackInserter ins = ((FileRepository) repo).getObjectDatabase().newPackInserter();
ins.checkExisting(false);
return ins;
}
use of org.eclipse.jgit.internal.storage.file.FileRepository in project gerrit by GerritCodeReview.
the class GroupsOnInit method getExistingGroup.
/**
* Returns the {@code AccountGroup} for the specified {@code GroupReference}.
*
* @param groupReference the {@code GroupReference} of the group
* @return the {@code InternalGroup} represented by the {@code GroupReference}
* @throws IOException if an error occurs while reading from NoteDb
* @throws ConfigInvalidException if the data in NoteDb is in an incorrect format
* @throws NoSuchGroupException if a group with such a name doesn't exist
*/
public InternalGroup getExistingGroup(GroupReference groupReference) throws NoSuchGroupException, IOException, ConfigInvalidException {
File allUsersRepoPath = getPathToAllUsersRepository();
if (allUsersRepoPath != null) {
try (Repository allUsersRepo = new FileRepository(allUsersRepoPath)) {
AccountGroup.UUID groupUuid = groupReference.getUUID();
GroupConfig groupConfig = GroupConfig.loadForGroup(allUsers, allUsersRepo, groupUuid);
return groupConfig.getLoadedGroup().orElseThrow(() -> new NoSuchGroupException(groupReference.getUUID()));
}
}
throw new NoSuchGroupException(groupReference.getUUID());
}
use of org.eclipse.jgit.internal.storage.file.FileRepository in project gerrit by GerritCodeReview.
the class ExternalIdsOnInit method insert.
public synchronized void insert(String commitMessage, Collection<ExternalId> extIds) throws IOException, ConfigInvalidException {
File path = getPath();
if (path != null) {
try (Repository allUsersRepo = new FileRepository(path)) {
ExternalIdNotes extIdNotes = ExternalIdNotes.load(allUsers, allUsersRepo, externalIdFactory, authConfig.isUserNameCaseInsensitiveMigrationMode());
extIdNotes.insert(extIds);
try (MetaDataUpdate metaDataUpdate = new MetaDataUpdate(GitReferenceUpdated.DISABLED, allUsers, allUsersRepo)) {
PersonIdent serverIdent = new GerritPersonIdentProvider(flags.cfg).get();
metaDataUpdate.getCommitBuilder().setAuthor(serverIdent);
metaDataUpdate.getCommitBuilder().setCommitter(serverIdent);
metaDataUpdate.getCommitBuilder().setMessage(commitMessage);
extIdNotes.commit(metaDataUpdate);
}
}
}
}
use of org.eclipse.jgit.internal.storage.file.FileRepository in project gerrit by GerritCodeReview.
the class AllProjectsConfigTest method noBaseConfig.
@Test
public void noBaseConfig() throws Exception {
assertThat(getConfig().getString("foo", null, "bar")).isNull();
try (Repository repo = new FileRepository(allProjectsRepoFile);
TestRepository<Repository> tr = new TestRepository<>(repo)) {
tr.branch("refs/meta/config").commit().add("project.config", "[foo]\nbar = baz").create();
}
assertThat(getConfig().getString("foo", null, "bar")).isEqualTo("baz");
}
Aggregations