Skip to content

Commit

Permalink
保持同步
Browse files Browse the repository at this point in the history
  • Loading branch information
Alovez committed Jul 31, 2017
1 parent c973d0b commit b3b9345
Showing 1 changed file with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -168,5 +168,24 @@ fi
COMMIT_ID=`echo $COMMIT | awk '{ print $2 }'`
```

接下来,拉取代码库
接下来,拉取代码库,获取最近所有的更改,并得到最新的提交ID。

```bash
run_or_fail "Could not pull from repository" git pull
COMMIT=$(run_or_fail "Could not call 'git log' on repository" git log -n1)
if [ $? != 0 ]; then
echo "Could not call 'git log' on repository"
exit 1
fi
NEW_COMMIT_ID=`echo $COMMIT | awk '{ print $2 }'`
```

最后,如果新得到的提交ID与上一次的ID不匹配,我们就知道在两次轮询间发生了新的提交,所以我们的脚本应该将新的提交ID储存在.commit\_id文件中。

```bash
# if the id changed, then write it to a file
if [ $NEW_COMMIT_ID != $COMMIT_ID ]; then
popd 1> /dev/null
echo $NEW_COMMIT_ID > .commit_id
fi
```

0 comments on commit b3b9345

Please sign in to comment.