aboutsummaryrefslogtreecommitdiffhomepage
path: root/bin/init/check_upstream
diff options
context:
space:
mode:
Diffstat (limited to 'bin/init/check_upstream')
-rwxr-xr-xbin/init/check_upstream24
1 files changed, 24 insertions, 0 deletions
diff --git a/bin/init/check_upstream b/bin/init/check_upstream
new file mode 100755
index 0000000..fa6d277
--- /dev/null
+++ b/bin/init/check_upstream
@@ -0,0 +1,24 @@
1#! /bin/bash
2
3# This script is for repo forked from others
4# check $1(repo) if upstream branch origin/master is
5# ahead of local branch $2(default to dev)
6
7if [ ! -d "$1" ]; then
8 return 0
9fi
10
11head='dev'
12if [ $# -eq 2 ]
13then
14 head=$2
15fi
16
17cd "$1" && \
18git fetch origin && \
19if ! git rev-list "$head" | grep "$(git rev-parse origin/master)" > /dev/null; then
20 [[ $(git pull my) == 'Alrady up to date.' ]] || \
21 echo "New commit at" "$1"
22fi
23
24echo "$(date)" check "$1" >> "$SETTING_DIR/log" || echo error happens when check upstream at $1