File tree Expand file tree Collapse file tree 1 file changed +23
-4
lines changed
Expand file tree Collapse file tree 1 file changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -62,9 +62,28 @@ execute_with_timeout () {
6262# Check if git local is behind remote
6363#
6464check_if_need_pull () {
65- if ! git diff --quiet remotes/origin/HEAD; then
66- # Difference found
67- return 1
68- fi
65+
66+ LOCAL_REVSPEC=HEAD
67+ BRANCH=$( git rev-parse --abbrev-ref ${LOCAL_REVSPEC} )
68+
69+ REMOTE_NAME=$( git config branch.${BRANCH} .remote)
70+
71+
72+ REMOTE_REVSPEC=remotes/${REMOTE_NAME} /${BRANCH}
73+
74+ if ! git fetch ${REMOTE_NAME}
75+ then
76+ echo " git fetch ${REMOTE_NAME} failed"
77+ exit 1
78+ fi
79+
80+ LOCAL_SHA1=$( git rev-parse ${LOCAL_REVSPEC} )
81+ REMOTE_SHA1=$( git rev-parse ${REMOTE_REVSPEC} )
82+ BASE_SHA1=$( git merge-base ${LOCAL_REVSPEC} ${REMOTE_REVSPEC} )
83+
84+ if [ ${LOCAL_SHA1} = ${BASE_SHA1} ]; then
85+ # Found change in remote
6986 return 0
87+ fi
88+ return 1
7089}
You can’t perform that action at this time.
0 commit comments