[med-svn] [Git][med-team/community/helper-scripts][master] Make inject-into-salsa-git aware of subgroups
Andreas Tille (@tille)
gitlab at salsa.debian.org
Thu Mar 17 15:46:51 GMT 2022
Andreas Tille pushed to branch master at Debian Med / community / helper-scripts
Commits:
5038afbb by Andreas Tille at 2022-03-17T16:46:43+01:00
Make inject-into-salsa-git aware of subgroups
- - - - -
1 changed file:
- inject-into-salsa-git
Changes:
=====================================
inject-into-salsa-git
=====================================
@@ -80,11 +80,22 @@ DEBPKGNAME=`dpkg-parsechangelog | awk '/^Source:/ {print $2}'`
SHORTDESC=`grep "^Description: " debian/control | head -n 1 | sed 's/^Description: //'`
VCSGIT=`grep "^Vcs-Git: " debian/control | sed -e 's/^Vcs-Git: //' -e 's#[githps]\+://anonscm.debian.org/#ssh://git.debian.org/#'`
SALSA_GROUP=`echo $VCSGIT | sed -e 's#.*://salsa.debian.org/\([^/]\+\)/.*#\1#'`
+SUBGROUP=`echo $VCSGIT | sed -e 's#.*://salsa.debian.org/[^/]\+/\([^/]\+\)/.*#\1#'`
+if [ "$VCSGIT" = "$SUBGROUP" ] ; then
+ SUBGROUP=""
+fi
#echo $VCSGIT
#echo $SALSA_GROUP
+#echo $SUBGROUP
-SALSA_GROUP_ID=$(curl -s -f -XGET "$SALSA_URL/groups/$SALSA_GROUP?with_projects=false" | jq '.id')
+if [ "$SUBGROUP" = "" ] ; then
+ # no subgroup
+ SALSA_GROUP_ID=$(curl -s -f -XGET "$SALSA_URL/groups/$SALSA_GROUP?with_projects=false" | jq '.id')
+else
+ # curl -s -f -XGET "$SALSA_URL/groups/$SALSA_GROUP/subgroups?with_projects=false" | jq '.[] | "\(.id) \(.name)"'
+ SALSA_GROUP_ID=$(curl -s -f -XGET "$SALSA_URL/groups/$SALSA_GROUP/subgroups?with_projects=false" | jq '.[] | "\(.id) \(.name)"' | grep $SUBGROUP | sed 's/^"\([0-9]\+\) \+.*"$/\1/')
+fi
if [ "$SALSA_GROUP_ID" = "" ] ; then
echo "Failed to find group ID for $SALSA_GROUP"
@@ -95,9 +106,10 @@ fi
set +e
set -x
RESPONSE=$(curl "$SALSA_URL/projects?search=${DEBPKGNAME}")
-echo $RESPONSE | jq --exit-status "map(select(.path == \"${DEBPKGNAME}\")) | .[0].id" > /dev/null
+PROJECT_ID=`echo $RESPONSE | jq --exit-status "map(select(.path == \"${DEBPKGNAME}\")) | .[0].id"` # > /dev/null
+#echo "$PROJECT_ID"
set -e
-if [ $? -eq 0 ]; then
+if [ "$PROJECT_ID" = "" ]; then
# Seems like not, lets create a project
set -x
echo "Project ${DEBPKGNAME} does not exists on Salsa - just create the project"
@@ -110,14 +122,9 @@ if [ $? -eq 0 ]; then
PROJECT_ID=$(echo $RESPONSE | jq '.id')
set +x
-else
- set -x
- echo "Project ${DEBPKGNAME} exists on Salsa - just update some metadata"
- PROJECT_ID=$(echo $RESPONSE | jq "map(select(.path == \"${DEBPKGNAME}\")) | .[0].id")
- set +x
fi
-remoteOrigin="git at salsa.debian.org:${SALSA_GROUP}/${DEBPKGNAME}.git"
+remoteOrigin=`echo $VCSGIT | sed 's#^https://salsa.debian.org/#git@salsa.debian.org:#'`
if git remote | grep -q origin ; then
echo "I: remote repository 'origin' is already existing"
if git remote -v | grep origin | grep -q "$remoteOrigin"; then
View it on GitLab: https://salsa.debian.org/med-team/community/helper-scripts/-/commit/5038afbb0f77dc877e95fb07060add85dd6acd98
--
View it on GitLab: https://salsa.debian.org/med-team/community/helper-scripts/-/commit/5038afbb0f77dc877e95fb07060add85dd6acd98
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20220317/d239278c/attachment-0001.htm>
More information about the debian-med-commit
mailing list