v1.5.0 added function to update to a renamed repository
This commit is contained in:
parent
77eabbc0ee
commit
541e4a00bd
@ -11,9 +11,10 @@ set -eu
|
||||
|
||||
readonly PROGNAME=`/usr/bin/basename $0`
|
||||
readonly PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
|
||||
readonly REVISION="1.4.0"
|
||||
readonly REVISION="1.5.0"
|
||||
|
||||
repo=""
|
||||
repo="" # the OLD repo
|
||||
transfer="" # the NEW repo
|
||||
login_old=""
|
||||
login_new=""
|
||||
dry_run=true
|
||||
@ -75,6 +76,8 @@ USAGE
|
||||
|
||||
PARAMETERS
|
||||
-r | --repo required, i.e. "my_organisation/my_repository"
|
||||
-t | --transfer optional, if the new repo has another organisation / name
|
||||
if not set transfer is set to "repo"
|
||||
-o | --login_old required, tea-id of your old login
|
||||
-n | --login_new required, tea-id of your new login
|
||||
-w | --wait wait time in s between issue handling (default 0.25)
|
||||
@ -125,7 +128,7 @@ get_all_data_from_gitea ()
|
||||
# PARAMETERS
|
||||
#
|
||||
if [[ "$@" == "" ]] ; then error_in_or_out_not_specified ; fi
|
||||
readonly TEMP=$(getopt -o h,r:o:n:w:c --long help,GO,colour,color,repo:,login_old:,login_new:,wait: -n "${PROGNAME}" -- "$@")
|
||||
readonly TEMP=$(getopt -o h,r:t:o:n:w:c --long help,GO,colour,color,repo:,transfer:,login_old:,login_new:,wait: -n "${PROGNAME}" -- "$@")
|
||||
eval set -- "${TEMP}"
|
||||
while true ; do
|
||||
case "$1" in
|
||||
@ -140,6 +143,10 @@ while true ; do
|
||||
repo="$2"
|
||||
shift
|
||||
;;
|
||||
--transfer|-t)
|
||||
transfer="$2"
|
||||
shift
|
||||
;;
|
||||
--login_old|-o)
|
||||
login_old="$2"
|
||||
shift
|
||||
@ -163,8 +170,12 @@ while true ; do
|
||||
shift
|
||||
done
|
||||
|
||||
if [[ "$transfer" == "" ]]; then
|
||||
transfer="$repo"
|
||||
fi
|
||||
|
||||
# check required
|
||||
if [[ -z "$repo" || -z "$login_old" || -z "$login_new" ]] ; then error_in_or_out_not_specified ; fi
|
||||
if [[ -z "$repo" || -z "$transfer" || -z "$login_old" || -z "$login_new" ]] ; then error_in_or_out_not_specified ; fi
|
||||
|
||||
#
|
||||
# START
|
||||
@ -188,7 +199,7 @@ checkCommand tr
|
||||
echo "# checking access to OLD (\"$login_old\") and NEW (\"$login_new\")"
|
||||
|
||||
readonly json_old=$(get_all_data_from_gitea "$login_old" "$repo")
|
||||
readonly json_new=$(get_all_data_from_gitea "$login_new" "$repo")
|
||||
readonly json_new=$(get_all_data_from_gitea "$login_new" "$transfer")
|
||||
|
||||
echo "# running consistency checks"
|
||||
readonly json_old_ids=$(echo "$json_old" | jq ".[] | .index" | sort -n)
|
||||
@ -216,14 +227,14 @@ while IFS="¬"; read -r index author assignees; do
|
||||
|
||||
# comment for the original author
|
||||
if [ $dry_run = false ]; then
|
||||
echo "migrator: this issue was created by @$author and will be assigned to '$assignees'" | tea comment --login "$login_new" --repo "$repo" "$index" >/dev/null
|
||||
echo "migrator: this issue was created by @$author and will be assigned to '$assignees'" | tea comment --login "$login_new" --repo "$transfer" "$index" >/dev/null
|
||||
fi
|
||||
|
||||
# assignment
|
||||
t="OK"
|
||||
if [[ -n $assignees ]]; then
|
||||
if [ $dry_run = false ]; then
|
||||
tea issue edit --login "$login_new" --repo "$repo" --add-assignees "$assignees" "$index" >/dev/null
|
||||
tea issue edit --login "$login_new" --repo "$transfer" --add-assignees "$assignees" "$index" >/dev/null
|
||||
fi
|
||||
else
|
||||
t="OK (no assignee)"
|
||||
|
Loading…
x
Reference in New Issue
Block a user