summaryrefslogtreecommitdiffstats
path: root/.local/bin/buildgo_sh
blob: ea548010e324afb7a599c5343800f2f3beabcb0e (plain) (blame)
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
#!/usr/bin/env sh

if [ -d "$HOME/.golang/go" ] && [ $(command -v go) ]; then
    CURR=$PWD
    cd $HOME/.golang/go/src;
    if [ "$(go version | grep devel)" ]; then
        # Check that the go version is dev-build
        # then verify that the displayed hash doesn't match current revision
        if [ ! "$(command -v git)" ]; then
            echo "git not found"
            exit 1
        fi
        fetchgit
        rev=$(git rev-parse --short HEAD)
        currentRevision=$(go version|cut -d ' ' -f 4|cut -d- -f 2)
        if [ $rev != $currentRevision ]; then
            echo "Upgrading ${currentRevision} -> ${rev}"
            go clean -cache;
            go clean -modcache;
            ./all.bash # Make always finishes, tests may just fail
            cd $HOME
            gotools.sh
        fi
    fi
    cd $CURR
fi