summaryrefslogtreecommitdiff
path: root/Biz/Ide/post-checkout
blob: 5474b5a55f81cfdb60df6d50aec0edc9e41d0333 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env bash
set -eu

# Path to wherever you put this.
init_tags=$BIZ_ROOT/Biz/Ide/init_tags.sh

old=$1
new=$2
# is_branch=$2 # 1 if branch, 2 if file

# filter out only the changed files
changed=($(git diff --name-only $old $new))

if [[ ! -r tags ]]
then
    $init_tags
elif [[ ${#changed} -gt 0 ]]
then
    grep -v -F --regexp=${^changed} $BIZ_ROOT/tags > $BIZ_ROOT/tags.tmp
    mv tags.tmp tags

    # Retag all hs files except the ones that were deleted.
    modified=($(git diff --name-only --diff-filter=d $old $new))
    # Filter *.hs, since grep returns non-zero for no matches.
    modified=(${(M)modified:#*.hs})
    echo "modified: $modified"
    $init_tags $modified
fi