本文整理汇总了Java中org.eclipse.jgit.errors.RepositoryNotFoundException类的典型用法代码示例。如果您正苦于以下问题:Java RepositoryNotFoundException类的具体用法?Java RepositoryNotFoundException怎么用?Java RepositoryNotFoundException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RepositoryNotFoundException类属于org.eclipse.jgit.errors包,在下文中一共展示了RepositoryNotFoundException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createGitServlet
import org.eclipse.jgit.errors.RepositoryNotFoundException; //导入依赖的package包/类
private GitServlet createGitServlet() {
final GitServlet gitServlet = new GitServlet();
gitServlet.setRepositoryResolver((req, name) -> {
String trimmedName = name.endsWith(SUFFIX) ? name.substring(0, name.length() - SUFFIX.length()) : name;
trimmedName = trimmedName.substring(trimmedName.lastIndexOf('/') + 1);
if (repositories.containsKey(trimmedName)) {
final LazilyLoadedRepository lazilyLoadedRepository = repositories.get(trimmedName);
synchronized (gitServlet) {
lazilyLoadedRepository.cloneRepository();
final Repository repository = lazilyLoadedRepository.get();
enableInsecureReceiving(repository);
repository.incrementOpen();
return repository;
}
} else {
throw new RepositoryNotFoundException("Repository " + name + "does not exist");
}
});
gitServlet.addReceivePackFilter(new AfterReceivePackResetFilter(repositories.values()));
return gitServlet;
}
示例2: prepare
import org.eclipse.jgit.errors.RepositoryNotFoundException; //导入依赖的package包/类
public static BackupService prepare(File localDir, URIish remoteUri) throws GitAPIException, IOException {
Git local;
try {
local = Git.open(localDir);
} catch (RepositoryNotFoundException e) {
log.info("Initialising " + fullPath(localDir) + " as a git repo for backup purposes");
local = Git.init().setDirectory(localDir).setBare(false).call();
}
log.info("Setting backup URL to " + remoteUri);
if (local.remoteList().call().stream().anyMatch(remoteConfig -> remoteConfig.getName().equals("origin"))) {
RemoteSetUrlCommand remoteSetUrlCommand = local.remoteSetUrl();
remoteSetUrlCommand.setName("origin");
remoteSetUrlCommand.setUri(remoteUri);
remoteSetUrlCommand.call();
} else {
RemoteAddCommand remoteAddCommand = local.remoteAdd();
remoteAddCommand.setName("origin");
remoteAddCommand.setUri(remoteUri);
remoteAddCommand.call();
}
URL inputUrl = BackupService.class.getResource("/dataDirGitIgnore.txt");
FileUtils.copyURLToFile(inputUrl, new File(localDir, ".gitignore"));
return new BackupService(local, remoteUri.toString());
}
示例3: newGit
import org.eclipse.jgit.errors.RepositoryNotFoundException; //导入依赖的package包/类
public Git newGit() throws SCMException {
final File gitDir = new File(".");
try {
return Git.open(gitDir);
} catch (final RepositoryNotFoundException rnfe) {
final String fullPathOfCurrentDir = pathOf(gitDir);
final File gitRoot = getGitRootIfItExistsInOneOfTheParentDirectories(new File(fullPathOfCurrentDir));
if (gitRoot == null) {
throw new SCMException("Releases can only be performed from Git repositories.")
.add("%s is not a Git repository.", fullPathOfCurrentDir);
}
throw new SCMException("The release plugin can only be run from the root folder of your Git repository")
.add("%s is not the root of a Gir repository", fullPathOfCurrentDir)
.add("Try running the release plugin from %s", pathOf(gitRoot));
} catch (final Exception e) {
throw new SCMException("Could not open git repository. Is %s a git repository?", pathOf(gitDir))
.add("Exception returned when accessing the git repo: %s", e.toString());
}
}
示例4: open
import org.eclipse.jgit.errors.RepositoryNotFoundException; //导入依赖的package包/类
@Override
public Repository open(DaemonClient client, String name)
throws RepositoryNotFoundException,
ServiceNotAuthorizedException, ServiceNotEnabledException,
ServiceMayNotContinueException {
CassandraRepository repo = repositories.get(name);
if (repo == null) {
try {
repo = new CassandraRepository(
new DfsRepositoryDescription(sanitiseName(name)),
storeconn);
} catch (Exception e) {
throw new ServiceMayNotContinueException(e);
}
repositories.put(name, repo);
}
return repo;
}
示例5: grant
import org.eclipse.jgit.errors.RepositoryNotFoundException; //导入依赖的package包/类
protected void grant(
Project.NameKey project,
String ref,
String permission,
boolean force,
AccountGroup.UUID groupUUID)
throws RepositoryNotFoundException, IOException, ConfigInvalidException {
try (MetaDataUpdate md = metaDataUpdateFactory.create(project)) {
md.setMessage(String.format("Grant %s on %s", permission, ref));
ProjectConfig config = ProjectConfig.read(md);
AccessSection s = config.getAccessSection(ref, true);
Permission p = s.getPermission(permission, true);
PermissionRule rule = Util.newRule(config, groupUUID);
rule.setForce(force);
p.add(rule);
config.commit(md);
projectCache.evict(config.getProject());
}
}
示例6: grantLabel
import org.eclipse.jgit.errors.RepositoryNotFoundException; //导入依赖的package包/类
protected void grantLabel(
String label,
int min,
int max,
Project.NameKey project,
String ref,
boolean force,
AccountGroup.UUID groupUUID,
boolean exclusive)
throws RepositoryNotFoundException, IOException, ConfigInvalidException {
String permission = Permission.LABEL + label;
try (MetaDataUpdate md = metaDataUpdateFactory.create(project)) {
md.setMessage(String.format("Grant %s on %s", permission, ref));
ProjectConfig config = ProjectConfig.read(md);
AccessSection s = config.getAccessSection(ref, true);
Permission p = s.getPermission(permission, true);
p.setExclusiveGroup(exclusive);
PermissionRule rule = Util.newRule(config, groupUUID);
rule.setForce(force);
rule.setMin(min);
rule.setMax(max);
p.add(rule);
config.commit(md);
projectCache.evict(config.getProject());
}
}
示例7: service
import org.eclipse.jgit.errors.RepositoryNotFoundException; //导入依赖的package包/类
private void service() throws IOException, PermissionBackendException, Failure {
project = projectState.getProject();
projectName = project.getNameKey();
try {
repo = repoManager.openRepository(projectName);
} catch (RepositoryNotFoundException e) {
throw new Failure(1, "fatal: '" + project.getName() + "': not a git archive", e);
}
try {
runImpl();
} finally {
repo.close();
}
}
示例8: checkedGet
import org.eclipse.jgit.errors.RepositoryNotFoundException; //导入依赖的package包/类
@Override
public ProjectState checkedGet(Project.NameKey projectName) throws IOException {
if (projectName == null) {
return null;
}
try {
ProjectState state = byName.get(projectName.get());
if (state != null && state.needsRefresh(clock.read())) {
byName.invalidate(projectName.get());
state = byName.get(projectName.get());
}
return state;
} catch (ExecutionException e) {
if (!(e.getCause() instanceof RepositoryNotFoundException)) {
log.warn(String.format("Cannot read project %s", projectName.get()), e);
Throwables.throwIfInstanceOf(e.getCause(), IOException.class);
throw new IOException(e);
}
return null;
}
}
示例9: parse
import org.eclipse.jgit.errors.RepositoryNotFoundException; //导入依赖的package包/类
@Override
public BranchResource parse(ProjectResource parent, IdString id)
throws ResourceNotFoundException, IOException, PermissionBackendException {
Project.NameKey project = parent.getNameKey();
try (Repository repo = repoManager.openRepository(project)) {
Ref ref = repo.exactRef(RefNames.fullName(id.get()));
if (ref == null) {
throw new ResourceNotFoundException(id);
}
// ListBranches checks the target of a symbolic reference to determine access
// rights on the symbolic reference itself. This check prevents seeing a hidden
// branch simply because the symbolic reference name was visible.
permissionBackend
.user(user)
.project(project)
.ref(ref.isSymbolic() ? ref.getTarget().getName() : ref.getName())
.check(RefPermission.READ);
return new BranchResource(parent.getProjectState(), parent.getUser(), ref);
} catch (AuthException notAllowed) {
throw new ResourceNotFoundException(id);
} catch (RepositoryNotFoundException noRepo) {
throw new ResourceNotFoundException();
}
}
示例10: scan
import org.eclipse.jgit.errors.RepositoryNotFoundException; //导入依赖的package包/类
private List<DashboardInfo> scan(ProjectState state, String project, boolean setDefault)
throws ResourceNotFoundException, IOException, PermissionBackendException {
PermissionBackend.ForProject perm = permissionBackend.user(user).project(state.getNameKey());
try (Repository git = gitManager.openRepository(state.getNameKey());
RevWalk rw = new RevWalk(git)) {
List<DashboardInfo> all = new ArrayList<>();
for (Ref ref : git.getRefDatabase().getRefs(REFS_DASHBOARDS).values()) {
if (perm.ref(ref.getName()).test(RefPermission.READ)) {
all.addAll(scanDashboards(state.getProject(), git, rw, ref, project, setDefault));
}
}
return all;
} catch (RepositoryNotFoundException e) {
throw new ResourceNotFoundException();
}
}
示例11: allBranches
import org.eclipse.jgit.errors.RepositoryNotFoundException; //导入依赖的package包/类
private List<BranchInfo> allBranches(ProjectResource rsrc)
throws IOException, ResourceNotFoundException, PermissionBackendException {
List<Ref> refs;
try (Repository db = repoManager.openRepository(rsrc.getNameKey())) {
Collection<Ref> heads = db.getRefDatabase().getRefs(Constants.R_HEADS).values();
refs = new ArrayList<>(heads.size() + 3);
refs.addAll(heads);
refs.addAll(
db.getRefDatabase()
.exactRef(Constants.HEAD, RefNames.REFS_CONFIG, RefNames.REFS_USERS_DEFAULT)
.values());
} catch (RepositoryNotFoundException noGitRepository) {
throw new ResourceNotFoundException();
}
return toBranchInfo(rsrc, refs);
}
示例12: getRepo
import org.eclipse.jgit.errors.RepositoryNotFoundException; //导入依赖的package包/类
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);
}
}
示例13: loadCommitData
import org.eclipse.jgit.errors.RepositoryNotFoundException; //导入依赖的package包/类
private boolean loadCommitData()
throws OrmException, RepositoryNotFoundException, IOException, MissingObjectException,
IncorrectObjectTypeException {
PatchSet ps = currentPatchSet();
if (ps == null) {
return false;
}
String sha1 = ps.getRevision().get();
try (Repository repo = repoManager.openRepository(project());
RevWalk walk = new RevWalk(repo)) {
RevCommit c = walk.parseCommit(ObjectId.fromString(sha1));
commitMessage = c.getFullMessage();
commitFooters = c.getFooterLines();
author = c.getAuthorIdent();
committer = c.getCommitterIdent();
parentCount = c.getParentCount();
}
return true;
}
示例14: ensureRebuilt
import org.eclipse.jgit.errors.RepositoryNotFoundException; //导入依赖的package包/类
private NoteDbChangeState ensureRebuilt(
Project.NameKey project, Change.Id id, NoteDbChangeState readOnlyState)
throws IOException, OrmException, RepositoryNotFoundException {
try (Repository changeRepo = repoManager.openRepository(project);
Repository allUsersRepo = repoManager.openRepository(allUsers)) {
if (!readOnlyState.isUpToDate(new RepoRefCache(changeRepo), new RepoRefCache(allUsersRepo))) {
NoteDbUpdateManager.Result r = rebuilder.rebuildEvenIfReadOnly(db(), id);
checkState(
r.newState().getReadOnlyUntil().equals(readOnlyState.getReadOnlyUntil()),
"state after rebuilding has different read-only lease: %s != %s",
r.newState(),
readOnlyState);
readOnlyState = r.newState();
}
}
return readOnlyState;
}
示例15: writeToGit
import org.eclipse.jgit.errors.RepositoryNotFoundException; //导入依赖的package包/类
private void writeToGit(Account.Id id, GeneralPreferencesInfo i)
throws RepositoryNotFoundException, IOException, ConfigInvalidException {
VersionedAccountPreferences prefs;
try (MetaDataUpdate md = metaDataUpdateFactory.get().create(allUsersName)) {
prefs = VersionedAccountPreferences.forUser(id);
prefs.load(md);
storeSection(
prefs.getConfig(),
UserConfigSections.GENERAL,
null,
i,
loader.readDefaultsFromGit(md.getRepository(), null));
storeMyChangeTableColumns(prefs, i.changeTable);
storeMyMenus(prefs, i.my);
storeUrlAliases(prefs, i.urlAliases);
prefs.commit(md);
cache.evict(id);
}
}