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; }
fileKey.open(false).create(true);
this.remoteRepo = fileKey.open(false); this.remoteRepo.create(true);
@Override protected void run() throws Exception { final org.eclipse.jgit.transport.UploadPack up; try { FileKey key = FileKey.lenient(srcGitdir, FS.DETECTED); db = key.open(true /* must exist */); } catch (RepositoryNotFoundException notFound) { throw die(MessageFormat.format(CLIText.get().notAGitRepository, srcGitdir.getPath())); } up = new org.eclipse.jgit.transport.UploadPack(db); if (0 <= timeout) up.setTimeout(timeout); up.upload(ins, outs, errs); } }
@Override protected void run() throws Exception { final org.eclipse.jgit.transport.ReceivePack rp; try { FileKey key = FileKey.lenient(dstGitdir, FS.DETECTED); db = key.open(true /* must exist */); } catch (RepositoryNotFoundException notFound) { throw die(MessageFormat.format(CLIText.get().notAGitRepository, dstGitdir.getPath())); } rp = new org.eclipse.jgit.transport.ReceivePack(db); rp.receive(ins, outs, errs); } }
public static Repository openRepository(File gitDir) throws Exception { gitDir = _getGitDir(gitDir); RepositoryCache.FileKey fileKey = RepositoryCache.FileKey.exact( gitDir, FS.DETECTED); return fileKey.open(true); }
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); }