[pkg-java-scripts] 01/01: Added the Salsa migration script
Emmanuel Bourg
ebourg-guest at moszumanska.debian.org
Sat Mar 3 23:31:38 GMT 2018
This is an automated email from the git hooks/post-receive script.
ebourg-guest pushed a commit to branch master
in repository pkg-java-scripts.
commit 036de9725dbaacd6aafa7d398ea11d3fe7f0f651
Author: Emmanuel Bourg <ebourg at apache.org>
Date: Sun Mar 4 00:31:11 2018 +0100
Added the Salsa migration script
---
.gitignore | 1 +
migrate-to-salsa.sh | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 95 insertions(+)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..4b2ba37
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+salsarc
diff --git a/migrate-to-salsa.sh b/migrate-to-salsa.sh
new file mode 100755
index 0000000..6144b9f
--- /dev/null
+++ b/migrate-to-salsa.sh
@@ -0,0 +1,94 @@
+#!/bin/bash
+#
+# Script to migrate a Git repository from Alioth to Salsa
+#
+
+set -eu
+
+if ! which jq >/dev/null
+then
+ echo "You need to apt install jq" >&2
+ exit 1
+fi
+
+if [ -z "$1" ]; then
+ echo "Usage: ./migrate-to-salsa.sh <packagename>"
+ exit 1;
+fi
+
+check_return_code() {
+ if [ $? -ne 0 ]; then
+ echo
+ echo "Something went wrong!"
+ exit 1
+ fi
+}
+
+. ./salsarc
+
+PACKAGE=$1
+
+ALIOTH_URL="https://anonscm.debian.org/git"
+ALIOTH_GROUP="pkg-java"
+ALIOTH_REPO_URL="$ALIOTH_URL/$ALIOTH_GROUP/$PACKAGE"
+
+SALSA_URL="https://salsa.debian.org/api/v4"
+SALSA_GROUP=java-team
+SALSA_GROUP_ID=2588
+
+#echo "Fetching Salsa group id..."
+#
+#SALSA_GROUP_ID=$(curl -s -f -XGET --header "PRIVATE-TOKEN: $SALSA_TOKEN" "$SALSA_URL/groups/$SALSA_GROUP" | jq '.id')
+#
+#echo "Salsa group id for $SALSA_GROUP : $SALSA_GROUP_ID"
+
+# -----------------------------------------------------------------------------
+
+echo "Migrating the ${PACKAGE} repository..."
+
+RESPONSE=$(curl -s "$SALSA_URL/projects?private_token=$SALSA_TOKEN" \
+ --data "path=$PACKAGE&namespace_id=$SALSA_GROUP_ID&import_url=$ALIOTH_REPO_URL&visibility=public")
+
+echo $RESPONSE | jq --exit-status .id > /dev/null
+check_return_code
+
+PROJECT_ID=$(echo $RESPONSE | jq '.id')
+
+# -----------------------------------------------------------------------------
+
+echo "Configuring the BTS tag pending hook..."
+
+TAGPENDING_URL="https://webhook.salsa.debian.org/tagpending/$PACKAGE"
+curl --silent --output /dev/null -XPOST --header "PRIVATE-TOKEN: $SALSA_TOKEN" $SALSA_URL/projects/$PROJECT_ID/hooks \
+ --data "url=$TAGPENDING_URL&push_events=1&enable_ssl_verification=1"
+check_return_code
+
+# -----------------------------------------------------------------------------
+
+echo "Configuring the KGB hook..."
+
+KGB_URL="http://kgb.debian.net:9418/webhook/?channel=debian-java%26network=oftc%26private=1%26use_color=1%26use_irc_notices=1%26squash_threshold=20"
+curl --silent --output /dev/null -XPOST --header "PRIVATE-TOKEN: $SALSA_TOKEN" $SALSA_URL/projects/$PROJECT_ID/hooks \
+ --data "url=$KGB_URL&push_events=yes&issues_events=yes&merge_requests_events=yes&tag_push_events=yes¬e_events=yes&job_events=yes&pipeline_events=yes&wiki_events=yes&enable_ssl_verification=yes"
+check_return_code
+
+# -----------------------------------------------------------------------------
+
+echo "Configuring email notification on push..."
+
+curl --silent --output /dev/null -XPUT --header "PRIVATE-TOKEN: $SALSA_TOKEN" $SALSA_URL/projects/$PROJECT_ID/services/emails-on-push \
+ --data "recipients=pkg-java-commits at lists.alioth.debian.org dispatch at tracker.debian.org"
+check_return_code
+
+# -----------------------------------------------------------------------------
+
+echo "Disabling issues, snippets, wiki, jobs and merge request URLs..."
+
+curl --silent --output /dev/null -XPUT --header "PRIVATE-TOKEN: $SALSA_TOKEN" $SALSA_URL/projects/$PROJECT_ID/ \
+ --data "issues_enabled=false&snippets_enabled=false&wiki_enabled=false&jobs_enabled=false&printing_merge_request_link_enabled=false"
+check_return_code
+
+# -----------------------------------------------------------------------------
+
+echo
+echo "Migration complete! The new repository is located at ${SALSA_URL%/api*}/$SALSA_GROUP/$PACKAGE"
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/pkg-java-scripts.git
More information about the pkg-java-commits
mailing list