| 1 | #!/bin/sh |
| 2 | # SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | |
| 4 | echo "Checking authentication token status" |
| 5 | glab auth status |
| 6 | |
| 7 | if test $? != 0 |
| 8 | then |
| 9 | echo "ERROR: not authenticated with gitlab.com" |
| 10 | exit 1 |
| 11 | fi |
| 12 | |
| 13 | if ! test -f .gitlab-map-auto |
| 14 | then |
| 15 | echo "ERROR: cannot find existing '.gitlab-map-auto file'" |
| 16 | echo "ERROR: this must be executed from the root of the" |
| 17 | echo "ERROR: git repository checkout" |
| 18 | exit 1 |
| 19 | fi |
| 20 | |
| 21 | fail=0 |
| 22 | echo "Updating member list from qemu-project" |
| 23 | glab api --paginate /groups/qemu-project/members | \ |
| 24 | jq -r -c '.[] | [.username, .name] | @tsv' | \ |
| 25 | grep -v '^group_3038080_bot' > \ |
| 26 | .gitlab-map-auto.tmp |
| 27 | test $? != 0 && fail=1 |
| 28 | |
| 29 | echo "Updating member list from qemu-project/qemu" |
| 30 | glab api --paginate /projects/qemu-project%2fqemu/members | \ |
| 31 | jq -r -c '.[] | [.username, .name] | @tsv' | \ |
| 32 | grep -v 'Duo Developer' >> \ |
| 33 | .gitlab-map-auto.tmp |
| 34 | test $? != 0 && fail=1 |
| 35 | |
| 36 | if test $fail == 0 |
| 37 | then |
| 38 | grep '^#' .gitlab-map-auto > .gitlab-map-auto.new |
| 39 | LC_ALL=C sort .gitlab-map-auto.tmp | uniq >> .gitlab-map-auto.new |
| 40 | mv .gitlab-map-auto.new .gitlab-map-auto |
| 41 | echo "OK: GitLab member list updated" |
| 42 | else |
| 43 | echo "ERROR: Updating member list failed" |
| 44 | fi |
| 45 | rm -f .gitlab-map-auto.tmp |