get wiki link from source repo and use it
This commit is contained in:
parent
5199f9ea5e
commit
840b9e9057
@ -156,7 +156,6 @@ RESPONSE=$(curl "$SILENT" "$checkSSL" -X 'POST' \
|
|||||||
-H "Authorization: token $SOURCEACCESSTOKEN" \
|
-H "Authorization: token $SOURCEACCESSTOKEN" \
|
||||||
-d '{
|
-d '{
|
||||||
"name": "'"$TARGETPKG"'",
|
"name": "'"$TARGETPKG"'",
|
||||||
"description": "'"SMEServer Koozali developed git repo for $TARGETPKG base"'"
|
|
||||||
}')
|
}')
|
||||||
|
|
||||||
# create a Bugzilla URL
|
# create a Bugzilla URL
|
||||||
@ -165,32 +164,16 @@ if [[ "$SOURCEORG" == "smecontribs" ]]; then
|
|||||||
PRODUCTBUGZILLA="SME%20Contribs"
|
PRODUCTBUGZILLA="SME%20Contribs"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# find the relevant wiki entry
|
# grab WIKILINK from source package
|
||||||
WIKILINK="https://wiki.koozali.org"
|
RESPONSE=$(curl "SILENT" -X 'GET' \
|
||||||
MEDIAWIKI_SITE="https://wiki.koozali.org/api.php"
|
"https://src.koozali.org/api/v1/repos/$SOURCEORG/$SOURCEPKG" \
|
||||||
SEARCH_TERM=${SOURCEPKG/e-smith-/}
|
-H 'accept: application/json' \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
# Call the API to perform the search and store the JSON response in a variable
|
-H "Authorization: token $SOURCEACCESSTOKEN" \
|
||||||
RESPONSE=$(curl -s "$MEDIAWIKI_SITE?action=query&format=json&list=search&srsearch=${SEARCH_TERM}&srprop=size%7Cwordcount%7Ctimestamp%7Csnippet&srlimit=10")
|
)
|
||||||
|
WIKILINK=$(echo $RESPONSE | jq ' .external_wiki.external_wiki_url')
|
||||||
# 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 "<br />${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}" )
|
|
||||||
|
|
||||||
|
# Update the repo with the changed description, bugzilla url and wiki url
|
||||||
if [ $DEBUG ] ; then echo "Updating Description, Bug and Wiki links" ; fi
|
if [ $DEBUG ] ; then echo "Updating Description, Bug and Wiki links" ; fi
|
||||||
RESPONSE=$(curl "$SILENT" "$checkSSL" -X 'PATCH' \
|
RESPONSE=$(curl "$SILENT" "$checkSSL" -X 'PATCH' \
|
||||||
"$SOURCEHOST/api/v1/repos/$TARGETORG/$TARGETPKG" \
|
"$SOURCEHOST/api/v1/repos/$TARGETORG/$TARGETPKG" \
|
||||||
|
Loading…
Reference in New Issue
Block a user