@Override public long lastModified() throws IOException, InterruptedException { return invoke(new FSFunction<Long>() { @Override public Long invoke(Repository repository) throws IOException { try (RevWalk walk = new RevWalk(repository)) { RevCommit commit = walk.parseCommit(commitId); return TimeUnit.SECONDS.toMillis(commit.getCommitTime()); } } }); }
@Override public long lastModified() throws IOException, InterruptedException { // TODO a more correct implementation return fs.lastModified(); }
return new GitSCMFileSystem(client, gitSCMSource.getRemote(), Constants.R_REMOTES+remoteName+"/"+head.getName(), (AbstractGitSCMSource.SCMRevisionImpl) rev); } finally {
@Override public boolean changesSince(@CheckForNull SCMRevision revision, @NonNull OutputStream changeLogStream) throws UnsupportedOperationException, IOException, InterruptedException { AbstractGitSCMSource.SCMRevisionImpl rev = getRevision(); if (rev == null ? revision == null : rev.equals(revision)) {
+ headName))).execute(); listener.getLogger().println("Done."); return new GitSCMFileSystem(client, remote, Constants.R_REMOTES + remoteName + "/" +headName, (AbstractGitSCMSource.SCMRevisionImpl) rev); } finally { cacheLock.unlock();
@NonNull @Override public InputStream content() throws IOException, InterruptedException { return fs.invoke(new GitSCMFileSystem.FSFunction<InputStream>() { @Override public InputStream invoke(Repository repository) throws IOException, InterruptedException { try (RevWalk walk = new RevWalk(repository)) { RevCommit commit = walk.parseCommit(fs.getCommitId()); RevTree tree = commit.getTree(); try (TreeWalk tw = TreeWalk.forPath(repository, getPath(), tree)) { if (tw == null) { throw new FileNotFoundException(); } FileMode fileMode = tw.getFileMode(0); if (fileMode == FileMode.MISSING) { throw new FileNotFoundException(); } if (fileMode == FileMode.TREE) { throw new IOException("Directory"); } ObjectId objectId = tw.getObjectId(0); ObjectLoader loader = repository.open(objectId); return new ByteArrayInputStream(loader.getBytes()); } } } }); } }
@NonNull @Override protected Type type() throws IOException, InterruptedException { return fs.invoke(new GitSCMFileSystem.FSFunction<Type>() { @Override public Type invoke(Repository repository) throws IOException, InterruptedException {
@NonNull @Override public Iterable<SCMFile> children() throws IOException, InterruptedException { return fs.invoke(new GitSCMFileSystem.FSFunction<List<SCMFile>>() { @Override public List<SCMFile> invoke(Repository repository) throws IOException, InterruptedException {
/** * Constructor. * * @param client the client * @param remote the remote GIT URL * @param head identifier for the head commit to be referenced * @param rev the revision. * @throws IOException on I/O error * @throws InterruptedException on thread interruption */ protected GitSCMFileSystem(GitClient client, String remote, final String head, @CheckForNull AbstractGitSCMSource.SCMRevisionImpl rev) throws IOException, InterruptedException { super(rev); this.remote = remote; this.head = head; cacheEntry = AbstractGitSCMSource.getCacheEntry(remote); listener = new LogTaskListener(LOGGER, Level.FINER); this.client = client; commitId = rev == null ? invoke(new FSFunction<ObjectId>() { @Override public ObjectId invoke(Repository repository) throws IOException, InterruptedException { return repository.getRef(head).getObjectId(); } }) : ObjectId.fromString(rev.getHash()); }