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" \
|
||||
-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 "<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}" )
|
||||
# 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"'"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user