From 6fae25b305d714b3ab7608fa003f1af9bf024545 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Tue, 14 Feb 2023 13:33:23 +0800 Subject: Rename tools into bin --- bin/init/check_upstream | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 bin/init/check_upstream (limited to 'bin/init/check_upstream') 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 @@ +#! /bin/bash + +# This script is for repo forked from others +# check $1(repo) if upstream branch origin/master is +# ahead of local branch $2(default to dev) + +if [ ! -d "$1" ]; then + return 0 +fi + +head='dev' +if [ $# -eq 2 ] +then + head=$2 +fi + +cd "$1" && \ +git fetch origin && \ +if ! git rev-list "$head" | grep "$(git rev-parse origin/master)" > /dev/null; then + [[ $(git pull my) == 'Alrady up to date.' ]] || \ + echo "New commit at" "$1" +fi + +echo "$(date)" check "$1" >> "$SETTING_DIR/log" || echo error happens when check upstream at $1 -- cgit v1.2.3-70-g09d2