/** {@inheritDoc} */ @Override public String getMessage() { return MessageFormat.format(JGitText.get().commandRejectedByHook, hookName, super.getMessage()); } }
/** * Set the reset mode * * @param mode * the mode of the reset command * @return this instance */ public ResetCommand setMode(ResetType mode) { if (!filepaths.isEmpty()) throw new JGitInternalException(MessageFormat.format( JGitText.get().illegalCombinationOfArguments, "[--mixed | --soft | --hard]", "<paths>...")); //$NON-NLS-1$ //$NON-NLS-2$ this.mode = mode; return this; }
private Ref getHead() throws GitAPIException { try { Ref head = repo.exactRef(Constants.HEAD); if (head == null || head.getObjectId() == null) throw new NoHeadException(JGitText.get().headRequiredToStash); return head; } catch (IOException e) { throw new JGitInternalException(JGitText.get().stashFailed, e); } }
throw new JGitInternalException(e.getMessage(), e); } catch (RefNotFoundException e) { throw new JGitInternalException(e.getMessage(), e); } catch (InvalidRefNameException e) { throw new JGitInternalException(e.getMessage(), e); } catch (CheckoutConflictException e) { throw new JGitInternalException(e.getMessage(), e);
private Ref updateTagRef(ObjectId tagId, RevWalk revWalk, String tagName, String newTagToString) throws IOException, ConcurrentRefUpdateException, RefAlreadyExistsException { String refName = Constants.R_TAGS + tagName; RefUpdate tagRef = repo.updateRef(refName); tagRef.setNewObjectId(tagId); tagRef.setForceUpdate(forceUpdate); tagRef.setRefLogMessage("tagged " + name, false); //$NON-NLS-1$ Result updateResult = tagRef.update(revWalk); switch (updateResult) { case NEW: case FORCED: return repo.exactRef(refName); case LOCK_FAILURE: throw new ConcurrentRefUpdateException( JGitText.get().couldNotLockHEAD, tagRef.getRef(), updateResult); case REJECTED: throw new RefAlreadyExistsException(MessageFormat.format( JGitText.get().tagAlreadyExists, newTagToString)); default: throw new JGitInternalException(MessageFormat.format( JGitText.get().updatingRefFailed, refName, newTagToString, updateResult)); } }
private void checkParameters() throws InvalidMergeHeadsException { if (squash.booleanValue() && fastForwardMode == FastForwardMode.NO_FF) { throw new JGitInternalException( JGitText.get().cannotCombineSquashWithNoff); } if (commits.size() != 1) throw new InvalidMergeHeadsException( commits.isEmpty() ? JGitText.get().noMergeHeadSpecified : MessageFormat.format( JGitText.get().mergeStrategyDoesNotSupportHeads, mergeStrategy.getName(), Integer.valueOf(commits.size()))); }
private void processOptions() throws InvalidRefNameException, RefAlreadyExistsException, IOException { if (((!checkoutAllPaths && paths.isEmpty()) || orphan) && (name == null || !Repository .isValidRefName(Constants.R_HEADS + name))) throw new InvalidRefNameException(MessageFormat.format(JGitText .get().branchNameInvalid, name == null ? "<null>" : name)); //$NON-NLS-1$ if (orphan) { Ref refToCheck = repo.exactRef(getBranchName()); if (refToCheck != null) throw new RefAlreadyExistsException(MessageFormat.format( JGitText.get().refAlreadyExists, name)); } }
/** * {@inheritDoc} * <p> * Run the reflog command */ @Override public Collection<ReflogEntry> call() throws GitAPIException, InvalidRefNameException { checkCallable(); try { ReflogReader reader = repo.getReflogReader(ref); if (reader == null) throw new RefNotFoundException(MessageFormat.format( JGitText.get().refNotResolved, ref)); return reader.getReverseEntries(); } catch (IOException e) { throw new InvalidRefNameException(MessageFormat.format( JGitText.get().cannotRead, ref), e); } }
private ObjectId getStashId() throws GitAPIException { final String revision = stashRef != null ? stashRef : DEFAULT_REF; final ObjectId stashId; try { stashId = repo.resolve(revision); } catch (IOException e) { throw new InvalidRefNameException(MessageFormat.format( JGitText.get().stashResolveFailed, revision), e); } if (stashId == null) throw new InvalidRefNameException(MessageFormat.format( JGitText.get().stashResolveFailed, revision)); return stashId; }
private ObjectId getStartPointObjectId() throws AmbiguousObjectException, RefNotFoundException, IOException { if (startCommit != null) return startCommit.getId(); String startPointOrHead = (startPoint != null) ? startPoint : Constants.HEAD; ObjectId result = repo.resolve(startPointOrHead); if (result == null) throw new RefNotFoundException(MessageFormat.format( JGitText.get().refNotResolved, startPointOrHead)); return result; }
@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); } }
private boolean isMergeDuringRebase(RepositoryState state) { if (state != RepositoryState.REBASING_INTERACTIVE && state != RepositoryState.REBASING_MERGE) return false; try { return repo.readMergeHeads() != null; } catch (IOException e) { throw new JGitInternalException(MessageFormat.format( JGitText.get().exceptionOccurredDuringReadingOfGIT_DIR, Constants.MERGE_HEAD, e), e); } }
private Ref getRef() throws GitAPIException { try { return repo.exactRef(R_STASH); } catch (IOException e) { throw new InvalidRefNameException(MessageFormat.format( JGitText.get().cannotRead, R_STASH), e); } }
private void deleteRef(Ref stashRef) { try { Result result = createRefUpdate(stashRef).delete(); if (Result.FORCED != result) throw new JGitInternalException(MessageFormat.format( JGitText.get().stashDropDeleteRefFailed, result)); } catch (IOException e) { throw new JGitInternalException(JGitText.get().stashDropFailed, e); } }
private void processOptions() throws InvalidRefNameException { if (name == null || !Repository.isValidRefName(R_HEADS + name) || !isValidBranchName(name)) throw new InvalidRefNameException(MessageFormat.format(JGitText .get().branchNameInvalid, name == null ? "<null>" : name)); //$NON-NLS-1$ }
private void checkoutPath(DirCacheEntry entry, ObjectReader reader, CheckoutMetadata checkoutMetadata) { try { DirCacheCheckout.checkoutEntry(repo, entry, reader, true, checkoutMetadata); } catch (IOException e) { throw new JGitInternalException(MessageFormat.format( JGitText.get().checkoutConflictWithFile, entry.getPathString()), e); } } }
private void checkoutPath(DirCacheEntry entry, ObjectReader reader, CheckoutMetadata checkoutMetadata) { try { DirCacheCheckout.checkoutEntry(repo, entry, reader, true, checkoutMetadata); } catch (IOException e) { throw new JGitInternalException(MessageFormat.format( JGitText.get().checkoutConflictWithFile, entry.getPathString()), e); } }
private ObjectId getObjectIdFromRef(Ref r) throws JGitInternalException { try { ObjectId key = repo.getRefDatabase().peel(r).getPeeledObjectId(); if (key == null) { key = r.getObjectId(); } return key; } catch (IOException e) { throw new JGitInternalException(e.getMessage(), e); } }
private RevCommit parseCommit(ObjectId commitId) { try (RevWalk rw = new RevWalk(repo)) { return rw.parseCommit(commitId); } catch (IOException e) { throw new JGitInternalException(MessageFormat.format( JGitText.get().cannotReadCommit, commitId.toString()), e); } }
private ObjectId resolveRefToCommitId() { try { return repo.resolve(getRefOrHEAD() + "^{commit}"); //$NON-NLS-1$ } catch (IOException e) { throw new JGitInternalException( MessageFormat.format(JGitText.get().cannotRead, getRefOrHEAD()), e); } }