xaizek / uncov (License: AGPLv3+) (since 2018-12-07)
Uncov(er) is a tool that collects and processes code coverage reports.
<root> / scripts / git-hook-post-commit (aa521035e5b819173b64bf2166a0256dab47ad01) (1,078B) (mode 100755) [raw]
#!/bin/bash
#
# Hook script to collect coverage information for uncov.
#
# Define SKIP_POST_HOOK to skip coverage collection, e.g., on amend of README:
#
#     SKIP_POST_HOOK=1 git commit --amend

if [ -n "$SKIP_POST_HOOK" ]; then
    exit 0
fi

function pop_stashed()
{
    # pop stashed changes if working directory wasn't clean
    if [ -z "$DIRTY" ]; then
        return
    fi

    git reset --hard HEAD
    local skipped="$(git ls-files -t | grep ^S | cut -d' ' -f2-)"
    git stash pop --quiet --index

    while read file; do
        git update-index --skip-worktree "$file"
    done <<< "$skipped"
}

# determine working tree status
if ! git diff --quiet || \
    [ "$(git status --short | tail -1 | cut -f1 -d' ')" = '??' ]; then
    DIRTY=1
fi

# stash not staged for commit changes
if [ -n "$DIRTY" ]; then
    if ! git stash save --include-untracked --keep-index; then
        exit 1
    fi
    trap pop_stashed EXIT
fi

nice ionice make --jobs $(( `nproc` * 3 / 4 )) coverage
RESULT="$?"

# stashed changes (if any) are automatically restored by EXIT trap handler
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/uncov

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/uncov

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master