diff options
| author | Hsieh Chin Fan <pham@topo.tw> | 2023-02-14 13:33:23 +0800 |
|---|---|---|
| committer | Hsieh Chin Fan <pham@topo.tw> | 2023-02-14 13:33:23 +0800 |
| commit | 6fae25b305d714b3ab7608fa003f1af9bf024545 (patch) | |
| tree | 05507b2c0505659d2fd847ecce988dacab63a236 /bin/init/check_upstream | |
| parent | 41ad31a2dee9ff912f222652f022b4c55cddcbf7 (diff) | |
Rename tools into bin
Diffstat (limited to 'bin/init/check_upstream')
| -rwxr-xr-x | bin/init/check_upstream | 24 |
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 | |||
| 7 | if [ ! -d "$1" ]; then | ||
| 8 | return 0 | ||
| 9 | fi | ||
| 10 | |||
| 11 | head='dev' | ||
| 12 | if [ $# -eq 2 ] | ||
| 13 | then | ||
| 14 | head=$2 | ||
| 15 | fi | ||
| 16 | |||
| 17 | cd "$1" && \ | ||
| 18 | git fetch origin && \ | ||
| 19 | if ! 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" | ||
| 22 | fi | ||
| 23 | |||
| 24 | echo "$(date)" check "$1" >> "$SETTING_DIR/log" || echo error happens when check upstream at $1 | ||