qemu/scripts/gitlab-map-update
Daniel P. Berrangé 4f7615789b gitlab: introduce files mapping GitLab accounts to real names
It is desirable to be able to discover the GitLab account handle
assocaited with a real name in the MAINTAINERS file.

Rather that duplicating the same account handle multiple times,
inline with the MAINTAINERS file entries, this introduces mapping
files:

  * .gitlab-map-auto - data automatically queried from GitLab
    using the 'glab' tool and REST API
  * .gitlab-map-manual - manual overrides/augmentation for
    cases where the MAINTAINERS real name does not match the
    GitLab account real name

The former would need refreshing when we add new MAINTAINERS
entries, if the person had to be added as a GitLab account
member. For this purpose scripts/gitlab-map-update can be
used, assuming the user has the 'glab' client tool present
and configured with an access token.

To audit how many maintainers have GitLab handles present/missing
scripts/gitlab-map-check can run a report.

  $ ./scripts/gitlab-map-check
  Missing GitLab handle for maintainer 'Akihiko Odaki'
  Missing GitLab handle for maintainer 'Albert Esteve'
  ....
  Missing GitLab handle for maintainer 'Zhenzhong Duan'
  Missing GitLab handle for maintainer 'Zhuoying Cai'
  GitLab handles missing: 158 / present: 68

Reviewed-by: Fabiano Rosas <farosas@suse.de>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2026-07-21 16:52:25 +01:00

45 lines
1.2 KiB
Bash
Executable file

#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later
echo "Checking authentication token status"
glab auth status
if test $? != 0
then
echo "ERROR: not authenticated with gitlab.com"
exit 1
fi
if ! test -f .gitlab-map-auto
then
echo "ERROR: cannot find existing '.gitlab-map-auto file'"
echo "ERROR: this must be executed from the root of the"
echo "ERROR: git repository checkout"
exit 1
fi
fail=0
echo "Updating member list from qemu-project"
glab api --paginate /groups/qemu-project/members | \
jq -r -c '.[] | [.username, .name] | @tsv' | \
grep -v '^group_3038080_bot' > \
.gitlab-map-auto.tmp
test $? != 0 && fail=1
echo "Updating member list from qemu-project/qemu"
glab api --paginate /projects/qemu-project%2fqemu/members | \
jq -r -c '.[] | [.username, .name] | @tsv' | \
grep -v 'Duo Developer' >> \
.gitlab-map-auto.tmp
test $? != 0 && fail=1
if test $fail == 0
then
grep '^#' .gitlab-map-auto > .gitlab-map-auto.new
LC_ALL=C sort .gitlab-map-auto.tmp | uniq >> .gitlab-map-auto.new
mv .gitlab-map-auto.new .gitlab-map-auto
echo "OK: GitLab member list updated"
else
echo "ERROR: Updating member list failed"
fi
rm -f .gitlab-map-auto.tmp