@Override public List<CommitTreeInfo> getCommitTree(final String commitId) { return gitOperation(getStashPersonIdent(), new Callable<List<CommitTreeInfo>>() { @Override public String toString() { return "getTree(" + commitId + ")"; } public List<CommitTreeInfo> call() throws Exception { return doGetCommitTree(git, commitId); } }); }
@Override public List<String> branches() { return gitOperation(getStashPersonIdent(), new Callable<List<String>>() { @Override public String toString() { return "doListBranches()"; } @Override public List<String> call() throws Exception { return doListBranches(git); } }); }
public <T> T readFile(final String branch, final String pathOrEmpty, final Function<File, T> callback) throws IOException, GitAPIException { return gitOperation(getStashPersonIdent(), new Callable<T>() { @Override public String toString() { return "doReadFile(" + branch + ", " + pathOrEmpty + ", " + callback + ")"; } @Override public T call() throws Exception { return doReadFile(git, getRootGitDirectory(), branch, pathOrEmpty, callback); } }); }
@Override public CommitInfo getCommitInfo(final String commitId) { return gitOperation(getStashPersonIdent(), new Callable<CommitInfo>() { @Override public String toString() { return "getCommitInfo(" + commitId + ")"; } public CommitInfo call() throws Exception { return doGetCommitInfo(git, commitId); } }); }
public FileContents read(final String branch, final String pathOrEmpty) throws IOException, GitAPIException { return gitOperation(getStashPersonIdent(), new Callable<FileContents>() { @Override public String toString() { return "doRead(" + branch + ", " + pathOrEmpty + ")"; } @Override public FileContents call() throws Exception { return doRead(git, getRootGitDirectory(), branch, pathOrEmpty); } }); }
@Override public void run() { try { gitOperation(getStashPersonIdent(), emptyCallable); } catch (Exception e) { LOG.warn("Failed to pull from remote repo due " + e.getMessage() + ". This exception is ignored.", e); } } };
public <T> T writeFile(final String branch, final String pathOrEmpty, final WriteCallback<T> callback) throws IOException, GitAPIException { return gitOperation(getStashPersonIdent(), new Callable<T>() { @Override public String toString() { return "doWriteFile(" + branch + ", " + pathOrEmpty + ", " + callback + ")"; } @Override public T call() throws Exception { return doWriteFile(git, getRootGitDirectory(), branch, pathOrEmpty, callback); } }); }
@Override public FileInfo exists(final String branch, final String pathOrEmpty) throws IOException, GitAPIException { return gitOperation(getStashPersonIdent(), new Callable<FileInfo>() { @Override public String toString() { return "doExists(" + branch + ", " + pathOrEmpty + ")"; } @Override public FileInfo call() throws Exception { File rootDir = getRootGitDirectory(); return doExists(git, rootDir, branch, pathOrEmpty, false); } }); }
@Override public void createBranch(final String fromBranch, final String newBranch) { gitOperation(getStashPersonIdent(), new Callable<Object>() { @Override public String toString() { return "createBranch(" + fromBranch + ", " + newBranch + ")"; } public Object call() throws Exception { doCreateBranch(git, fromBranch, newBranch); return null; } }); }
public List<String> completePath(final String branch, final String completionText, final boolean directoriesOnly) { return gitOperation(getStashPersonIdent(), new Callable<List<String>>() { @Override public String toString() { return "completePath(" + branch + ", " + completionText + ")"; } @Override public List<String> call() throws Exception { File rootDir = getRootGitDirectory(); return doCompletePath(git, rootDir, branch, completionText, directoriesOnly); } }); }
public void rename(final String branch, final String oldPath, final String newPath, final String commitMessage, final String authorName, final String authorEmail) { final PersonIdent personIdent = new PersonIdent(authorName, authorEmail); gitOperation(personIdent, new Callable<RevCommit>() { @Override public String toString() { return "rename(" + branch + ", " + oldPath + ", " + newPath + ")"; } public RevCommit call() throws Exception { File rootDir = getRootGitDirectory(); return doRename(git, rootDir, branch, oldPath, newPath, commitMessage, personIdent); } }); }
private CommitInfo write(final String branch, final String path, final String commitMessage, String authorName, String authorEmail, final byte[] data) { final PersonIdent personIdent = new PersonIdent(authorName, authorEmail); return gitOperation(personIdent, new Callable<CommitInfo>() { @Override public String toString() { return "doWrite(" + branch + ", " + path + ")"; } public CommitInfo call() throws Exception { checkoutBranch(git, branch); File rootDir = getRootGitDirectory(); return doWrite(git, rootDir, branch, path, data, personIdent, commitMessage); } }); }
@Override public void revertTo(final String branch, final String objectId, final String blobPath, final String commitMessage, final String authorName, final String authorEmail) { final PersonIdent personIdent = new PersonIdent(authorName, authorEmail); gitOperation(personIdent, new Callable<Void>() { @Override public String toString() { return "revertTo(" + branch + ", " + objectId + ", " + blobPath + ")"; } @Override public Void call() throws Exception { Git aGit = git; File rootDir = getRootGitDirectory(); return doRevert(aGit, rootDir, branch, objectId, blobPath, commitMessage, personIdent); } }); }
public void remove(final String branch, final String path, final String commitMessage, final String authorName, final String authorEmail) { final PersonIdent personIdent = new PersonIdent(authorName, authorEmail); gitOperation(personIdent, new Callable<RevCommit>() { @Override public String toString() { return "remove(" + branch + ", " + path + ")"; } public RevCommit call() throws Exception { Git aGit = git; File rootDir = getRootGitDirectory(); return doRemove(aGit, rootDir, branch, path, commitMessage, personIdent); } }); }
@Override public CommitInfo createDirectory(final String branch, final String path, final String commitMessage, final String authorName, final String authorEmail) { final PersonIdent personIdent = new PersonIdent(authorName, authorEmail); return gitOperation(personIdent, new Callable<CommitInfo>() { @Override public String toString() { return "createDirectory(" + branch + ", " + path + ")"; } public CommitInfo call() throws Exception { checkoutBranch(git, branch); File rootDir = getRootGitDirectory(); return doCreateDirectory(git, rootDir, branch, path, personIdent, commitMessage); } }); }
@Override public String readJsonChildContent(final String branch, final String path, String fileNameWildcardOrBlank, final String search) throws IOException { final String fileNameWildcard = (Strings.isBlank(fileNameWildcardOrBlank)) ? "*.json" : fileNameWildcardOrBlank; return gitOperation(getStashPersonIdent(), new Callable<String>() { @Override public String toString() { return "readJsonChildContent(" + branch + ", " + path + ")"; } @Override public String call() throws Exception { File rootDir = getRootGitDirectory(); return doReadJsonChildContent(git, rootDir, branch, path, fileNameWildcard, search); } }); }