2020-12-02 10:09:37 -05:00
|
|
|
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
WORKHORSE_DIR=workhorse/
|
2020-12-09 04:09:47 -05:00
|
|
|
WORKHORSE_REF="$(cat GITLAB_WORKHORSE_VERSION)"
|
2020-12-03 13:10:10 -05:00
|
|
|
WORKHORSE_URL=${GITLAB_WORKHORSE_URL:-https://gitlab.com/gitlab-org/gitlab-workhorse.git}
|
2020-12-02 10:09:37 -05:00
|
|
|
|
|
|
|
if [ $# -gt 1 ] || ([ $# = 1 ] && [ x$1 != xcheck ]); then
|
|
|
|
echo "Usage: update-workhorse [check]"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-12-09 04:09:47 -05:00
|
|
|
if echo "$WORKHORSE_REF" | grep -q '^[0-9]\+\.[0-9]\+\.[0-9]\+' ; then
|
|
|
|
# Assume this is a tagged release
|
|
|
|
WORKHORSE_REF="v${WORKHORSE_REF}"
|
|
|
|
fi
|
|
|
|
|
2020-12-02 10:09:37 -05:00
|
|
|
clean="$(git status --porcelain)"
|
|
|
|
if [ -n "$clean" ] ; then
|
|
|
|
echo 'error: working directory is not clean:'
|
|
|
|
echo "$clean"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-12-03 13:10:10 -05:00
|
|
|
git fetch "$WORKHORSE_URL" "$WORKHORSE_REF"
|
2020-12-02 10:09:37 -05:00
|
|
|
git rm -rf --quiet -- "$WORKHORSE_DIR"
|
|
|
|
git read-tree --prefix="$WORKHORSE_DIR" -u FETCH_HEAD
|
|
|
|
|
|
|
|
status="$(git status --porcelain)"
|
|
|
|
|
|
|
|
if [ x$1 = xcheck ]; then
|
|
|
|
if [ -n "$status" ]; then
|
|
|
|
cat <<MSG
|
|
|
|
error: $WORKHORSE_DIR does not match $WORKHORSE_REF
|
|
|
|
|
|
|
|
During the transition period of https://gitlab.com/groups/gitlab-org/-/epics/4826,
|
|
|
|
the workhorse/ directory in this repository is read-only. To make changes:
|
|
|
|
|
|
|
|
1. Submit a MR to https://gitlab.com/gitlab-org/gitlab-workhorse
|
|
|
|
2. Once your MR is merged, have a new gitlab-workhorse tag made
|
|
|
|
by a maintainer
|
|
|
|
3. Update the GITLAB_WORKHORSE_VERSION file in this repository
|
|
|
|
4. Run scripts/update-workhorse to update the workhorse/ directory
|
|
|
|
|
|
|
|
MSG
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$status" ]; then
|
|
|
|
echo "warn: $WORKHORSE_DIR is already up to date, exiting without commit"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
tree=$(git write-tree)
|
|
|
|
msg="Update vendored workhorse to $WORKHORSE_REF"
|
|
|
|
commit=$(git commit-tree -p HEAD -p FETCH_HEAD^{commit} -m "$msg" "$tree")
|
|
|
|
git update-ref HEAD "$commit"
|
|
|
|
git log -1
|