git: ba47678b30a5 - main - git-arc: Use full names in reviewed-by lines

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Mon, 10 Aug 2026 17:40:30 UTC
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=ba47678b30a50fd44234f8ed7fbef68a56479b37

commit ba47678b30a50fd44234f8ed7fbef68a56479b37
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2026-08-10 14:49:11 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-08-10 17:31:21 +0000

    git-arc: Use full names in reviewed-by lines
    
    Phabricator user names are not useful identifiers outside of
    phabricator, don't use them if we can avoid it.
---
 tools/tools/git/git-arc.sh | 42 ++++++++++++++++++++++++++++++++++--------
 1 file changed, 34 insertions(+), 8 deletions(-)

diff --git a/tools/tools/git/git-arc.sh b/tools/tools/git/git-arc.sh
index 72605d49d40f..d8551630f7e2 100755
--- a/tools/tools/git/git-arc.sh
+++ b/tools/tools/git/git-arc.sh
@@ -289,7 +289,7 @@ create_one_review()
 # Get a list of reviewers who accepted the specified diff.
 diff2reviewers()
 {
-    local diff reviewid userids
+    local diff reviewid userids tmp author username realname
 
     diff=$1
     reviewid=$(diff2phid "$diff")
@@ -301,11 +301,27 @@ diff2reviewers()
         arc_call_conduit -- differential.revision.search |
         jq '.response.data[0].attachments.reviewers.reviewers[] | select(.status == "accepted").reviewerPHID')
     if [ -n "$userids" ]; then
+        tmp=$(xmktemp)
         echo '{
         "constraints": {"phids": ['"$(echo $userids | tr '[:blank:]' ',')"']}
         }' |
         arc_call_conduit -- user.search |
-        jq -r '.response.data[].fields.username'
+        jq -r '.response.data[] | [.fields.username, .fields.realName] | @tsv' > "$tmp"
+
+        while IFS=$(printf '\t') read -r username realname; do
+            if is_freebsd_committer "$username"; then
+                # FreeBSD uses bare login names in Reviewed-by lines.
+                echo "$username"
+            else
+                # Resolve mangled phabricator usernames.
+                author=$(find_author "$username" "$realname" "" "")
+                if [ "$author" = "ABORT" ]; then
+                    warn "Skipping reviewer ${username}: uncertain author identity"
+                else
+                    echo "$author"
+                fi
+            fi
+        done < "$tmp"
     fi
 }
 
@@ -448,6 +464,20 @@ gitarc__list()
     done
 }
 
+# Return true if the Phabricator username looks like a FreeBSD committer login:
+# no '.' in the name and not a guest account.
+is_freebsd_committer()
+{
+    case "$1" in
+    *.* | guest-*)
+        return 1
+        ;;
+    *)
+        return 0
+        ;;
+    esac
+}
+
 # Try to guess our way to a good author name. The DWIM is strong in this
 # function, but these heuristics seem to generally produce the right results, in
 # the sample of src commits I checked out.
@@ -468,14 +498,10 @@ find_author()
     # these people having their local config pointing at something other than
     # freebsd.org (which isn't surprising for ports committers getting src
     # commits reviewed).
-    case "${addr}" in
-    *.*) ;;             # external user
-    guest-*) ;;		# Fake email address, not a FreeBSD user
-    *)
+    if is_freebsd_committer "${addr}"; then
         echo "${name} <${addr}@FreeBSD.org>"
         return
-        ;;
-    esac
+    fi
 
     # Choice 2: author_addr and author_name were set in the bundle, so use
     # that. We may need to filter some known bogus ones, should they crop up.