From b497a006933e6a2915ec8fa9b53f8004e7005c57 Mon Sep 17 00:00:00 2001 From: Trevor Batley Date: Sun, 4 Jun 2023 17:00:24 +1000 Subject: [PATCH] change to migrate rather than fork --- rename-e-smith-pkg.sh | 79 ++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 35 deletions(-) diff --git a/rename-e-smith-pkg.sh b/rename-e-smith-pkg.sh index 663d48a..9181595 100755 --- a/rename-e-smith-pkg.sh +++ b/rename-e-smith-pkg.sh @@ -148,52 +148,61 @@ fi #Fork e-smith- into users repositories as smeserver- # - add bugzilla and wiki references -if [ $DEBUG ] ; then echo "Forking $SORCEORG/$SOURCEPKG into $TARGETORG/$TARGETPKG!" ; fi -RESPONSE=$(curl "$SILENT" "$checkSSL" -X 'POST' \ - "$SOURCEHOST/api/v1/repos/$SOURCEORG/$SOURCEPKG/forks" \ - -H 'accept: application/json' \ - -H 'Content-Type: application/json' \ - -H "Authorization: token $SOURCEACCESSTOKEN" \ - -d '{ - "name": "'"$TARGETPKG"'" - }') - # create a Bugzilla URL PRODUCTBUGZILLA="SME%20Server%2010.X" +BASEORCONTRIB="base" if [[ "$SOURCEORG" == "smecontribs" ]]; then PRODUCTBUGZILLA="SME%20Contribs" + BASEORCONTRIB="contrib" fi # grab WIKILINK from source package -WIKILINK=$(curl "$SILENT" -X 'GET' \ - "$SOURCEHOST/api/v1/repos/$SOURCEORG/$SOURCEPKG" \ - -H 'accept: application/json' \ - -H 'Content-Type: application/json' \ - -H "Authorization: token $SOURCEACCESSTOKEN" | \ - jq -r ' .external_wiki.external_wiki_url') -if [ $DEBUG ] ; then echo "WIKILINK=$WIKILINK" ; fi +#WIKILINK=$(curl "$SILENT" -X 'GET' \ +# "$SOURCEHOST/api/v1/repos/$SOURCEORG/$SOURCEPKG" \ +# -H 'accept: application/json' \ +# -H 'Content-Type: application/json' \ +# -H "Authorization: token $SOURCEACCESSTOKEN" | \ +# jq -r ' .external_wiki.external_wiki_url') +#if [ $DEBUG ] ; then echo "WIKILINK=$WIKILINK" ; fi -# Update the repo with the changed description, bugzilla url and wiki url -if [ $DEBUG ] ; then echo "Updating Description, Bug and Wiki links" ; fi -RESPONSE=$(curl "$SILENT" "$checkSSL" -X 'PATCH' \ - "$SOURCEHOST/api/v1/repos/$TARGETORG/$TARGETPKG" \ - -H 'accept: application/json' \ - -H "Authorization: token $SOURCEACCESSTOKEN" \ - -H 'Content-Type: application/json' \ - -d '{ - "description": "'"SMEServer Koozali developed repo for $TARGETPKG base"'", - "has_issues": true, +# migrate the source package over to target with updated fields +if [ $DEBUG ] ; then echo "Migrating $SOURCEORG/$SOURCEPKG as $TARGETORG/$1 on $TARGETHOST" ; fi +RESPONSE=$(curl $SILENT -k -X 'POST' \ + "$TARGETHOST/api/v1/repos/migrate" \ + -H 'accept: application/json' \ + -H "Authorization: token $TARGETACCESSTOKEN" \ + -H 'Content-Type: application/json' \ + -d '{ + "description": "'"SMEServer Koozali developed git repo for $TARGETPKG $BASEORCONTRIB"'", + "clone_addr": "'"$TARGETHOST/$TARGETORG/$TARGETPKG.git"'", + "repo_name": "'"$TARGETPKG"'", + "repo_owner": "'"$TARGETORG"'", "external_tracker": { - "external_tracker_format": "https://bugs.koozali.org/show_bug.cgi?id={index}", - "external_tracker_style": "numeric", "external_tracker_url": "'"https://bugs.koozali.org/buglist.cgi?component=$TARGETPKG&product=$PRODUCTBUGZILLA"'" - }, - "has_wiki": true, - "external_wiki": { - "external_wiki_url": "'"$WIKILINK"'" } - }' - ) + }' + ) +# Update the repo with the changed description, bugzilla url and wiki url +#if [ $DEBUG ] ; then echo "Updating Description, Bug and Wiki links" ; fi +#RESPONSE=$(curl "$SILENT" "$checkSSL" -X 'PATCH' \ +# "$SOURCEHOST/api/v1/repos/$TARGETORG/$TARGETPKG" \ +# -H 'accept: application/json' \ +# -H "Authorization: token $SOURCEACCESSTOKEN" \ +# -H 'Content-Type: application/json' \ +# -d '{ +# "description": "'"SMEServer Koozali developed repo for $TARGETPKG base"'", +# "has_issues": true, +# "external_tracker": { +# "external_tracker_format": "https://bugs.koozali.org/show_bug.cgi?id={index}", +# "external_tracker_style": "numeric", +# "external_tracker_url": "'"https://bugs.koozali.org/buglist.cgi?component=$TARGETPKG&product=$PRODUCTBUGZILLA"'" +# }, +# "has_wiki": true, +# "external_wiki": { +# "external_wiki_url": "'"$WIKILINK"'" +# } +# }' +# ) # Create the local Git repository GITFiles=$WORKDIR/GITFiles/$TARGETORG