<commit_before>#!/bin/sh

(bash <<'EOF'

export repo_url=https://github.com/c7hm4r/rpi2-setup.git
export dest_dir=$HOME/rpi2-setup
export custom_playbook_path=main.custom.yml
export template_playbook_path=main.template.yml
export base_template_playbook_path=main.template.base.yml
export new_custom_playbook_path=main.custom.merged.yml

set -e
set -x

#TODO: Uncomment
#sudo apt-get update
sudo apt-get install --yes ansible meld trash-cli

if [ ! -d "$dest_dir" ]
then
    git clone "$repo_url" "$dest_dir"
    cd "$dest_dir"
else
    cd "$dest_dir"

    repo_modified=0
    if ! git ls-files --other --directory --exclude-standard \
            --no-empty-directory | sed q1 || \
        ! git diff-files --quiet --ignore-submodules -- || \
        ! git diff-index --cached --quiet HEAD --ignore-submodules --
    then
        repo_modified=1
    fi

    if [ "$repo_modified" -eq 1 ]
    then
        git stash --include-untracked --keep-index
    fi
    git pull
    if [ "$repo_modified" -eq 1 ]
    then
        git stash pop --index
    fi
fi

if [ ! -e "$custom_playbook_path" ]
then
    cp "$template_playbook_path" "$custom_playbook_path"
    cp "$template_playbook_path" "$base_template_playbook_path"
else
    trash "$new_custom_playbook_path" || true
    git merge-file -p "$custom_playbook_path" "$base_template_playbook_path" "$template_playbook_path" > "$new_custom_playbook_path"<commit_msg>fix git return code<commit_after>#!/bin/sh

(bash <<'EOF'

export repo_url=https://github.com/c7hm4r/rpi2-setup.git
export dest_dir=$HOME/rpi2-setup
export custom_playbook_path=main.custom.yml
export template_playbook_path=main.template.yml
export base_template_playbook_path=main.template.base.yml
export new_custom_playbook_path=main.custom.merged.yml

set -e
set -x

#TODO: Uncomment
#sudo apt-get update
sudo apt-get install --yes ansible meld trash-cli

if [ ! -d "$dest_dir" ]
then
    git clone "$repo_url" "$dest_dir"
    cd "$dest_dir"
else
    cd "$dest_dir"

    repo_modified=0
    if ! git ls-files --other --directory --exclude-standard \
            --no-empty-directory | sed q1 || \
        ! git diff-files --quiet --ignore-submodules -- || \
        ! git diff-index --cached --quiet HEAD --ignore-submodules --
    then
        repo_modified=1
    fi

    if [ "$repo_modified" -eq 1 ]
    then
        git stash --include-untracked --keep-index
    fi
    git pull
    if [ "$repo_modified" -eq 1 ]
    then
        git stash pop --index
    fi
fi

if [ ! -e "$custom_playbook_path" ]
then
    cp "$template_playbook_path" "$custom_playbook_path"
    cp "$template_playbook_path" "$base_template_playbook_path"
else
    trash "$new_custom_playbook_path" || true
    git merge-file -p "$custom_playbook_path" "$base_template_playbook_path" "$template_playbook_path" > "$new_custom_playbook_path" || true
{'fraction_non_alphanumeric': 0.12076271186440678, 'fraction_numerical': 0.006355932203389831, 'mean_word_length': 3.129737609329446, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '1099959', 'n_tokens_mistral': 1008, 'n_tokens_neox': 973, 'n_words': 225}