@VisibleForTesting String getGitDescribe(@Nonnull Repository repository) throws GitCommitIdExecutionException { try { DescribeResult describeResult = DescribeCommand .on(evaluateOnCommit, repository, log) .apply(super.gitDescribe) .call(); return describeResult.toString(); } catch (GitAPIException ex) { ex.printStackTrace(); throw new GitCommitIdExecutionException("Unable to obtain git.commit.id.describe information", ex); } }
@VisibleForTesting String getGitDescribe(@NotNull Repository repository) throws GitCommitIdExecutionException { try { DescribeResult describeResult = DescribeCommand .on(evaluateOnCommit, repository, log) .apply(super.gitDescribe) .call(); return describeResult.toString(); } catch (GitAPIException ex) { ex.printStackTrace(); throw new GitCommitIdExecutionException("Unable to obtain git.commit.id.describe information", ex); } }
private static void handleMergeConflict(Git git, Context context) { Status status = null; try { status = git.status().call(); ContentResolver resolver = context.getContentResolver(); for (String file : status.getConflicting()) { OrgFile f = new OrgFile(file, resolver); ContentValues values = new ContentValues(); values.put("comment", "conflict"); f.updateFileInDB(resolver, values); } } catch (GitAPIException e1) { e1.printStackTrace(); return; } catch (OrgFileNotFoundException e) { e.printStackTrace(); } }
public static Git getGit() { if (git == null) { try { git = Git.open(FlareBot.instance().isTestBot() ? new File(".") : new File("FlareBot/")); } catch (RepositoryNotFoundException e) { try { git = Git.cloneRepository() .setDirectory(FlareBot.instance().isTestBot() ? new File(".") : new File("FlareBot/")) .setURI("https://github.com/FlareBot/FlareBot.git") .call(); } catch (GitAPIException e1) { e1.printStackTrace(); git = null; } } catch (IOException e) { e.printStackTrace(); git = null; } } return git; }
public void commitFile() throws IOException { final FileRepositoryBuilder builder = new FileRepositoryBuilder(); final Repository repository = builder.setWorkTree(new File(gitDir)).findGitDir().build(); try { new Git(repository).commit().setOnly("build.gradle").setMessage("Bump the version of builld.gradle").call(); } catch (final GitAPIException e) { e.printStackTrace(); } }
e.printStackTrace(); } catch (GitAPIException e) { e.printStackTrace(); } catch (NullPointerException e) {
private static void printLog(final Git git) { try { for (final RevCommit revCommit : ((GitImpl) git)._log().call()) { logger.info("[LOG]: " + revCommit.getName() + " --- " + revCommit.getFullMessage()); } } catch (GitAPIException e) { e.printStackTrace(); } }
public void pullRepo() { try { git.pull().setRemote(REMOTE_NAME).setRemoteBranchName(MASTER_BRANCH).setRebase(false).call(); } catch (InvalidRemoteException e) { e.printStackTrace(); } catch (TransportException e) { e.printStackTrace(); } catch (GitAPIException e) { e.printStackTrace(); } }
private static void printLog(final Git git) { try { for (final RevCommit revCommit : ((GitImpl) git)._log().call()) { logger.info("[LOG]: " + revCommit.getName() + " --- " + revCommit.getFullMessage()); } } catch (GitAPIException e) { e.printStackTrace(); } }
public static boolean cloneRepo(final String uri, final File cloneTo, final String branch, final GitCloneProgressCallback callback) { Git result = null; try { final CloneCommand clone = Git.cloneRepository() .setURI(uri).setDirectory(cloneTo) .setBare(false).setRemote(REMOTE_NAME).setNoCheckout(false) .setCloneAllBranches(false).setCloneSubmodules(false) .setProgressMonitor(callback); if (!branch.isEmpty()) { if (branch.contains("/")) { clone.setBranch(branch.substring(branch.lastIndexOf('/') + 1)); } else { clone.setBranch(branch); } } result = clone.call(); return true; } catch (GitAPIException e) { e.printStackTrace(); } finally { if (result != null) { result.close(); } } return false; }
public void pullRepo(String uri, String branch) { try { setRemote(uri); git.pull().setRemote(REMOTE_NAME).setRemoteBranchName(branch).setRebase(false).call(); } catch (InvalidRemoteException e) { e.printStackTrace(); } catch (TransportException e) { e.printStackTrace(); } catch (GitAPIException e) { e.printStackTrace(); } }
public void initRepo() { if (exists()) { return; } try { Git.init().setDirectory(getRootDir()).setBare(false).call(); } catch (InvalidRemoteException e) { e.printStackTrace(); } catch (TransportException e) { e.printStackTrace(); } catch (GitAPIException e) { e.printStackTrace(); } }
public void pushRepo(String uri, GitUser user) { try { setRemote(uri); git.push().setRemote(REMOTE_NAME).setCredentialsProvider(new UsernamePasswordCredentialsProvider(user.getUsername(), user.getPassword())).call(); } catch (InvalidRemoteException e) { e.printStackTrace(); } catch (TransportException e) { e.printStackTrace(); } catch (GitAPIException e) { e.printStackTrace(); } }
gae.printStackTrace(new PrintWriter(sw)); String exceptionAsString = sw.toString();
e.printStackTrace(); } catch (GitAPIException e) { e.printStackTrace(); } catch (MissingObjectException e) { e.printStackTrace();
public void addAndCommit(String message, GitUser user) { try { git.add().addFilepattern(".").call(); git.commit().setMessage(message).setAuthor(user.getName(), user.getEmail()).setCommitter(user.getName(), user.getEmail()).setAll(true).call(); } catch (InvalidRemoteException e) { e.printStackTrace(); } catch (TransportException e) { e.printStackTrace(); } catch (GitAPIException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } }
public static void cloneRepo(String uri, File cloneTo) { Git result = null; try { result = Git.cloneRepository().setURI(uri).setDirectory(cloneTo) .setBranch(MASTER_BRANCH).setBare(false).setRemote(REMOTE_NAME) .setNoCheckout(false).setCloneAllBranches(false).setCloneSubmodules(false).call(); } catch (InvalidRemoteException e) { e.printStackTrace(); } catch (TransportException e) { e.printStackTrace(); } catch (GitAPIException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { if (result != null) { result.close(); } } }
public static void cloneRepo(String uri, File cloneTo, String branch) { Git result = null; try { result = Git.cloneRepository().setURI(uri).setDirectory(cloneTo) .setBranch(branch).setBare(false).setRemote(REMOTE_NAME) .setNoCheckout(false).setCloneAllBranches(false).setCloneSubmodules(false).call(); } catch (InvalidRemoteException e) { e.printStackTrace(); } catch (TransportException e) { e.printStackTrace(); } catch (GitAPIException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { if (result != null) { result.close(); } } }
public void pullRepo(String uri, String branch, GitUser user) { try { setRemote(uri); git.pull().setRemote(REMOTE_NAME).setRemoteBranchName(branch).setRebase(false) .setCredentialsProvider(new UsernamePasswordCredentialsProvider(user.getUsername(), user.getPassword())).call(); } catch (InvalidRemoteException e) { e.printStackTrace(); } catch (TransportException e) { e.printStackTrace(); } catch (GitAPIException e) { e.printStackTrace(); } }
public static void cloneRepo(String uri, File cloneTo, String branch, GitUser user) { Git result = null; try { result = Git.cloneRepository().setURI(uri).setDirectory(cloneTo) .setBranch(branch).setBare(false).setRemote(REMOTE_NAME) .setNoCheckout(false).setCloneAllBranches(false).setCloneSubmodules(false) .setCredentialsProvider(new UsernamePasswordCredentialsProvider(user.getUsername(), user.getPassword())).call(); } catch (InvalidRemoteException e) { e.printStackTrace(); } catch (TransportException e) { e.printStackTrace(); } catch (GitAPIException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { if (result != null) { result.close(); } } }