gitea_assignment_migrator/migrate_assignments.sh
2024-02-22 16:49:17 +01:00

99 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
set -eu
readonly PROGNAME=`/usr/bin/basename $0`
readonly PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
readonly REVISION="0.0.1-WIP"
repo_in=""
repo_out=""
dry_run=true
#
# FUNCTIONS
#
print_help()
{
cat << "EOF"
PURPOSE
this script will start in DRY MODE by default - see --GO parameter
INSTALLATION AND PREPERATION
- install tea: https://gitea.com/gitea/tea
- create Gitea tokens for tea
- permissions on the OLD system:
- user: read
- issue: read
- permissions on the NEW system:
- user: read
- issue: read and write
- set up login via tea → "tea login add --help", i.e.
- tea login add --name OLD --url https://oldgitea.example.com --token 123456789123456789
- tea login add --name NEW --url https://newgitea.example.com --token 123459789123456789
USAGE
-h | --help print this help
-i | -in required, i.e. https://oldgitea.example.com/my_old_repo
-o | -out required, i.e. https://newgitea.example.com/my_new_repo
--GO stop dry mode
EOF
}
error_in_or_out_not_specified()
{
echo -e "Error: --in and --out must be specified\n";
print_help;
exit 2
}
#
# PARAMETERS
#
if [[ "$@" == "" ]] ; then error_in_or_out_not_specified ; fi
TEMP=$(getopt -o hi:o: --long help,GO,in:,out: -n "${PROGNAME}" -- "$@")
eval set -- "${TEMP}"
while true ; do
case "$1" in
--help|-h)
print_help
exit 0
;;
--in|-i)
repo_in="$2"
shift
;;
--out|-o)
repo_out="$2"
shift
;;
--GO)
dry_run=false
;;
--) shift ; break ;;
*) echo "Internal error!"
exit 5
;;
esac
shift
done
# check required
if [[ -z "$repo_in" || -z "$repo_out" ]] ; then error_in_or_out_not_specified ; fi
#
# START
#
if $dry_run; then echo -e "###\n### DRY RUN - will not change anything\n###"; fi
tea issues list --output simple --login NEW
tea issues list --output simple --login NEW --repo eine_tolle_organisation/ein_tolles_repository
exit 0