add back in update of external issues and wiki

This commit is contained in:
Trevor Batley 2023-06-05 08:52:52 +10:00
parent ce96666422
commit a7b3cda711

View File

@ -64,7 +64,7 @@ else
WORKDIR=${smegit_WORKDIR}
fi
SOURCEHOST=${remote_GITEAHOST}
GITEAHOST=${remote_GITEAHOST}
SOURCEACCESSTOKEN=${remote_GITEAACCESSTOKEN}
SOURCEORG="smeserver"
TARGETORG=${remote_USER}
@ -74,7 +74,7 @@ for param in $2 $3 $4 $5 $6; do
if [ $param ] ; then
case $param in
local )
SOURCEHOST=${local_GITEAHOST}
GITEAHOST=${local_GITEAHOST}
SOURCEACCESSTOKEN=${local_GITEAACCESSTOKEN}
TARGETORG=${local_USER} ;;
force )
@ -107,17 +107,17 @@ TARGETPKG=${SOURCEPKG/e-smith/smeserver}
#Check that source package exists
if [ $DEBUG ] ; then echo "Check if $SOURCEORG/$SOURCEPKG is there!" ; fi
RESPONSE=$(curl $SILENT -o /dev/null -w "%{http_code}" "$SOURCEHOST/api/v1/repos/$SOURCEORG/$SOURCEPKG")
RESPONSE=$(curl $SILENT -o /dev/null -w "%{http_code}" "$GITEAHOST/api/v1/repos/$SOURCEORG/$SOURCEPKG")
if [ "$RESPONSE" == "200" ]; then
if [ $DEBUG ] ; then echo "Repository for $SOURCEORG/$SOURCEPKG exists!" ; fi
else
echo "************Repository for $SOURCEORG/$SOURCEPKG does not exist on $SOURCEHOST ($RESPONSE)"
echo "************Repository for $SOURCEORG/$SOURCEPKG does not exist on $GITEAHOST ($RESPONSE)"
exit 1
fi
#Check that target package does not exist
if [ $DEBUG ] ; then echo "Check if $TARGETORG/$TARGETPKG is there!" ; fi
RESPONSE=$(curl $SILENT -o /dev/null -w "%{http_code}" "$SOURCEHOST/api/v1/repos/$TARGETORG/$TARGETPKG")
RESPONSE=$(curl $SILENT -o /dev/null -w "%{http_code}" "$GITEAHOST/api/v1/repos/$TARGETORG/$TARGETPKG")
if [ "$RESPONSE" == "200" ]; then
if [ $DEBUG ] ; then echo "Repository for $TARGETORG/$TARGETPKG exists!" ; fi
if [ -z ${DELETEIT} ] ; then
@ -128,7 +128,7 @@ if [ "$RESPONSE" == "200" ]; then
DELETEIT=true
break ;;
[Nn]* )
echo "************Abandoning Fork of $SOURCEORG/$SOURCEPKG on $SOURCEHOST ($RESPONSE)"
echo "************Abandoning Fork of $SOURCEORG/$SOURCEPKG on $GITEAHOST ($RESPONSE)"
exit 1 ;;
* ) echo "Please answer yes or no.";;
esac
@ -137,12 +137,12 @@ if [ "$RESPONSE" == "200" ]; then
if [ $DELETEIT ] ; then
if [ $DEBUG ] ; then echo "Deleting $TARGETORG/$TARGETPKG" ; fi
RESPONSE=$(curl "$checkSSL" "$SILENT" -X 'DELETE' \
"$SOURCEHOST/api/v1/repos/$TARGETORG/$TARGETPKG" \
"$GITEAHOST/api/v1/repos/$TARGETORG/$TARGETPKG" \
-H 'accept: application/json' \
-H "Authorization: token $SOURCEACCESSTOKEN" )
fi
else
if [ $DEBUG ] ; then echo "Repository for $TARGETORG/$TARGETPKG does not exist on $SOURCEHOST" ; fi
if [ $DEBUG ] ; then echo "Repository for $TARGETORG/$TARGETPKG does not exist on $GITEAHOST" ; fi
fi
#Fork e-smith-<pkg> into users repositories as smeserver-<pkg>
@ -156,62 +156,52 @@ if [[ "$SOURCEORG" == "smecontribs" ]]; then
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
# 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' \
"$SOURCEHOST/api/v1/repos/migrate" \
"$GITEAHOST/api/v1/repos/migrate" \
-H 'accept: application/json' \
-H "Authorization: token $SOURCEACCESSTOKEN" \
-H 'Content-Type: application/json' \
-d '{
"auth_token": "'"$SOURCEACCESSTOKEN"'",
"clone_addr": "'"$SOURCEHOST/$SOURCEORG/$SOURCEPKG.git"'",
"clone_addr": "'"$GITEAHOST/$SOURCEORG/$SOURCEPKG.git"'",
"description": "'"SMEServer Koozali developed git repo for $TARGETPKG $BASEORCONTRIB"'",
"repo_name": "'"$TARGETPKG"'",
"repo_owner": "'"$TARGETORG"'",
"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"'"
}
"repo_owner": "'"$TARGETORG"'"
}'
)
# 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"'"
# }
# }'
# )
# Migrate does NOT copy accross the issues and wiki external links
# grab WIKILINK from source package
WIKILINK=$(curl "$SILENT" -X 'GET' \
"$GITEAHOST/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 bugzilla url and original wiki url
if [ $DEBUG ] ; then echo "Updating Description, Bug and Wiki links" ; fi
RESPONSE=$(curl "$SILENT" "$checkSSL" -X 'PATCH' \
"$GITEAHOST/api/v1/repos/$TARGETORG/$TARGETPKG" \
-H 'accept: application/json' \
-H "Authorization: token $SOURCEACCESSTOKEN" \
-H 'Content-Type: application/json' \
-d '{
"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
@ -225,9 +215,9 @@ if [ -d "$TARGETPKG" ] ; then
fi
# Clone the package
if [ $DEBUG ] ; then echo "git clone $SOURCEHOST/$TARGETORG/$TARGETPKG.git" ; fi
if [ $DEBUG ] ; then echo "git clone $GITEAHOST/$TARGETORG/$TARGETPKG.git" ; fi
cd $GITFiles
git clone "$SOURCEHOST/$TARGETORG/$TARGETPKG.git" $QUIET
git clone "$GITEAHOST/$TARGETORG/$TARGETPKG.git" $QUIET
cd $GITFiles/$TARGETPKG
#Update README.md