Check the gerrit remote is as expected, eol_branch

I've come across the case where .gitreview has had the incorrect remote
information for the repository (for example another projects .gitreview
has been blindly copied in). Add some basic checking to ensure the
remote looks correct or raise a warning if not.

Change-Id: I663b95656db8c5ddab08e2e4aa6514694b00a1ab
This commit is contained in:
Joshua Hesketh 2017-09-20 21:02:56 +10:00 committed by Tony Breeds
parent dcf7ae4e37
commit f58cb68fe1
1 changed files with 14 additions and 0 deletions

View File

@ -167,6 +167,20 @@ while (( "$#" )); do
fi
fi
# Add some hardening around incorrect looking remote url's
remote_url=`git config --get remote.$REMOTE.url`
if [[ $remote_url != *"$project.git" && $remote_url != *"$project" ]]; then
warning_message "The url for remote $REMOTE does not end with $project or
$project.git. This may be deliberate, but it's more likely that the
project has a mis-configured .gitreview file pointing to the wrong
repository. This is the case in many of the (now retired) deb-* packages
where their remotes were set to the upstream project instead of their own
deb repository."
echo "skipping..."
popd
continue
fi
git remote update --prune
if ! git rev-parse remotes/$REMOTE/$BRANCH >/dev/null 2>&1; then