aboutsummaryrefslogtreecommitdiffstats
path: root/git-devproj.sh
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2024-10-10 19:33:36 +0200
committerMatěj Cepl <mcepl@cepl.eu>2024-10-14 11:11:20 +0200
commit133642b9c5691f8a6f12b06550af6b6ff1fbde90 (patch)
tree8c60ae62328e40a0a75773bd2d98d47b0ba4a893 /git-devproj.sh
parent9798a36af47c5ee21c85bff9b6a01dc631b9ddcd (diff)
downloadgosc-133642b9c5691f8a6f12b06550af6b6ff1fbde90.tar.gz
fix[git-devproj]: don’t copy all contributors from the devel projectHEADmaster
Also, * instead of hacking XML with RE [1] use xmlstarlet, sed is just not enough any more. * remove <group> elements as well, we don’t want to copy group ownerships of the parent group * set also the name attribute of the child project configuration, OBS fails otherwise * check the project via API, don't rely on $(pwd) * don't rely on name of the directory, use .osc/_project Yes, xmlstarlet is unusual dependency, but it seems to work well and it is in Tumbelweed. [1] https://stackoverflow.com/a/1732454/164233
Diffstat (limited to 'git-devproj.sh')
-rwxr-xr-xgit-devproj.sh21
1 files changed, 15 insertions, 6 deletions
diff --git a/git-devproj.sh b/git-devproj.sh
index 2565e24..1d1cb04 100755
--- a/git-devproj.sh
+++ b/git-devproj.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# Requires: coreutils, curl, jq, git
+# Requires: coreutils, osc, xmlstarlet, git
set -ue
usage () {
@@ -18,6 +18,10 @@ die () {
OBS_LOGIN="$(osc who |cut -d: -f 1)"
+# If we are in a project checkout, what's its name?
+CUR_PRJ=""
+[ -d '.osc/' ] && CUR_PRJ="$(cat .osc/_project)"
+
# Do we have our own configuration for MYORG?
MYORG="$(git config --get --default '' obs.org)"
[ -z "${MYORG}" ] && MYORG="${OBS_LOGIN}"
@@ -33,7 +37,7 @@ fi
if [ $# -gt 2 ] ; then
if [ "$3" = "." ] ; then
- TRGPRJ="$(basename "$(pwd -P)")"
+ TRGPRJ="$CUR_PRJ"
else
TRGPRJ="$3"
fi
@@ -45,10 +49,15 @@ fi
# we have to encode \# as %23.
SCM_URL="https://src.opensuse.org/${MYORG}/${PKG}"
-if [ "x$(basename "$(pwd -P)")" != "x$TRGPRJ" ] ; then
- if [ ! -d "$TRGPRJ" ] ; then
- osc meta prj "$SRCPRJ" | sed -E -e 's/(<project name=")([^"]+)">/\1'"$TRGPRJ"'">/' \
- | osc meta prj -F - "$TRGPRJ"
+if [ "x$CUR_PRJ" != "x$TRGPRJ" ] ; then
+ if ! osc ls "$TRGPRJ" >/dev/null 2>&1 ; then
+ osc meta prj "$SRCPRJ" \
+ | xmlstarlet ed \
+ -d "/project/person[@userid!='${OBS_LOGIN}']" \
+ -d "/project/group" \
+ -u "/project/@name" -v "$TRGPRJ" \
+ -u "/project/title" -v "Development branch of ${SRCPRJ}" \
+ | osc meta prj -F - "$TRGPRJ"
osc meta prjconf "$SRCPRJ" | osc meta prjconf -F - "$TRGPRJ"
fi