All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.netbeans.libs.git.GitRevertResult Maven / Gradle / Ivy

The newest version!
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.netbeans.libs.git;

import java.io.File;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

/**
 * Provides information about the result of reverting a commit.
 * 
 * @author Ondra Vrabec
 */
public final class GitRevertResult {
    
    private Status status;
    private GitRevisionInfo revertCommit;

    private final List conflicts;
    private final List failures;

    /**
     * Result status of a commit revert.
     */
    public static enum Status {
        REVERTED {
            @Override
            public String toString() {
                return "Reverted";
            }
        },
        REVERTED_IN_INDEX {
            @Override
            public String toString() {
                return "Reverted In Index";
            }
        },
        CONFLICTING {
            @Override
            public String toString() {
                return "Conflicting";
            }
        },
        FAILED {
            @Override
            public String toString() {
                return "Failed";
            }
        },
        NO_CHANGE {
            @Override
            public String toString() {
                return "No Change";
            }
        }
    }
    
    GitRevertResult (Status status, GitRevisionInfo commit, List conflicts, List failures) {
        this.status = status;
        this.revertCommit = commit;
        this.conflicts = conflicts == null ? Collections.emptyList() : conflicts;
        this.failures = failures == null ? Collections.emptyList() : failures;
    }

    /**
     * @return result of the revert.
     */
    public Status getStatus () {
        return status;
    }

    /**
     * @return current HEAD commit after the successful revert or null if it failed.
     */
    public GitRevisionInfo getNewHead () {
        return revertCommit;
    }

    /**
     * If the revert started but was unable to finish because of unresolved conflicts then the method
     * returns a collection of such files in conflict.
     * To complete the commit revert you need to resolve the conflicts and commit the changes.
     * @return files in conflict
     */
    public Collection getConflicts () {
        return conflicts;
    }

    /**
     * When the commit revert fails because of local modifications then this 
     * method returns a collections of files causing the failure.
     * @return files that cause the revert to fail.
     */
    public Collection getFailures () {
        return failures;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy