List of usage examples for org.eclipse.jgit.lib RepositoryState MERGING_RESOLVED
RepositoryState MERGING_RESOLVED
To view the source code for org.eclipse.jgit.lib RepositoryState MERGING_RESOLVED.
Click Source Link
From source file:at.bitandart.zoubek.mervin.gerrit.GerritReviewRepositoryService.java
License:Open Source License
@Override public void saveReview(URI uri, ModelReview modelReview, User currentReviewer, IProgressMonitor monitor) throws InvalidReviewRepositoryException, InvalidReviewException, RepositoryIOException { monitor.beginTask("Connecting to repository", IProgressMonitor.UNKNOWN); String repoFileURI = COMMENTS_FILE_URI; try {/*from w w w. j a v a 2s .c o m*/ Git git = Git.open(new File(uri)); Repository repository = git.getRepository(); ObjectInserter objectInserter = repository.newObjectInserter(); String commentRefName = getCommentRefName(modelReview); Ref commentRef = repository.exactRef(commentRefName); DirCache index = DirCache.newInCore(); DirCacheBuilder dirCacheBuilder = index.builder(); monitor.beginTask("Preparing commit...", IProgressMonitor.UNKNOWN); if (commentRef != null) { /* * The ref already exists so we have to copy the previous * RevTree to keep all already attached files */ RevWalk revWalk = new RevWalk(repository); RevCommit prevCommit = revWalk.parseCommit(commentRef.getObjectId()); RevTree tree = prevCommit.getTree(); List<String> ignoredFiles = new ArrayList<>(); /* * add file path of the new file to the ignored file paths, as * we don't want any already existing old file in our new tree */ ignoredFiles.add(repoFileURI); buildDirCacheFromTree(tree, repository, dirCacheBuilder, ignoredFiles); revWalk.close(); } monitor.beginTask("Writing comments file...", IProgressMonitor.UNKNOWN); ResourceSet resourceSet = new ResourceSetImpl(); Resource resource = resourceSet.createResource(org.eclipse.emf.common.util.URI.createURI(repoFileURI)); addCommentsToResource(modelReview, resource); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); resource.save(outputStream, null); // insert file as object byte[] content = outputStream.toByteArray(); long length = content.length; InputStream inputStream = new ByteArrayInputStream(content); ObjectId objectId = objectInserter.insert(Constants.OBJ_BLOB, length, inputStream); inputStream.close(); // create tree entry DirCacheEntry entry = new DirCacheEntry(repoFileURI); entry.setFileMode(FileMode.REGULAR_FILE); entry.setLastModified(System.currentTimeMillis()); entry.setLength(length); entry.setObjectId(objectId); dirCacheBuilder.add(entry); dirCacheBuilder.finish(); // write new tree in database ObjectId indexTreeId = index.writeTree(objectInserter); monitor.beginTask("Commiting comments...", IProgressMonitor.UNKNOWN); // create commit CommitBuilder commitBuilder = new CommitBuilder(); PersonIdent personIdent = new PersonIdent("Mervin", "mervin@mervin.modelreview"); commitBuilder.setCommitter(personIdent); commitBuilder.setAuthor(personIdent); commitBuilder.setMessage( MessageFormat.format("Updated comments by user \"{0}\"", currentReviewer.getName())); if (commentRef != null) { commitBuilder.setParentId(commentRef.getObjectId()); } commitBuilder.setTreeId(indexTreeId); // commit ObjectId commitId = objectInserter.insert(commitBuilder); objectInserter.flush(); RefUpdate refUpdate = repository.updateRef(commentRefName); refUpdate.setNewObjectId(commitId); if (commentRef != null) refUpdate.setExpectedOldObjectId(commentRef.getObjectId()); else refUpdate.setExpectedOldObjectId(ObjectId.zeroId()); /* * TODO the result handling below is copied from the CommitCommand * class, I don't know if this is really necessary in our case */ Result result = refUpdate.forceUpdate(); switch (result) { case NEW: case FORCED: case FAST_FORWARD: { if (repository.getRepositoryState() == RepositoryState.MERGING_RESOLVED) { /* * Commit was successful. Now delete the files used for * merge commits */ repository.writeMergeCommitMsg(null); repository.writeMergeHeads(null); } else if (repository.getRepositoryState() == RepositoryState.CHERRY_PICKING_RESOLVED) { repository.writeMergeCommitMsg(null); repository.writeCherryPickHead(null); } else if (repository.getRepositoryState() == RepositoryState.REVERTING_RESOLVED) { repository.writeMergeCommitMsg(null); repository.writeRevertHead(null); } break; } case REJECTED: case LOCK_FAILURE: throw new RepositoryIOException("Error occured during writing to the git repository", new ConcurrentRefUpdateException("Could not lock ref " + refUpdate.getRef().getName(), refUpdate.getRef(), result)); default: throw new RepositoryIOException("Error occured during writing to the git repository", new JGitInternalException(MessageFormat.format(JGitText.get().updatingRefFailed, refUpdate.getRef().getName(), commitId.toString(), result))); } } catch (IOException e) { throw new InvalidReviewRepositoryException("Could not open local git repository", e); } finally { monitor.done(); } }
From source file:com.mangosolutions.rcloud.rawgist.repository.git.BareCommitCommand.java
/** * Executes the {@code commit} command with all the options and parameters * collected by the setter methods of this class. Each instance of this * class should only be used for one invocation of the command (means: one * call to {@link #call()})/*w w w .j a v a2 s. c o m*/ * * @return a {@link RevCommit} object representing the successful commit. * @throws NoHeadException * when called on a git repo without a HEAD reference * @throws NoMessageException * when called without specifying a commit message * @throws UnmergedPathsException * when the current index contained unmerged paths (conflicts) * @throws ConcurrentRefUpdateException * when HEAD or branch ref is updated concurrently by someone * else * @throws WrongRepositoryStateException * when repository is not in the right state for committing * @throws AbortedByHookException * if there are either pre-commit or commit-msg hooks present in * the repository and one of them rejects the commit. */ public RevCommit call() throws GitAPIException, NoHeadException, NoMessageException, UnmergedPathsException, ConcurrentRefUpdateException, WrongRepositoryStateException, AbortedByHookException { checkCallable(); Collections.sort(only); try (RevWalk rw = new RevWalk(repo)) { RepositoryState state = repo.getRepositoryState(); if (!noVerify) { Hooks.preCommit(repo, hookOutRedirect).call(); } processOptions(state, rw); if (all && !repo.isBare()) { try (Git git = new Git(repo)) { git.add().addFilepattern(".") //$NON-NLS-1$ .setUpdate(true).call(); } catch (NoFilepatternException e) { // should really not happen throw new JGitInternalException(e.getMessage(), e); } } Ref head = repo.findRef(Constants.HEAD); if (head == null) { throw new NoHeadException(JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported); } // determine the current HEAD and the commit it is referring to ObjectId headId = repo.resolve(Constants.HEAD + "^{commit}"); //$NON-NLS-1$ if (headId == null && amend) throw new WrongRepositoryStateException(JGitText.get().commitAmendOnInitialNotPossible); if (headId != null) { if (amend) { RevCommit previousCommit = rw.parseCommit(headId); for (RevCommit p : previousCommit.getParents()) parents.add(p.getId()); if (author == null) author = previousCommit.getAuthorIdent(); } else { parents.add(0, headId); } } if (!noVerify) { message = Hooks.commitMsg(repo, hookOutRedirect).setCommitMessage(message).call(); } // lock the index // DirCache index = repo.lockDirCache(); index.lock(); try (ObjectInserter odi = repo.newObjectInserter()) { if (!only.isEmpty()) index = createTemporaryIndex(headId, index, rw); // Write the index as tree to the object database. This may // fail for example when the index contains unmerged paths // (unresolved conflicts) ObjectId indexTreeId = index.writeTree(odi); if (insertChangeId) insertChangeId(indexTreeId); // Check for empty commits if (headId != null && !allowEmpty.booleanValue()) { RevCommit headCommit = rw.parseCommit(headId); headCommit.getTree(); if (indexTreeId.equals(headCommit.getTree())) { return null; } } // Create a Commit object, populate it and write it CommitBuilder commit = new CommitBuilder(); commit.setCommitter(committer); commit.setAuthor(author); commit.setMessage(message); commit.setParentIds(parents); commit.setTreeId(indexTreeId); ObjectId commitId = odi.insert(commit); odi.flush(); RevCommit revCommit = rw.parseCommit(commitId); RefUpdate ru = repo.updateRef(Constants.HEAD); ru.setNewObjectId(commitId); if (reflogComment != null) { ru.setRefLogMessage(reflogComment, false); } else { String prefix = amend ? "commit (amend): " //$NON-NLS-1$ : parents.size() == 0 ? "commit (initial): " //$NON-NLS-1$ : "commit: "; //$NON-NLS-1$ ru.setRefLogMessage(prefix + revCommit.getShortMessage(), false); } if (headId != null) { ru.setExpectedOldObjectId(headId); } else { ru.setExpectedOldObjectId(ObjectId.zeroId()); } Result rc = ru.forceUpdate(); switch (rc) { case NEW: case FORCED: case FAST_FORWARD: { setCallable(false); if (state == RepositoryState.MERGING_RESOLVED || isMergeDuringRebase(state)) { // Commit was successful. Now delete the files // used for merge commits repo.writeMergeCommitMsg(null); repo.writeMergeHeads(null); } else if (state == RepositoryState.CHERRY_PICKING_RESOLVED) { repo.writeMergeCommitMsg(null); repo.writeCherryPickHead(null); } else if (state == RepositoryState.REVERTING_RESOLVED) { repo.writeMergeCommitMsg(null); repo.writeRevertHead(null); } return revCommit; } case REJECTED: case LOCK_FAILURE: throw new ConcurrentRefUpdateException(JGitText.get().couldNotLockHEAD, ru.getRef(), rc); default: throw new JGitInternalException(MessageFormat.format(JGitText.get().updatingRefFailed, Constants.HEAD, commitId.toString(), rc)); } } finally { index.unlock(); } } catch (UnmergedPathException e) { throw new UnmergedPathsException(e); } catch (IOException e) { throw new JGitInternalException(JGitText.get().exceptionCaughtDuringExecutionOfCommitCommand, e); } }
From source file:com.mangosolutions.rcloud.rawgist.repository.git.BareCommitCommand.java
/** * Sets default values for not explicitly specified options. Then validates * that all required data has been provided. * * @param state//w w w .jav a2 s .c o m * the state of the repository we are working on * @param rw * the RevWalk to use * * @throws NoMessageException * if the commit message has not been specified */ private void processOptions(RepositoryState state, RevWalk rw) throws NoMessageException { if (committer == null) { committer = new PersonIdent(repo); } if (author == null && !amend) { author = committer; } if (allowEmpty == null) { // JGit allows empty commits by default. Only when pathes are // specified the commit should not be empty. This behaviour differs // from native git but can only be adapted in the next release. // TODO(ch) align the defaults with native git allowEmpty = (only.isEmpty()) ? Boolean.TRUE : Boolean.FALSE; } // when doing a merge commit parse MERGE_HEAD and MERGE_MSG files if (state == RepositoryState.MERGING_RESOLVED || isMergeDuringRebase(state)) { try { parents = repo.readMergeHeads(); if (parents != null) { for (int i = 0; i < parents.size(); i++) { RevObject ro = rw.parseAny(parents.get(i)); if (ro instanceof RevTag) parents.set(i, rw.peel(ro)); } } } catch (IOException e) { throw new JGitInternalException(MessageFormat.format( JGitText.get().exceptionOccurredDuringReadingOfGIT_DIR, Constants.MERGE_HEAD, e), e); } if (message == null) { try { message = repo.readMergeCommitMsg(); } catch (IOException e) { throw new JGitInternalException(MessageFormat.format( JGitText.get().exceptionOccurredDuringReadingOfGIT_DIR, Constants.MERGE_MSG, e), e); } } } else if (state == RepositoryState.SAFE && message == null) { try { message = repo.readSquashCommitMsg(); if (message != null) { repo.writeSquashCommitMsg(null /* delete */); } } catch (IOException e) { throw new JGitInternalException(MessageFormat .format(JGitText.get().exceptionOccurredDuringReadingOfGIT_DIR, Constants.MERGE_MSG, e), e); } } if (message == null) { // as long as we don't support -C option we have to have // an explicit message throw new NoMessageException(JGitText.get().commitMessageNotSpecified); } }
From source file:edu.wustl.lookingglass.community.CommunityRepository.java
License:Open Source License
private void resolveMerge() throws NoWorkTreeException, GitAPIException, IOException { assert this.username != null; assert this.email != null; Status status = this.git.status().call(); Map<String, StageState> conflicting = status.getConflictingStageState(); for (String path : conflicting.keySet()) { StageState stageState = conflicting.get(path); switch (stageState) { case BOTH_MODIFIED: // UU case BOTH_ADDED: // AA case ADDED_BY_US: // AU case ADDED_BY_THEM: // UA // Both the local and server version have been modified File conflictingFile = new File(this.repoDir, path); String fullPath = conflictingFile.getAbsolutePath(); // Since the local copy was modified it probably makes sense to leave it // since that's the copy the user has been working on. Here's my assumption... // a sync didn't happen, so the user opens their project and sees it's not their // latest changes, they accept the failure and start to fix it... finally a sync // happens... at this point they are probably editing this world, so when they save // they wouldn't even load the new file, so we should just keep the old file. // TODO: we should really prompt the user to resolve this conflict. // but that's kinda hard with the singletons... because you probably just want // to open both files in two different windows (editors) but we can't do that. :( // Recover server version this.git.checkout().setStage(Stage.THEIRS).addPath(path).call(); // Append a timestamp LocalDateTime date = LocalDateTime.now(); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("YYYY-mm-dd+HH'h'MM'm'"); String timestamp = date.format(formatter); File theirFile = new File(FilenameUtils.getFullPath(fullPath), FilenameUtils.getBaseName(path) + " (" + timestamp + ")." + FilenameUtils.getExtension(path)); if (conflictingFile.exists() && !theirFile.exists()) { Files.move(conflictingFile.toPath(), theirFile.toPath()); String relativePath = this.repoDir.toURI().relativize(theirFile.toURI()).getPath(); this.git.add().addFilepattern(relativePath).call(); }//w w w. j a va2 s .c o m // Recover local version this.git.checkout().setStage(Stage.OURS).addPath(path).call(); this.git.add().addFilepattern(path).call(); break; case DELETED_BY_US: // DU // The modified local version is already in the checkout, so it just needs to be added. // We need to specifically mention the file, so we can't reuse the Add () method this.git.add().addFilepattern(path).call(); break; case DELETED_BY_THEM: // UD // Recover server version this.git.checkout().setStage(Stage.THEIRS).addPath(path).call(); this.git.add().addFilepattern(path).call(); break; case BOTH_DELETED: // DD break; default: throw new IllegalArgumentException("Unknown StageState: " + stageState); } } RepositoryState resolvedState = this.git.getRepository().getRepositoryState(); assert resolvedState == RepositoryState.MERGING_RESOLVED; // we are done resolving the merge! this.git.commit().setAuthor(this.username, this.email).call(); RepositoryState safeState = this.git.getRepository().getRepositoryState(); assert safeState == RepositoryState.SAFE; }
From source file:org.eclipse.egit.core.op.ResetOperation.java
License:Open Source License
private void reset(IProgressMonitor monitor) throws CoreException { monitor.beginTask(NLS.bind(CoreText.ResetOperation_performingReset, type.toString().toLowerCase(), refName), 3);//from ww w. j a v a 2s. c o m IProject[] validProjects = null; if (type == ResetType.HARD) validProjects = ProjectUtil.getValidProjects(repository); boolean merging = false; if (repository.getRepositoryState().equals(RepositoryState.MERGING) || repository.getRepositoryState().equals(RepositoryState.MERGING_RESOLVED)) merging = true; mapObjects(); monitor.worked(1); writeRef(); monitor.worked(1); switch (type) { case HARD: checkoutIndex(); monitor.worked(1); if (merging) resetMerge(); monitor.worked(1); // only refresh if working tree changes ProjectUtil.refreshValidProjects(validProjects, new SubProgressMonitor(monitor, 1)); monitor.worked(1); break; case MIXED: // Change the resetIndex(); monitor.worked(2); if (merging) resetMerge(); monitor.worked(1); break; case SOFT: // only change the ref monitor.worked(3); } monitor.done(); }
From source file:org.eclipse.egit.ui.internal.actions.CommitAction.java
License:Open Source License
@Override public void execute(IAction act) { // let's see if there is any dirty editor around and // ask the user if they want to save or abort if (!PlatformUI.getWorkbench().saveAllEditors(true)) { return;// w w w .j a v a 2 s .c o m } resetState(); try { buildIndexHeadDiffList(); } catch (IOException e) { handle(new TeamException(UIText.CommitAction_errorComputingDiffs, e), UIText.CommitAction_errorDuringCommit, UIText.CommitAction_errorComputingDiffs); return; } catch (CoreException e) { handle(new TeamException(UIText.CommitAction_errorComputingDiffs, e), UIText.CommitAction_errorDuringCommit, UIText.CommitAction_errorComputingDiffs); return; } Repository[] repos = getRepositoriesFor(getProjectsForSelectedResources()); Repository repository = null; amendAllowed = repos.length == 1; for (Repository repo : repos) { repository = repo; RepositoryState state = repo.getRepositoryState(); // currently we don't support committing a merge commit if (state == RepositoryState.MERGING_RESOLVED || !state.canCommit()) { MessageDialog.openError(getTargetPart().getSite().getShell(), UIText.CommitAction_cannotCommit, NLS.bind(UIText.CommitAction_repositoryState, state.getDescription())); return; } } loadPreviousCommit(); if (files.isEmpty()) { if (amendAllowed && previousCommit != null) { boolean result = MessageDialog.openQuestion(getTargetPart().getSite().getShell(), UIText.CommitAction_noFilesToCommit, UIText.CommitAction_amendCommit); if (!result) return; amending = true; } else { MessageDialog.openWarning(getTargetPart().getSite().getShell(), UIText.CommitAction_noFilesToCommit, UIText.CommitAction_amendNotPossible); return; } } String author = null; String committer = null; if (repository != null) { final RepositoryConfig config = repository.getConfig(); author = config.getAuthorName(); final String authorEmail = config.getAuthorEmail(); author = author + " <" + authorEmail + ">"; //$NON-NLS-1$ //$NON-NLS-2$ committer = config.getCommitterName(); final String committerEmail = config.getCommitterEmail(); committer = committer + " <" + committerEmail + ">"; //$NON-NLS-1$ //$NON-NLS-2$ } CommitDialog commitDialog = new CommitDialog(getTargetPart().getSite().getShell()); commitDialog.setAmending(amending); commitDialog.setAmendAllowed(amendAllowed); commitDialog.setFileList(files); commitDialog.setPreselectedFiles(getSelectedFiles()); commitDialog.setAuthor(author); commitDialog.setCommitter(committer); if (previousCommit != null) { commitDialog.setPreviousCommitMessage(previousCommit.getMessage()); PersonIdent previousAuthor = previousCommit.getAuthor(); commitDialog .setPreviousAuthor(previousAuthor.getName() + " <" + previousAuthor.getEmailAddress() + ">"); //$NON-NLS-1$ //$NON-NLS-2$ } if (commitDialog.open() != IDialogConstants.OK_ID) return; final CommitOperation commitOperation = new CommitOperation(commitDialog.getSelectedFiles(), notIndexed, notTracked, commitDialog.getAuthor(), commitDialog.getCommitter(), commitDialog.getCommitMessage()); if (commitDialog.isAmending()) { commitOperation.setAmending(true); commitOperation.setPreviousCommit(previousCommit); commitOperation.setRepos(repos); } String jobname = UIText.CommitAction_CommittingChanges; Job job = new Job(jobname) { @Override protected IStatus run(IProgressMonitor monitor) { try { commitOperation.execute(monitor); for (IProject proj : getProjectsForSelectedResources()) { RepositoryMapping.getMapping(proj).fireRepositoryChanged(); } } catch (CoreException e) { return Activator.createErrorStatus(UIText.CommitAction_CommittingFailed, e); } finally { GitLightweightDecorator.refresh(); } return Status.OK_STATUS; } }; job.setUser(true); job.schedule(); }
From source file:org.eclipse.egit.ui.internal.actions.CommitActionHandler.java
License:Open Source License
public Object execute(final ExecutionEvent event) throws ExecutionException { // let's see if there is any dirty editor around and // ask the user if they want to save or abort if (!PlatformUI.getWorkbench().saveAllEditors(true)) { return null; }/*from www. java 2s. co m*/ resetState(); final IProject[] projects = getProjectsInRepositoryOfSelectedResources(event); try { PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { buildIndexHeadDiffList(projects, monitor); } catch (IOException e) { throw new InvocationTargetException(e); } } }); } catch (InvocationTargetException e) { Activator.handleError(UIText.CommitAction_errorComputingDiffs, e.getCause(), true); return null; } catch (InterruptedException e) { return null; } Repository[] repos = getRepositoriesFor(getProjectsForSelectedResources(event)); Repository repository = null; Repository mergeRepository = null; amendAllowed = repos.length == 1; boolean isMergedResolved = false; for (Repository repo : repos) { repository = repo; RepositoryState state = repo.getRepositoryState(); if (!state.canCommit()) { MessageDialog.openError(getShell(event), UIText.CommitAction_cannotCommit, NLS.bind(UIText.CommitAction_repositoryState, state.getDescription())); return null; } else if (state.equals(RepositoryState.MERGING_RESOLVED)) { isMergedResolved = true; mergeRepository = repo; } } loadPreviousCommit(event); if (files.isEmpty()) { if (amendAllowed && previousCommit != null) { boolean result = MessageDialog.openQuestion(getShell(event), UIText.CommitAction_noFilesToCommit, UIText.CommitAction_amendCommit); if (!result) return null; amending = true; } else { MessageDialog.openWarning(getShell(event), UIText.CommitAction_noFilesToCommit, UIText.CommitAction_amendNotPossible); return null; } } String author = null; String committer = null; if (repository != null) { final UserConfig config = repository.getConfig().get(UserConfig.KEY); author = config.getAuthorName(); final String authorEmail = config.getAuthorEmail(); author = author + " <" + authorEmail + ">"; //$NON-NLS-1$ //$NON-NLS-2$ committer = config.getCommitterName(); final String committerEmail = config.getCommitterEmail(); committer = committer + " <" + committerEmail + ">"; //$NON-NLS-1$ //$NON-NLS-2$ } CommitDialog commitDialog = new CommitDialog(getShell(event)); commitDialog.setAmending(amending); commitDialog.setAmendAllowed(amendAllowed); commitDialog.setFileList(files, indexDiffs); commitDialog.setPreselectedFiles(getSelectedFiles(event)); commitDialog.setAuthor(author); commitDialog.setCommitter(committer); commitDialog.setAllowToChangeSelection(!isMergedResolved); if (previousCommit != null) { commitDialog.setPreviousCommitMessage(previousCommit.getFullMessage()); PersonIdent previousAuthor = previousCommit.getAuthorIdent(); commitDialog .setPreviousAuthor(previousAuthor.getName() + " <" + previousAuthor.getEmailAddress() + ">"); //$NON-NLS-1$ //$NON-NLS-2$ } if (isMergedResolved) { commitDialog.setCommitMessage(getMergeResolveMessage(mergeRepository, event)); } if (commitDialog.open() != IDialogConstants.OK_ID) return null; final CommitOperation commitOperation = new CommitOperation(commitDialog.getSelectedFiles(), notIndexed, notTracked, commitDialog.getAuthor(), commitDialog.getCommitter(), commitDialog.getCommitMessage()); if (commitDialog.isAmending()) { commitOperation.setAmending(true); commitOperation.setPreviousCommit(previousCommit); commitOperation.setRepos(repos); } commitOperation.setComputeChangeId(commitDialog.getCreateChangeId()); commitOperation.setCommitAll(isMergedResolved); if (isMergedResolved) commitOperation.setRepos(repos); String jobname = UIText.CommitAction_CommittingChanges; Job job = new Job(jobname) { @Override protected IStatus run(IProgressMonitor monitor) { try { commitOperation.execute(monitor); for (IProject proj : getProjectsForSelectedResources(event)) { RepositoryMapping.getMapping(proj).fireRepositoryChanged(); } } catch (CoreException e) { return Activator.createErrorStatus(UIText.CommitAction_CommittingFailed, e); } catch (ExecutionException e) { return Activator.createErrorStatus(UIText.CommitAction_CommittingFailed, e); } finally { GitLightweightDecorator.refresh(); } return Status.OK_STATUS; } @Override public boolean belongsTo(Object family) { if (family.equals(JobFamilies.COMMIT)) return true; return super.belongsTo(family); } }; job.setUser(true); job.schedule(); return null; }
From source file:org.eclipse.egit.ui.internal.commit.CommitHelper.java
License:Open Source License
private void calculateCommitInfo() { Repository mergeRepository = null;//from ww w. j a v a 2 s.co m isMergedResolved = false; isCherryPickResolved = false; RepositoryState state = repository.getRepositoryState(); canCommit = state.canCommit(); if (!canCommit) { cannotCommitMessage = NLS.bind(UIText.CommitAction_repositoryState, state.getDescription()); return; } if (state.equals(RepositoryState.MERGING_RESOLVED)) { isMergedResolved = true; mergeRepository = repository; } else if (state.equals(RepositoryState.CHERRY_PICKING_RESOLVED)) { isCherryPickResolved = true; mergeRepository = repository; } previousCommit = getHeadCommit(repository); final UserConfig config = repository.getConfig().get(UserConfig.KEY); author = config.getAuthorName(); final String authorEmail = config.getAuthorEmail(); author = author + " <" + authorEmail + ">"; //$NON-NLS-1$ //$NON-NLS-2$ committer = config.getCommitterName(); final String committerEmail = config.getCommitterEmail(); committer = committer + " <" + committerEmail + ">"; //$NON-NLS-1$ //$NON-NLS-2$ if (isMergedResolved || isCherryPickResolved) { commitMessage = getMergeResolveMessage(mergeRepository); } if (isCherryPickResolved) { author = getCherryPickOriginalAuthor(mergeRepository); } }
From source file:org.eclipse.egit.ui.internal.commit.CommitHelper.java
License:Open Source License
/** * @param repository/* ww w . ja va 2s . c o m*/ * to check * @return true if an empty commit without files is allowed in the * current state */ public static boolean isCommitWithoutFilesAllowed(Repository repository) { RepositoryState state = repository.getRepositoryState(); return state == RepositoryState.MERGING_RESOLVED; }
From source file:org.eclipse.ptp.internal.rdt.sync.git.core.JGitRepo.java
License:Open Source License
/** * Is repository currently in an unresolved merge state? * * @return whether repository is in an unresolved merge state * @throws IOException/*from www. ja v a 2 s . com*/ */ public boolean inUnresolvedMergeState() throws IOException { if (inMergeState() && !(git.getRepository().getRepositoryState().equals(RepositoryState.MERGING_RESOLVED))) { return true; } else { return false; } }