package info.knacki.pass.git.entities;

import android.support.annotation.NonNull;

public class GitRef {
    protected final String fHash;
    protected final String fBranch;

    public GitRef(String hash, String branch) {
        fHash = hash;
        fBranch = branch;
    }

    public String GetBranch() {
        return fBranch;
    }

    public String GetHash() {
        return fHash;
    }

    public String GetBranchName() {
        int branchIndex = fBranch.lastIndexOf('/');
        if (branchIndex == -1)
            return fBranch;
        return fBranch.substring(branchIndex + 1);
    }

    @NonNull
    @Override
    public String toString() {
        return "ref {" + fHash + "} for branch {" + fBranch + "}";
    }
}
