public static Repository prepareBareRemote() throws IOException { // Create a folder in the temp folder that will act as the remote repository File remoteDir = File.createTempFile("remote", ""); remoteDir.delete(); remoteDir.mkdirs(); // Create a bare repository FileKey fileKey = FileKey.exact(remoteDir, FS.DETECTED); Repository remoteRepo = fileKey.open(false); remoteRepo.create(true); return remoteRepo; }
RepositoryCache.FileKey fileKey = RepositoryCache.FileKey.exact(new File(GIT_REMOTE_REPO_DIR), FS.DETECTED); fileKey.open(false).create(true);
RepositoryCache.FileKey fileKey = RepositoryCache.FileKey.exact(remoteDir, FS.DETECTED); this.remoteRepo = fileKey.open(false); this.remoteRepo.create(true);
public Repository createRepository(String name) throws RepositoryNotFoundException { if (isUnreasonableName(name)) { throw new RepositoryNotFoundException("Invalid name: " + name); } try { File dir = FileKey.resolve(gitDirOf(name), FS.DETECTED); FileKey loc; if (dir != null) { // Already exists on disk, use the repository we found. // loc = FileKey.exact(dir, FS.DETECTED); } else { // It doesn't exist under any of the standard permutations // of the repository name, so prefer the standard bare name. // if (!name.endsWith(Constants.DOT_GIT_EXT)) { name = name + Constants.DOT_GIT_EXT; } loc = FileKey.exact(new File(basePath, name), FS.DETECTED); } return RepositoryCache.open(loc, false); } catch (IOException e1) { final RepositoryNotFoundException e2; e2 = new RepositoryNotFoundException("Cannot open repository " + name); e2.initCause(e1); throw e2; } }
/** * Remove a repository from the cache. * <p> * Removes a repository from the cache, if it is still registered here. This * method will not close the repository, only remove it from the cache. See * {@link org.eclipse.jgit.lib.RepositoryCache#close(Repository)} to remove * and close the repository. * * @param db * repository to unregister. * @since 4.3 */ public static void unregister(Repository db) { if (db.getDirectory() != null) { unregister(FileKey.exact(db.getDirectory(), db.getFS())); } }
/** * Register one repository into the cache. * <p> * During registration the cache automatically increments the usage counter, * permitting it to retain the reference. A {@link FileKey} for the * repository's {@link Repository#getDirectory()} is used to index the * repository in the cache. * <p> * If another repository already is registered in the cache at this * location, the other instance is closed. * * @param db * repository to register. */ public static void register(final Repository db) { if (db.getDirectory() != null) { FileKey key = FileKey.exact(db.getDirectory(), db.getFS()); cache.registerRepository(key, db); } }
/** * Remove a repository from the cache. * <p> * Removes a repository from the cache, if it is still registered here. This * method will not close the repository, only remove it from the cache. See * {@link RepositoryCache#close(Repository)} to remove and close the * repository. * * @param db * repository to unregister. * @since 4.3 */ public static void unregister(final Repository db) { if (db.getDirectory() != null) { unregister(FileKey.exact(db.getDirectory(), db.getFS())); } }
/** * Register one repository into the cache. * <p> * During registration the cache automatically increments the usage counter, * permitting it to retain the reference. A * {@link org.eclipse.jgit.lib.RepositoryCache.FileKey} for the repository's * {@link org.eclipse.jgit.lib.Repository#getDirectory()} is used to index * the repository in the cache. * <p> * If another repository already is registered in the cache at this * location, the other instance is closed. * * @param db * repository to register. */ public static void register(Repository db) { if (db.getDirectory() != null) { FileKey key = FileKey.exact(db.getDirectory(), db.getFS()); cache.registerRepository(key, db); } }
/** * Close and remove a repository from the cache. * <p> * Removes a repository from the cache, if it is still registered here, and * close it. * * @param db * repository to unregister. */ public static void close(@NonNull final Repository db) { if (db.getDirectory() != null) { FileKey key = FileKey.exact(db.getDirectory(), db.getFS()); cache.unregisterAndCloseRepository(key, db); } }
/** * Close and remove a repository from the cache. * <p> * Removes a repository from the cache, if it is still registered here, and * close it. * * @param db * repository to unregister. */ public static void close(@NonNull Repository db) { if (db.getDirectory() != null) { FileKey key = FileKey.exact(db.getDirectory(), db.getFS()); cache.unregisterAndCloseRepository(key); } }
private AlternateHandle openAlternate(File objdir) throws IOException { final File parent = objdir.getParentFile(); if (FileKey.isGitRepository(parent, fs)) { FileKey key = FileKey.exact(parent, fs); FileRepository db = (FileRepository) RepositoryCache.open(key); return new AlternateRepository(db); } ObjectDirectory db = new ObjectDirectory(config, objdir, null, fs, null); return new AlternateHandle(db); }
public static Repository openRepository(File gitDir) throws Exception { gitDir = _getGitDir(gitDir); RepositoryCache.FileKey fileKey = RepositoryCache.FileKey.exact( gitDir, FS.DETECTED); return fileKey.open(true); }
private AlternateHandle openAlternate(File objdir) throws IOException { final File parent = objdir.getParentFile(); if (FileKey.isGitRepository(parent, fs)) { FileKey key = FileKey.exact(parent, fs); FileRepository db = (FileRepository) RepositoryCache.open(key); return new AlternateRepository(db); } ObjectDirectory db = new ObjectDirectory(config, objdir, null, fs, null); return new AlternateHandle(db); }
FileKey key = FileKey.exact(dir, FS.DETECTED); db = RepositoryCache.open(key, true); } catch (IOException e) {
/** * Register one repository into the cache. * <p> * During registration the cache automatically increments the usage counter, * permitting it to retain the reference. A * {@link org.eclipse.jgit.lib.RepositoryCache.FileKey} for the repository's * {@link org.eclipse.jgit.lib.Repository#getDirectory()} is used to index * the repository in the cache. * <p> * If another repository already is registered in the cache at this * location, the other instance is closed. * * @param db * repository to register. */ public static void register(Repository db) { if (db.getDirectory() != null) { FileKey key = FileKey.exact(db.getDirectory(), db.getFS()); cache.registerRepository(key, db); } }
/** * Remove a repository from the cache. * <p> * Removes a repository from the cache, if it is still registered here. This * method will not close the repository, only remove it from the cache. See * {@link org.eclipse.jgit.lib.RepositoryCache#close(Repository)} to remove * and close the repository. * * @param db * repository to unregister. * @since 4.3 */ public static void unregister(Repository db) { if (db.getDirectory() != null) { unregister(FileKey.exact(db.getDirectory(), db.getFS())); } }
/** * Close and remove a repository from the cache. * <p> * Removes a repository from the cache, if it is still registered here, and * close it. * * @param db * repository to unregister. */ public static void close(@NonNull Repository db) { if (db.getDirectory() != null) { FileKey key = FileKey.exact(db.getDirectory(), db.getFS()); cache.unregisterAndCloseRepository(key); } }
private AlternateHandle openAlternate(File objdir) throws IOException { final File parent = objdir.getParentFile(); if (FileKey.isGitRepository(parent, fs)) { FileKey key = FileKey.exact(parent, fs); FileRepository db = (FileRepository) RepositoryCache.open(key); return new AlternateRepository(db); } ObjectDirectory db = new ObjectDirectory(config, objdir, null, fs, null); return new AlternateHandle(db); }
RepositoryCache.FileKey fileKey = RepositoryCache.FileKey.exact(remoteDir, FS.DETECTED); Repository remoteRepo = fileKey.open(false); remoteRepo.create(true);
@BeforeClass public void setup() throws Exception { cleanUpDir(TEST_DIR); // Create a bare repository RepositoryCache.FileKey fileKey = RepositoryCache.FileKey.exact(remoteDir, FS.DETECTED); this.remoteRepo = fileKey.open(false); this.remoteRepo.create(true); this.gitForPush = Git.cloneRepository().setURI(this.remoteRepo.getDirectory().getAbsolutePath()).setDirectory(cloneDir).call(); // push an empty commit as a base for detecting changes this.gitForPush.commit().setMessage("First commit").call(); this.gitForPush.push().setRemote("origin").setRefSpecs(this.masterRefSpec).call(); this.config = ConfigBuilder.create() .addPrimitive(GitConfigMonitor.GIT_CONFIG_MONITOR_PREFIX + "." + ConfigurationKeys.GIT_MONITOR_REPO_URI, this.remoteRepo.getDirectory().getAbsolutePath()) .addPrimitive(GitConfigMonitor.GIT_CONFIG_MONITOR_PREFIX + "." + ConfigurationKeys.GIT_MONITOR_REPO_DIR, TEST_DIR + "/jobConfig") .addPrimitive(ConfigurationKeys.FLOWSPEC_STORE_DIR_KEY, TEST_DIR + "flowCatalog") .addPrimitive(ConfigurationKeys.GIT_MONITOR_POLLING_INTERVAL, 5) .build(); this.flowCatalog = new FlowCatalog(config); this.flowCatalog.startAsync().awaitRunning(); this.gitConfigMonitor = new GitConfigMonitor(this.config, this.flowCatalog); this.gitConfigMonitor.setActive(true); }