aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/init/check_upstream
blob: fa6d2774e662206f24d85eeadbf7e08684e38a0b (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
#! /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