From 133642b9c5691f8a6f12b06550af6b6ff1fbde90 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Thu, 10 Oct 2024 19:33:36 +0200 Subject: fix[git-devproj]: don’t copy all contributors from the devel project MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also, * instead of hacking XML with RE [1] use xmlstarlet, sed is just not enough any more. * remove 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 --- git-devproj.sh | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'git-devproj.sh') 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/(/\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 -- cgit