aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/check_upstream.sh
blob: 73d2b2267180f5ce78d77f496926d9e9088f368f (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
# check git repo $1 if upstream branch
# origin/master is ahead of local branch $2(default to dev)
check_upstream() {

    if [ ! -d $1 ]; then
        return 0
    fi

    head='dev'
    if [ $# -eq 2 ]
    then
        head=$2
    fi

    cd ~/$1
    git fetch origin && \
    git rev-list $head | grep $(git rev-parse origin/master) > /dev/null

    if [ $? -ne 0 ]
    then
        echo "New commit at" $1
    fi

    cd ~/git/settings
    echo check $1 at $(date) >> ./log
}