/** {@inheritDoc} */ @Override public String getMessage() { return MessageFormat.format(JGitText.get().commandRejectedByHook, hookName, super.getMessage()); } }
@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); } }
public static GitException buildErrorOnReference(GitAPIException e, String reference) { if (e instanceof RefAlreadyExistsException) { return new GitException("A reference <" + reference + "> already exist.", e.getCause()); } else if (e instanceof InvalidRefNameException) { return new GitException("The reference <" + reference + "> is invalid.", e.getCause()); } else if (e instanceof RefNotFoundException) { return new GitException("The reference <" + reference + "> is not found.", e.getCause()); } else { return new GitException(e.getMessage()); } } }
gae.printStackTrace(new PrintWriter(sw)); String exceptionAsString = sw.toString(); gae.getMessage(), "Stack trace:", exceptionAsString));
gae.printStackTrace(new PrintWriter(sw)); String exceptionAsString = sw.toString(); gae.getMessage(), "Stack trace:", exceptionAsString)); } catch (IOException e) { StringWriter sw = new StringWriter();
@Override public boolean isDirty() throws GitCommitIdExecutionException { try { return JGitCommon.isRepositoryInDirtyState(git); } catch (GitAPIException e) { throw new GitCommitIdExecutionException("Failed to get git status: " + e.getMessage(), e); } }
@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); } }
/** * Init git repo with bare * * @param gitPath xxx.git folder * @throws GitException */ public static void init(Path gitPath, boolean bare) throws GitException { try { if (bare) { Git.init().setBare(bare).setGitDir(gitPath.toFile()).call(); } else { Git.init().setDirectory(gitPath.toFile()).call(); } } catch (GitAPIException e) { throw new GitException(e.getMessage()); } }
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(); } }
/** {@inheritDoc} */ @Override public String getMessage() { return MessageFormat.format(JGitText.get().commandRejectedByHook, hookName, super.getMessage()); } }
@Override public String getMessage() { return MessageFormat.format(JGitText.get().commandRejectedByHook, hookName, super.getMessage()); } }
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 Status getStatus() { try { return this.git.status().call(); } catch (GitAPIException e) { LOGGER.trace(e.getMessage(), e); return null; } } }
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(); } }
@Override public boolean isDirty() throws GitCommitIdExecutionException { try { return JGitCommon.isRepositoryInDirtyState(git); } catch (GitAPIException e) { throw new GitCommitIdExecutionException("Failed to get git status: " + e.getMessage(), e); } }
e.printStackTrace(); } catch (GitAPIException e) { e.printStackTrace(); } catch (NullPointerException e) {
/** * Method will return a complete history of commits for a given file. * * @param request - HttpServletRequest * @param response - HttpServletResponse * @param path - path of file * @return - List of History * @throws VersionControlException - failed */ @PostMapping @ResponseStatus(HttpStatus.OK) public List<History> history(final HttpServletRequest request, final HttpServletResponse response, final @RequestBody String path) throws VersionControlException { try (GitUtil git = repositoryFactory.from(request, response)) { return git.history(path); } catch (final GitAPIException ex) { LOGGER.error(ex.getMessage(), ex); throw new VersionControlException(); } }
} catch (GitAPIException e2) { gitUrl = null; e2.printStackTrace();
@Override public Ref switchBranch(final Git repo, final String branchName) { try { return repo.checkout().setName(branchName).call(); } catch (GitAPIException e) { throw new RuntimeException("Couldn't switch to branch " + branchName + ": " + e.getMessage(), e); } }