v1.1.0; added wait time; removed title; added comment on change; docs++
This commit is contained in:
parent
3e2d080c3d
commit
a3eb327e5b
@ -11,12 +11,13 @@ set -eu
|
|||||||
|
|
||||||
readonly PROGNAME=`/usr/bin/basename $0`
|
readonly PROGNAME=`/usr/bin/basename $0`
|
||||||
readonly PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
|
readonly PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
|
||||||
readonly REVISION="1.0.0"
|
readonly REVISION="1.1.0"
|
||||||
|
|
||||||
repo=""
|
repo=""
|
||||||
login_old=""
|
login_old=""
|
||||||
login_new=""
|
login_new=""
|
||||||
dry_run=true
|
dry_run=true
|
||||||
|
wait_time=0.25
|
||||||
|
|
||||||
#
|
#
|
||||||
# FUNCTIONS
|
# FUNCTIONS
|
||||||
@ -43,10 +44,13 @@ INFORMATION
|
|||||||
- this script will check the OLD and NEW repository for inconsistencies
|
- this script will check the OLD and NEW repository for inconsistencies
|
||||||
- issue-ids are checked; titles are not checked
|
- issue-ids are checked; titles are not checked
|
||||||
- assignments in new repo are checked
|
- assignments in new repo are checked
|
||||||
- if your titles include a ¬ character, the script may could behave funny as this is used as separator
|
- the --wait time slows down the script to reduce e-mail-sending-speed
|
||||||
|
- the title is not fetched due to complications with tea and "quotes"
|
||||||
- Troubleshooting
|
- Troubleshooting
|
||||||
- "Error: could not edit issue:"
|
- "Error: could not edit issue:"
|
||||||
- please check, if the assigned person(s) have the right to be assigned (are they in the Organisation? Collaborators?)
|
- please check, if the assigned person(s) have the right to be assigned (are they in the Organisation? Collaborators?)
|
||||||
|
- "Error: The target couldn't be found."
|
||||||
|
- please check, if the --repo is the same for OLD and NEW
|
||||||
|
|
||||||
INSTALLATION AND PREPARATION
|
INSTALLATION AND PREPARATION
|
||||||
- install
|
- install
|
||||||
@ -68,6 +72,7 @@ USAGE
|
|||||||
-r | --repo required, i.e. "my_organisation/my_repository"
|
-r | --repo required, i.e. "my_organisation/my_repository"
|
||||||
-o | --login_old required, tea-id of your old login
|
-o | --login_old required, tea-id of your old login
|
||||||
-n | --login_new required, tea-id of your new login
|
-n | --login_new required, tea-id of your new login
|
||||||
|
-w | --wait wait time in s between issue handling (default 0.25)
|
||||||
--GO stop dry mode
|
--GO stop dry mode
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
@ -89,7 +94,7 @@ checkCommand()
|
|||||||
# PARAMETERS
|
# PARAMETERS
|
||||||
#
|
#
|
||||||
if [[ "$@" == "" ]] ; then error_in_or_out_not_specified ; fi
|
if [[ "$@" == "" ]] ; then error_in_or_out_not_specified ; fi
|
||||||
readonly TEMP=$(getopt -o h,r:o:n: --long help,GO,repo:login_old:,login_new: -n "${PROGNAME}" -- "$@")
|
readonly TEMP=$(getopt -o h,r:o:n:w: --long help,GO,repo:login_old:,login_new:wait: -n "${PROGNAME}" -- "$@")
|
||||||
eval set -- "${TEMP}"
|
eval set -- "${TEMP}"
|
||||||
while true ; do
|
while true ; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@ -109,6 +114,10 @@ while true ; do
|
|||||||
login_new="$2"
|
login_new="$2"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
--wait|-w)
|
||||||
|
wait_time="$2"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
--GO)
|
--GO)
|
||||||
dry_run=false
|
dry_run=false
|
||||||
;;
|
;;
|
||||||
@ -135,11 +144,11 @@ checkCommand sort
|
|||||||
checkCommand tr
|
checkCommand tr
|
||||||
|
|
||||||
# check access and get data
|
# check access and get data
|
||||||
echo -e "\n# checking access to OLD (\"$login_old\") and NEW (\"$login_new\")"
|
echo "# checking access to OLD (\"$login_old\") and NEW (\"$login_new\")"
|
||||||
readonly json_old=$(tea issues list --output json --login "$login_old" --repo "$repo" --state all --fields index,assignees,title)
|
readonly json_old=$(tea issues list --output json --login "$login_old" --repo "$repo" --state all --fields index,author,assignees)
|
||||||
readonly json_new=$(tea issues list --output json --login "$login_new" --repo "$repo" --state all --fields index,assignees,title)
|
readonly json_new=$(tea issues list --output json --login "$login_new" --repo "$repo" --state all --fields index,author,assignees)
|
||||||
|
|
||||||
echo -e "\n# running consitency checks"
|
echo "# running consistency checks"
|
||||||
readonly json_old_ids=$(echo "$json_old" | jq ".[] | .index" | sort -n)
|
readonly json_old_ids=$(echo "$json_old" | jq ".[] | .index" | sort -n)
|
||||||
readonly json_new_ids=$(echo "$json_new" | jq ".[] | .index" | sort -n)
|
readonly json_new_ids=$(echo "$json_new" | jq ".[] | .index" | sort -n)
|
||||||
# check if issues
|
# check if issues
|
||||||
@ -157,20 +166,30 @@ if [[ "$json_new_assignments" != "" ]]; then echo >&2 "NEW repo already contains
|
|||||||
|
|
||||||
|
|
||||||
# process data
|
# process data
|
||||||
echo -e "\n# processing data"
|
echo "# processing data"
|
||||||
while IFS="¬"; read -r index assignees title; do
|
while IFS="¬"; read -r index author assignees; do
|
||||||
assignees=$(echo "$assignees" | tr ' ' ,)
|
assignees=$(echo "$assignees" | tr ' ' ,)
|
||||||
issueinfo="… issue#$index - \"$title\" - assigned to \"$assignees\""
|
|
||||||
|
|
||||||
|
echo "… #$index - by \"$author\" assigned to \"$assignees\""
|
||||||
|
|
||||||
|
# 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
|
||||||
|
fi
|
||||||
|
|
||||||
|
# assignment
|
||||||
if [[ -n $assignees ]]; then
|
if [[ -n $assignees ]]; then
|
||||||
echo "$issueinfo"
|
|
||||||
if [ $dry_run = false ]; 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 "$repo" --add-assignees "$assignees" "$index" >/dev/null
|
||||||
fi
|
fi
|
||||||
|
echo " → OK"
|
||||||
else
|
else
|
||||||
echo "$issueinfo - SKIPPED"
|
echo " → INFO: added comment, no assignee"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done< <(echo "$json_old" | jq --raw-output '.[] | "\(.index)¬\(.assignees)¬\(.title)"')
|
sleep $wait_time
|
||||||
|
|
||||||
|
done< <(echo "$json_old" | jq --raw-output '.[] | "\(.index)¬\(.author)¬\(.assignees)"')
|
||||||
|
|
||||||
|
echo "# done"
|
||||||
exit 0
|
exit 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user