<commit_before>source "${SANDBIN_HOME}/scripts/lib/colors.lib.zsh"

function new_alias() {
    local scope="$1"
    local alias_name="$2"
    local alias_command="$3"

    if [ $# = 3 ]; then
        printf "New command: ${YELLOW}git ${BOLD}%s${NORMAL}\n" "${alias_name}"
        git config $scope alias.${alias_name} "${alias_command}"
        return $?;
    else
        printf "New alias: scope, name or command not found\n"
        return 1;
    fi
}

function set_git_attribute() {
    local attribute="$1"
    local scope="$2"
    local value="$3"

    if [ $# = 3 ]; then
        git config $scope $attribute "$value"
        return $?;
    else
        printf "${RED}set_git_attribute: scope or '%s' not found${NORMAL}\n" "$attribute"
        return 1;
    fi
}

function get_git_attribute() {
    local attribute="$1"
    local scope="$2"

    git config $scope --get $attribute
}

function git_flow_init() {
    local force="$1"

    if [ -d "./.git" ]; then
        printf "Initializing git flow in '%s' directory...\n" "$(pwd)"
        git flow init $force
        exit $?
    else
        printf "Sorry! I need a git repository to work :(\n"
        exit 1
    fi
}

function git_tags() {
    git for-each-ref --sort=-taggerdate --format='%(refname:short)' refs/tags | sed 's/\\n/ /g'
}

function git_tag_subject() {
    local tag="$1"
    git for-each-ref refs/tags --format='%(refname:short)#%(subject)' | grep $tag | cut -f 2 -d '#';
}

function git_previous_tag_from_tag() {
    local tag="$1"
    git describe --abbrev=0 --tags $tag^ 2> /dev/null
}

function git_branch_name() {
    git rev-parse --abbrev-ref HEAD<commit_msg>Add git_tag_date() & fix git_tag_subject()<commit_after>source "${SANDBIN_HOME}/scripts/lib/colors.lib.zsh"

function new_alias() {
    local scope="$1"
    local alias_name="$2"
    local alias_command="$3"

    if [ $# = 3 ]; then
        printf "New command: ${YELLOW}git ${BOLD}%s${NORMAL}\n" "${alias_name}"
        git config $scope alias.${alias_name} "${alias_command}"
        return $?;
    else
        printf "New alias: scope, name or command not found\n"
        return 1;
    fi
}

function set_git_attribute() {
    local attribute="$1"
    local scope="$2"
    local value="$3"

    if [ $# = 3 ]; then
        git config $scope $attribute "$value"
        return $?;
    else
        printf "${RED}set_git_attribute: scope or '%s' not found${NORMAL}\n" "$attribute"
        return 1;
    fi
}

function get_git_attribute() {
    local attribute="$1"
    local scope="$2"

    git config $scope --get $attribute
}

function git_flow_init() {
    local force="$1"

    if [ -d "./.git" ]; then
        printf "Initializing git flow in '%s' directory...\n" "$(pwd)"
        git flow init $force
        exit $?
    else
        printf "Sorry! I need a git repository to work :(\n"
        exit 1
    fi
}

function git_tags() {
    git for-each-ref --sort=-taggerdate --format='%(refname:short)' refs/tags | sed 's/\\n/ /g'
}

function git_tag_subject() {
    local tag="$1"
    git for-each-ref refs/tags/$tag --format='%(refname:short)#%(subject)' | cut -f 2 -d '#';
}

function git_tag_date() {
    local tag="$1"
    git for-each-ref refs/tags/$tag --format='%(refname:short)#%(taggerdate:short)' | cut -f 2 -d '#';
}

function git_previous_tag_from_tag() {
    local tag="$1"
    git describe --abbrev=0 --tags $tag^ 2> /dev/null
}

function git_branch_name() {
    git rev-parse --abbrev-ref HEAD
{'fraction_non_alphanumeric': 0.16266974862756428, 'fraction_numerical': 0.011557353366079168, 'mean_word_length': 2.6289308176100628, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1059566', 'n_tokens_mistral': 1206, 'n_tokens_neox': 1165, 'n_words': 320}