v1.4.0 added pagination (server defines max-limit)
This commit is contained in:
parent
7051919aeb
commit
77eabbc0ee
@ -11,7 +11,7 @@ set -eu
|
||||
|
||||
readonly PROGNAME=`/usr/bin/basename $0`
|
||||
readonly PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
|
||||
readonly REVISION="1.3.2"
|
||||
readonly REVISION="1.4.0"
|
||||
|
||||
repo=""
|
||||
login_old=""
|
||||
@ -23,7 +23,7 @@ use_colour=true
|
||||
#
|
||||
# FUNCTIONS
|
||||
#
|
||||
print_help()
|
||||
print_help ()
|
||||
{
|
||||
echo "--- $PROGNAME $REVISION"
|
||||
cat << "EOF"
|
||||
@ -81,7 +81,7 @@ USAGE
|
||||
EOF
|
||||
}
|
||||
|
||||
error_in_or_out_not_specified()
|
||||
error_in_or_out_not_specified ()
|
||||
{
|
||||
echo -e "Error: --repo, --login_old and --login_new must be specified\n";
|
||||
print_help;
|
||||
@ -89,11 +89,38 @@ error_in_or_out_not_specified()
|
||||
}
|
||||
|
||||
# @param $1 "command" → the command to check for
|
||||
checkCommand()
|
||||
checkCommand ()
|
||||
{
|
||||
command -v "$1" >/dev/null 2>&1 || { echo >&2 "Command ${1} is required but it's not installed. Aborting."; exit 42; }
|
||||
}
|
||||
|
||||
# collects all data from the given gitea instance+repo,
|
||||
# uses pagination to really get all data (limit may be set by the server)
|
||||
# get_all_data_from_gitea "$login_old" "$repo"
|
||||
get_all_data_from_gitea ()
|
||||
{
|
||||
local readonly l="$1"
|
||||
local readonly r="$2"
|
||||
|
||||
local _collect=""
|
||||
local _page=1
|
||||
while true; do
|
||||
# get data from repo and remove [ and ]
|
||||
local _tmp=$(tea issues list --output json --login "$l" --repo "$r" --state all --limit 100 --fields index,author,assignees --page $_page | sed 's/\[//g' | sed 's/\]//g')
|
||||
if [[ $(echo "[$_tmp]" | jq length) -eq 0 ]]; then
|
||||
break
|
||||
fi
|
||||
if [[ -z "$_collect" ]] then
|
||||
_collect="$_tmp"
|
||||
else
|
||||
_collect="$_collect,$_tmp"
|
||||
fi
|
||||
_page=$(($_page+1));
|
||||
done
|
||||
echo "[$_collect]"
|
||||
return 0;
|
||||
}
|
||||
|
||||
#
|
||||
# PARAMETERS
|
||||
#
|
||||
@ -159,8 +186,9 @@ checkCommand tr
|
||||
|
||||
# check access and get data
|
||||
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 --limit 99999 --fields index,author,assignees)
|
||||
readonly json_new=$(tea issues list --output json --login "$login_new" --repo "$repo" --state all --limit 99999 --fields index,author,assignees)
|
||||
|
||||
readonly json_old=$(get_all_data_from_gitea "$login_old" "$repo")
|
||||
readonly json_new=$(get_all_data_from_gitea "$login_new" "$repo")
|
||||
|
||||
echo "# running consistency checks"
|
||||
readonly json_old_ids=$(echo "$json_old" | jq ".[] | .index" | sort -n)
|
||||
|
Loading…
x
Reference in New Issue
Block a user