WIP
This commit is contained in:
parent
84addba2c2
commit
f734790237
@ -5,8 +5,9 @@ readonly PROGNAME=`/usr/bin/basename $0`
|
|||||||
readonly PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
|
readonly PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
|
||||||
readonly REVISION="0.0.1-WIP"
|
readonly REVISION="0.0.1-WIP"
|
||||||
|
|
||||||
repo_in=""
|
repo=""
|
||||||
repo_out=""
|
login_old=""
|
||||||
|
login_new=""
|
||||||
dry_run=true
|
dry_run=true
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -20,7 +21,9 @@ PURPOSE
|
|||||||
this script will start in DRY MODE by default - see --GO parameter
|
this script will start in DRY MODE by default - see --GO parameter
|
||||||
|
|
||||||
INSTALLATION AND PREPERATION
|
INSTALLATION AND PREPERATION
|
||||||
- install tea: https://gitea.com/gitea/tea
|
- install
|
||||||
|
- jq - Command-line JSON processor
|
||||||
|
- tea: https://gitea.com/gitea/tea
|
||||||
- create Gitea tokens for tea
|
- create Gitea tokens for tea
|
||||||
- permissions on the OLD system:
|
- permissions on the OLD system:
|
||||||
- user: read
|
- user: read
|
||||||
@ -33,25 +36,32 @@ INSTALLATION AND PREPERATION
|
|||||||
- tea login add --name NEW --url https://newgitea.example.com --token 123459789123456789
|
- tea login add --name NEW --url https://newgitea.example.com --token 123459789123456789
|
||||||
|
|
||||||
USAGE
|
USAGE
|
||||||
-h | --help print this help
|
-h | --help print this help
|
||||||
-i | -in required, i.e. https://oldgitea.example.com/my_old_repo
|
-r | --repo required, i.e. "my_organisation/my_repository"
|
||||||
-o | -out required, i.e. https://newgitea.example.com/my_new_repo
|
-o | --login_old required, tea-id of your old login
|
||||||
--GO stop dry mode
|
-n | --login_new required, tea-id of your new login
|
||||||
|
--GO stop dry mode
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
error_in_or_out_not_specified()
|
error_in_or_out_not_specified()
|
||||||
{
|
{
|
||||||
echo -e "Error: --in and --out must be specified\n";
|
echo -e "Error: --repo, --login_old and --login_new must be specified\n";
|
||||||
print_help;
|
print_help;
|
||||||
exit 2
|
exit 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# @param $1 "command" → the command to check for
|
||||||
|
checkCommand()
|
||||||
|
{
|
||||||
|
command -v "$1" >/dev/null 2>&1 || { echo >&2 "Command ${1} is required but it's not installed. Aborting."; exit 42; }
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# PARAMETERS
|
# PARAMETERS
|
||||||
#
|
#
|
||||||
if [[ "$@" == "" ]] ; then error_in_or_out_not_specified ; fi
|
if [[ "$@" == "" ]] ; then error_in_or_out_not_specified ; fi
|
||||||
TEMP=$(getopt -o hi:o: --long help,GO,in:,out: -n "${PROGNAME}" -- "$@")
|
TEMP=$(getopt -o h,r:o:n: --long help,GO,repo:login_old:,login_new: -n "${PROGNAME}" -- "$@")
|
||||||
eval set -- "${TEMP}"
|
eval set -- "${TEMP}"
|
||||||
while true ; do
|
while true ; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@ -59,12 +69,16 @@ while true ; do
|
|||||||
print_help
|
print_help
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
--in|-i)
|
--repo|-r)
|
||||||
repo_in="$2"
|
repo="$2"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--out|-o)
|
--login_old|-o)
|
||||||
repo_out="$2"
|
login_old="$2"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--login_new|-n)
|
||||||
|
login_new="$2"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--GO)
|
--GO)
|
||||||
@ -79,20 +93,28 @@ while true ; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
# check required
|
# check required
|
||||||
if [[ -z "$repo_in" || -z "$repo_out" ]] ; then error_in_or_out_not_specified ; fi
|
if [[ -z "$repo" || -z "$login_old" || -z "$login_new" ]] ; then error_in_or_out_not_specified ; fi
|
||||||
|
|
||||||
#
|
#
|
||||||
# START
|
# START
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# check commands
|
||||||
|
checkCommand tea
|
||||||
|
checkCommand jq
|
||||||
|
|
||||||
|
|
||||||
if $dry_run; then echo -e "###\n### DRY RUN - will not change anything\n###"; fi
|
if $dry_run; then echo -e "###\n### DRY RUN - will not change anything\n###"; fi
|
||||||
|
|
||||||
|
str=$(tea issues list --output json --login "$login_old" --repo "$repo" --fields index,title,assignees)
|
||||||
|
|
||||||
|
while IFS="¬"; read -r index title assignees; do
|
||||||
|
echo "processing issue #${index} - \"${title}\", assigned to ${assignees}"
|
||||||
|
done< <(echo "$str" | jq --raw-output '.[] | "\(.index)¬\(.title)¬\(.assignees)"')
|
||||||
|
|
||||||
|
|
||||||
|
#tea issues list --output simple --login NEW
|
||||||
|
#tea issues list --output simple --login NEW --repo eine_tolle_organisation/ein_tolles_repository
|
||||||
|
|
||||||
tea issues list --output simple --login NEW
|
|
||||||
tea issues list --output simple --login NEW --repo eine_tolle_organisation/ein_tolles_repository
|
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user