add review option

This commit is contained in:
Trevor Batley 2023-05-12 08:39:20 +10:00
parent 11f2f53a3e
commit 4a855c986b

View File

@ -32,10 +32,12 @@ while read -r line || [[ -n "$line" ]]; do
done < "$inifilename"
if [[ -z $1 ]] ; then
echo "migrate-org.sh <source organisation> [<target organisation>]"
echo "migrate-org.sh <source organisation> [<target organisation> <review>]"
echo "<target organisation> is optional and will default to the gitea user"
echo "<review> is optional and will echo the changes, but not execute"
exit 0
fi
DEBUG=
curlsilent="-s"
if [ ${smegit_DEBUG} == true ] ; then DEBUG=true ; fi
@ -43,13 +45,15 @@ if [ $DEBUG ] ; then
echo "found ini file: $inifilename"
curlsilent="-v"
fi
MIRROR="copy"
TARGETORG=
#if [ $2 ] ; then TARGETORG=$2 ; fi
for $param in $2 $3 ; do
for $param in $2 $3 $4; do
if [ $param ] ; then
if [[ $param == "copy" || $param == "mirror" ]] ; then
MIRROR=$param
elif [[ $param == "review"]] ; then
REVIEW=true
else
TARGETORG=$param
fi
@ -58,7 +62,6 @@ for $param in $2 $3 ; do
fi
done
REMOTEACCESSTOKEN=${remote_GITEAACCESSTOKEN}
LOCALACCESSTOKEN=${local_GITEAACCESSTOKEN}
REMOTEGITEAHOST=${remote_GITEAHOST}
@ -74,6 +77,17 @@ if [[ "$RESPONSE" != "200" ]] ; then
exit 1
fi
if [[ ! $REVIEW ]] ; then
while true; do
read -p "Are you sure?(y/n) " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
fi
# get a list of repositories in the source organisation
for page in {1..10} ; do
if [ $DEBUG ] ; then echo "getting page $page of repos from $REMOTEGITHOST $1" ; fi
@ -90,7 +104,11 @@ for page in {1..10} ; do
else
echo $RESPONSE | grep -oP '(?<="name":").+?(?=")' | while read repo; do
if [ $DEBUG ] ; then echo "git-migrate-repo.sh ${repo} $1 $TARGETORG $MIRROR" ; fi
git-migrate-repo.sh ${repo} $1 $TARGETORG $MIRROR
if [[ $REVIEW ]] ; then
echo "git-migrate-repo.sh ${repo} $1 $TARGETORG $MIRROR"
else
git-migrate-repo.sh ${repo} $1 $TARGETORG $MIRROR
fi
done
fi
done