2020-03-05 22:10:52 -08:00
|
|
|
#!/bin/bash
|
2020-03-04 21:58:46 -08:00
|
|
|
|
2020-03-05 22:10:52 -08:00
|
|
|
# full github url
|
|
|
|
GITHUB_REPO_URL=https://${access_token}@github.com/minetest-mirrors/${github_repo}
|
|
|
|
|
|
|
|
# fetch commit-checksums
|
2020-03-05 23:14:59 -08:00
|
|
|
LOCAL_SHA=$(git ls-remote "${GITHUB_REPO_URL}" ${branch} | cut -f1)
|
2020-09-24 23:28:31 -07:00
|
|
|
REMOTE_SHA=$(git ls-remote "${source_repo}" ${branch} | head -n1 | cut -f1)
|
2020-03-05 23:08:42 -08:00
|
|
|
|
|
|
|
echo "Local sha: ${LOCAL_SHA} (${github_repo})"
|
|
|
|
echo "Remote sha: ${REMOTE_SHA} (${source_repo})"
|
2020-03-05 22:10:52 -08:00
|
|
|
|
|
|
|
# exit if commits are equal
|
|
|
|
test "${LOCAL_SHA}" == "${REMOTE_SHA}" && exit 0
|
|
|
|
|
2020-03-05 23:08:42 -08:00
|
|
|
echo "Changes detected! Cloning and updating local repo"
|
|
|
|
|
2020-03-05 22:10:52 -08:00
|
|
|
# clone, pull and push
|
2020-09-24 23:24:14 -07:00
|
|
|
rm gh_repo -rf
|
2020-03-05 22:10:52 -08:00
|
|
|
git clone -b ${branch} ${GITHUB_REPO_URL} gh_repo || exit -1
|
2020-03-04 21:58:46 -08:00
|
|
|
cd gh_repo
|
2020-03-04 22:25:30 -08:00
|
|
|
git pull ${source_repo} ${branch} || exit -1
|
|
|
|
git push origin ${branch} || exit -1
|