summaryrefslogblamecommitdiffstats
path: root/resolvers.sh
blob: ff4e38f79f8ad7f29aa67b51253b4a5a2449ed25 (plain) (tree)














































































                                                            
##
# get_commit <version>
#
# Resolve a revision to a commit ID, exit via fatal error if
# resolution cannot take place.
##
function get_commit
{
    # local repository #
    if [[ "$remote" == "" ]]; then
        if [[ "$1" == "HEAD" ]]; then
            cat "$path/HEAD"

        elif [[ "$1" == "BASE" ]]; then
            cat ".systr/BASE"

        elif [[ "$1" == "TRAC" ]]; then
            cat ".systr/TRAC"

        elif [[ "$1" == "NULL" ]]; then
            echo "NULL"

        elif [ -f "$path/refs/$1" ]; then
            cat "$path/refs/$1"

        elif [ -f "$path/$1/.commit.systr" ]; then
            echo "$1"

        else
            echo "Error: $1 not a revision" >&2
            exit
        fi

    # remote repository #
    else
        exit

    fi
}

##
# get_symref <version>
#
# Resolve a revision to a symbolic reference, exit via fatal
# error if resolution cannot take place.
##
function get_symref
{
    # local repository #
    if [[ "$remote" == "" ]]; then
        if [[ "$1" == "HEAD" ]]; then
            echo "HEAD"

        elif [[ "$1" == "BASE" ]]; then
            echo "BASE"

        elif [[ "$1" == "TRAC" ]]; then
            cat ".systr/TRAC"

        elif [[ "$1" == "NULL" ]]; then
            echo "NULL"

        elif [ -f "$path/refs/$1" ]; then
            echo "refs/$1"

        elif [ -f "$path/$1/.commit.systr" ]; then
            echo "$1"

        else
            echo "Error: $1 not a revision" >&2
            exit
        fi

    # remote repository #
    else
        exit

    fi
}