123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- /*
- * Copyright (C) 2011, Philipp Thun <philipp.thun@sap.com> and others
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Distribution License v. 1.0 which is available at
- * https://www.eclipse.org/org/documents/edl-v10.php.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
- package org.eclipse.jgit.api;
-
- import java.util.List;
- import java.util.Map;
-
- import org.eclipse.jgit.lib.Ref;
- import org.eclipse.jgit.merge.ResolveMerger.MergeFailureReason;
- import org.eclipse.jgit.revwalk.RevCommit;
-
- /**
- * Encapsulates the result of a {@link org.eclipse.jgit.api.CherryPickCommand}.
- */
- public class CherryPickResult {
-
- /**
- * The cherry-pick status
- */
- public enum CherryPickStatus {
- /** */
- OK {
- @Override
- public String toString() {
- return "Ok"; //$NON-NLS-1$
- }
- },
- /** */
- FAILED {
- @Override
- public String toString() {
- return "Failed"; //$NON-NLS-1$
- }
- },
- /** */
- CONFLICTING {
- @Override
- public String toString() {
- return "Conflicting"; //$NON-NLS-1$
- }
- }
- }
-
- private final CherryPickStatus status;
-
- private final RevCommit newHead;
-
- private final List<Ref> cherryPickedRefs;
-
- private final Map<String, MergeFailureReason> failingPaths;
-
- /**
- * Constructor for CherryPickResult
- *
- * @param newHead
- * commit the head points at after this cherry-pick
- * @param cherryPickedRefs
- * list of successfully cherry-picked <code>Ref</code>'s
- */
- public CherryPickResult(RevCommit newHead, List<Ref> cherryPickedRefs) {
- this.status = CherryPickStatus.OK;
- this.newHead = newHead;
- this.cherryPickedRefs = cherryPickedRefs;
- this.failingPaths = null;
- }
-
- /**
- * Constructor for CherryPickResult
- *
- * @param failingPaths
- * list of paths causing this cherry-pick to fail (see
- * {@link org.eclipse.jgit.merge.ResolveMerger#getFailingPaths()}
- * for details)
- */
- public CherryPickResult(Map<String, MergeFailureReason> failingPaths) {
- this.status = CherryPickStatus.FAILED;
- this.newHead = null;
- this.cherryPickedRefs = null;
- this.failingPaths = failingPaths;
- }
-
- private CherryPickResult(CherryPickStatus status) {
- this.status = status;
- this.newHead = null;
- this.cherryPickedRefs = null;
- this.failingPaths = null;
- }
-
- /**
- * A <code>CherryPickResult</code> with status
- * {@link CherryPickStatus#CONFLICTING}
- */
- public static final CherryPickResult CONFLICT = new CherryPickResult(
- CherryPickStatus.CONFLICTING);
-
- /**
- * Get status
- *
- * @return the status this cherry-pick resulted in
- */
- public CherryPickStatus getStatus() {
- return status;
- }
-
- /**
- * Get the new head after this cherry-pick
- *
- * @return the commit the head points at after this cherry-pick,
- * <code>null</code> if {@link #getStatus} is not
- * {@link org.eclipse.jgit.api.CherryPickResult.CherryPickStatus#OK}
- */
- public RevCommit getNewHead() {
- return newHead;
- }
-
- /**
- * Get the cherry-picked {@code Ref}s
- *
- * @return the list of successfully cherry-picked <code>Ref</code>'s,
- * <code>null</code> if {@link #getStatus} is not
- * {@link org.eclipse.jgit.api.CherryPickResult.CherryPickStatus#OK}
- */
- public List<Ref> getCherryPickedRefs() {
- return cherryPickedRefs;
- }
-
- /**
- * Get the list of paths causing this cherry-pick to fail
- *
- * @return the list of paths causing this cherry-pick to fail (see
- * {@link org.eclipse.jgit.merge.ResolveMerger#getFailingPaths()}
- * for details), <code>null</code> if {@link #getStatus} is not
- * {@link org.eclipse.jgit.api.CherryPickResult.CherryPickStatus#FAILED}
- */
- public Map<String, MergeFailureReason> getFailingPaths() {
- return failingPaths;
- }
- }
|