@@ -0,0 +1,1538 @@
+package hu.sebcsaba.gitrelocate;%0A%0Aimport java.io.IOException;%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Apublic class GitRunner %7B%0A%09%0A%09private final CmdLineTool cmdLine;%0A%09%0A%09public GitRunner(CmdLineTool cmdLine) %7B%0A%09%09this.cmdLine = cmdLine;%0A%09%7D%0A%09%0A%09public CommitID getCommitId(String anyGitCommitRef) %7B%0A%09%09return new CommitID(gitString(%22rev-parse%22, anyGitCommitRef).trim());%0A%09%7D%0A%09%0A%09public List%3CCommitID%3E getCommitParentIds(CommitID commitId) %7B%0A%09%09return getCommitIDList(gitStringList(%22log%22, %22--pretty=%25P%22, %22-n%22, %221%22, commitId.toString()));%0A%09%7D%0A%09%0A%09public List%3CString%3E getTagNames() %7B%0A%09%09return gitStringList(%22tag%22);%0A%09%7D%0A%09%0A%09public List%3CString%3E getBranchNames() %7B%0A%09%09List%3CString%3E result = gitStringList(%22branch%22);%0A%09%09result.remove(%22*%22);%0A%09%09return result;%0A%09%7D%0A%09%0A%09private String gitString(String... params) %7B%0A%09%09try %7B%0A%09%09%09return cmdLine.getString(unshift(%22git%22, params));%0A%09%09%7D%0A%09%09catch (IOException ex) %7B%0A%09%09%09throw new RuntimeException(ex);%0A%09%09%7D%0A%09%7D%0A%09%0A%09private List%3CString%3E gitStringList(String... params) %7B%0A%09%09try %7B%0A%09%09%09return cmdLine.getStringList(unshift(%22git%22, params));%0A%09%09%7D%0A%09%09catch (IOException ex) %7B%0A%09%09%09throw new RuntimeException(ex);%0A%09%09%7D%0A%09%7D%0A%09%0A%09private List%3CCommitID%3E getCommitIDList(List%3CString%3E ids) %7B%0A%09%09List%3CCommitID%3E result = new ArrayList%3CCommitID%3E(ids.size());%0A%09%09for (String id : ids) %7B%0A%09%09%09result.add(new CommitID(id));%0A%09%09%7D%0A%09%09return result;%0A%09%7D%0A%09%0A%09private String%5B%5D unshift(String first, String%5B%5D rest) %7B%0A%09%09String%5B%5D result = new String%5Brest.length+1%5D;%0A%09%09result%5B0%5D = first;%0A%09%09System.arraycopy(rest, 0, result, 1, rest.length);%0A%09%09return result;%0A%09%7D%0A%0A%7D%0A

add GitRunner basic version