Commit 99ab4a64 authored by Raphaël Hertzog's avatar Raphaël Hertzog

Add new script to update default branch

Useful when you want to reconfigure your projects to default to
debian/master instead of master to follow DEP-14. Beware that you can't
remove the branch which is currently the default branch. So you
have to do a multi-step process: create the new branch, update
the default branch, remove the old branch.
parent b8e9cc3c
......@@ -33,6 +33,13 @@ in commit messages.
emails will be sent to the Debian Package Tracker through
dispatch@tracker.debian.org).
* `update_default_branch.sh` pkg-foo/bar "branch-name"
Update the default branch of the "bar" project in the "pkg-foo" group to
be "branch-name". The branch must be already existing for this to work.
If the branch name is omitted, it will use "debian/master" as
default branch.
* `list_projects.sh` pkg-baz
Lists on stdout all the projects of the group pkg-baz, one project per line.
......
#!/bin/bash
set -e
. ./salsarc
if [ "$#" -eq 0 ] || [ "$#" -gt 2 ] || [ -z "$1" ]; then
echo "Usage: $0 pkg-foo/bar [default-branch]" >&2
echo " where 'pkg-foo/bar' is the Salsa project name for which you want to update the default branch." >&2
echo " If default-branch is empty, then this script will use 'debian/master'" >&2
exit 1
fi
PROJECT_NAME="$1"
PROJECT_PATH="${PROJECT_NAME//\//%2F}"
if [ -z "$2" ]; then
DEFAULT_BRANCH="debian/master"
else
DEFAULT_BRANCH="$2"
fi
PROJECT_ID=$(curl --silent -f -XGET --header "PRIVATE-TOKEN: $SALSA_TOKEN" "$SALSA_URL/projects/$PROJECT_PATH" | jq '.id')
if [ -z "$PROJECT_ID" ]; then
echo "Project $PROJECT_NAME not found among your owned projects on $SALSA_URL service" >&2
exit 1
else
echo "Configuring default branch for $PROJECT_NAME ($PROJECT_ID)"
fi
case $PROJECT_ID in
''|*[!0-9]*) echo "$PROJECT_NAME not found using $SALSA_URL service" ;;
*) curl -XPUT --header "PRIVATE-TOKEN: $SALSA_TOKEN" \
$SALSA_URL/projects/$PROJECT_ID \
--data "default_branch=$DEFAULT_BRANCH"
if [ $? -eq 0 ]; then
echo
echo "All done."
else
echo
echo "Something went wrong!"
fi;;
esac
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment