mirror of
https://github.com/moby/moby.git
synced 2026-08-13 17:06:44 +00:00
The DCO job runs inside an Alpine container and fetches the base branch from VALIDATE_REPO unless VALIDATE_ORIGIN_BRANCH is set. In forked runs that repository can point at a private upstream URL, so the unauthenticated fetch fails with: ``` fatal: could not read Username for 'https://github.com': No such device or address ``` Pass the pull request base SHA so the validator can resolve the comparison point locally. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
34 lines
952 B
Bash
34 lines
952 B
Bash
#!/usr/bin/env bash
|
|
|
|
set -e -o pipefail
|
|
|
|
if [ -z "$VALIDATE_UPSTREAM" ]; then
|
|
# this is kind of an expensive check, so let's not do this twice if we
|
|
# are running more than one validate bundlescript
|
|
|
|
VALIDATE_REPO="${VALIDATE_REPO:-https://github.com/moby/moby.git}"
|
|
VALIDATE_BRANCH="${VALIDATE_BRANCH:-master}"
|
|
|
|
VALIDATE_HEAD="$(git rev-parse --verify HEAD)"
|
|
|
|
if [ -z "$VALIDATE_ORIGIN_BRANCH" ]; then
|
|
git fetch -q "$VALIDATE_REPO" "refs/heads/$VALIDATE_BRANCH"
|
|
VALIDATE_ORIGIN_BRANCH=FETCH_HEAD
|
|
fi
|
|
VALIDATE_UPSTREAM="$(git rev-parse --verify "$VALIDATE_ORIGIN_BRANCH")"
|
|
|
|
VALIDATE_COMMIT_LOG="$VALIDATE_UPSTREAM..$VALIDATE_HEAD"
|
|
VALIDATE_COMMIT_DIFF="$VALIDATE_UPSTREAM...$VALIDATE_HEAD"
|
|
|
|
validate_diff() {
|
|
if [ "$VALIDATE_UPSTREAM" != "$VALIDATE_HEAD" ]; then
|
|
git diff "$VALIDATE_COMMIT_DIFF" "$@"
|
|
fi
|
|
}
|
|
validate_log() {
|
|
if [ "$VALIDATE_UPSTREAM" != "$VALIDATE_HEAD" ]; then
|
|
git log "$VALIDATE_COMMIT_LOG" "$@"
|
|
fi
|
|
}
|
|
fi
|