From 840b9e9057a968740229354b78e13514f9bb9663 Mon Sep 17 00:00:00 2001 From: Trevor Batley Date: Sat, 3 Jun 2023 12:11:10 +1000 Subject: [PATCH] get wiki link from source repo and use it --- rename-e-smith-pkg.sh | 47 ++++++++++++++----------------------------- 1 file changed, 15 insertions(+), 32 deletions(-) diff --git a/rename-e-smith-pkg.sh b/rename-e-smith-pkg.sh index 50b260f..226c4f4 100755 --- a/rename-e-smith-pkg.sh +++ b/rename-e-smith-pkg.sh @@ -156,7 +156,6 @@ RESPONSE=$(curl "$SILENT" "$checkSSL" -X 'POST' \ -H "Authorization: token $SOURCEACCESSTOKEN" \ -d '{ "name": "'"$TARGETPKG"'", - "description": "'"SMEServer Koozali developed git repo for $TARGETPKG base"'" }') # create a Bugzilla URL @@ -165,32 +164,16 @@ if [[ "$SOURCEORG" == "smecontribs" ]]; then PRODUCTBUGZILLA="SME%20Contribs" fi -# find the relevant wiki entry -WIKILINK="https://wiki.koozali.org" -MEDIAWIKI_SITE="https://wiki.koozali.org/api.php" -SEARCH_TERM=${SOURCEPKG/e-smith-/} - -# Call the API to perform the search and store the JSON response in a variable -RESPONSE=$(curl -s "$MEDIAWIKI_SITE?action=query&format=json&list=search&srsearch=${SEARCH_TERM}&srprop=size%7Cwordcount%7Ctimestamp%7Csnippet&srlimit=10") - -# Use jq to extract the titles and pageids of the pages that match the search term (case-insensitive) -RESULTS=$(echo "$RESPONSE" | jq -r '.query.search[] | select(.title | ascii_downcase | contains("'"${SEARCH_TERM}"'" | ascii_downcase)) | .title, .pageid') - -# Loop through the results and construct the URL for each page -URLS=$(while read -r TITLE; do \ - read -r PAGEID; \ - URL="https://wiki.koozali.org/${TITLE}"; \ - URL=$(echo $URL | sed 's/ /_/g'); \ - echo "
${URL}"; \ -done <<< "${RESULTS}" ) -# and get the first non french (sorry JP!) -WIKILINK=$(while read -r TITLE; do \ - read -r PAGEID; \ - URL="https://wiki.koozali.org/${TITLE}"; \ - URL=$(echo $URL | sed 's/ /_/g'); \ - if [[ ! "$URL" =~ 'fr' ]] ; then echo "${URL}"; break; fi \ -done <<< "${RESULTS}" ) +# grab WIKILINK from source package +RESPONSE=$(curl "SILENT" -X 'GET' \ + "https://src.koozali.org/api/v1/repos/$SOURCEORG/$SOURCEPKG" \ + -H 'accept: application/json' \ + -H 'Content-Type: application/json' \ + -H "Authorization: token $SOURCEACCESSTOKEN" \ + ) +WIKILINK=$(echo $RESPONSE | jq ' .external_wiki.external_wiki_url') +# 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" \ @@ -199,13 +182,13 @@ RESPONSE=$(curl "$SILENT" "$checkSSL" -X 'PATCH' \ -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_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, + "has_wiki": true, "external_wiki": { "external_wiki_url": "'"$WIKILINK"'" }