<commit_before># git.bash
#
# Assorted git utility functions. These functions all require us to cd into the
# git repo we want to operate on first. These exist mostly for aesthetic
# reasons, i.e., pretty output in the various ellipsis commands and can be used
# by package authors for consistency with them.

load pkg

# Clone a Git repo.
git.clone() {
    git clone --depth 1 "$@" 2>&1 | grep 'Cloning into'
}

# Pull git repo.
git.pull() {
    pkg.init_globals ${1:-$PKG_NAME}
    echo -e "\033[1mupdating $PKG_NAME\033[0m"
    git pull
}

# Push git repo.
git.push() {
    pkg.init_globals ${1:-$PKG_NAME}
    echo -e "\033[1mpushing $PKG_NAME\033[0m"
    git push
}

# Print last commit's sha1 hash.
git.sha1() {
    git rev-parse --short HEAD
}

# Print last commit's relative update time.
git.last_updated() {
    git --no-pager log --pretty="format:%ad" --date=relative -1
}

# Print how far ahead git repo is
git.ahead() {
    git status -sb --porcelain | grep -o '\[.*\]'
}

# Check whether get repo has changes.
git.has_changes() {
    if git diff-index --quiet HEAD --; then
        return 1
    fi
    return 0
}

# Print diffstat for git repo
git.diffstat() {
    git --no-pager diff --stat --color=always
}

# Checks if git is configured as we expect.
git.configured() {
    for key in user.name user.email github.user; do
        if [ -z "$(git config --global $key | cat)"  ]; then
            return 1
        fi
    done
    return 0
}

# Adds an include safely.
git.add_include() {
    git config --global --unset-all include.path $1
    if [ -z "$(git config --global include.path)" ]; then
        git config --global --remove-section include &>/dev/null
    fi
    git config --global --add include.path $1
}
<commit_msg>Remove grep on git.clone.<commit_after># git.bash
#
# Assorted git utility functions. These functions all require us to cd into the
# git repo we want to operate on first. These exist mostly for aesthetic
# reasons, i.e., pretty output in the various ellipsis commands and can be used
# by package authors for consistency with them.

load pkg

# Clone a Git repo.
git.clone() {
    git clone --depth 1 "$@"
}

# Pull git repo.
git.pull() {
    pkg.init_globals ${1:-$PKG_NAME}
    echo -e "\033[1mupdating $PKG_NAME\033[0m"
    git pull
}

# Push git repo.
git.push() {
    pkg.init_globals ${1:-$PKG_NAME}
    echo -e "\033[1mpushing $PKG_NAME\033[0m"
    git push
}

# Print last commit's sha1 hash.
git.sha1() {
    git rev-parse --short HEAD
}

# Print last commit's relative update time.
git.last_updated() {
    git --no-pager log --pretty="format:%ad" --date=relative -1
}

# Print how far ahead git repo is
git.ahead() {
    git status -sb --porcelain | grep -o '\[.*\]'
}

# Check whether get repo has changes.
git.has_changes() {
    if git diff-index --quiet HEAD --; then
        return 1
    fi
    return 0
}

# Print diffstat for git repo
git.diffstat() {
    git --no-pager diff --stat --color=always
}

# Checks if git is configured as we expect.
git.configured() {
    for key in user.name user.email github.user; do
        if [ -z "$(git config --global $key | cat)"  ]; then
            return 1
        fi
    done
    return 0
}

# Adds an include safely.
git.add_include() {
    git config --global --unset-all include.path $1
    if [ -z "$(git config --global include.path)" ]; then
        git config --global --remove-section include &>/dev/null
    fi
    git config --global --add include.path $1
}

{'fraction_non_alphanumeric': 0.12755542758422114, 'fraction_numerical': 0.016700259141952202, 'mean_word_length': 2.519756838905775, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '1719320', 'n_tokens_mistral': 1213, 'n_tokens_neox': 1149, 'n_words': 427}