From nobody Tue Nov 05 02:11:55 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XjBfg5kL5z5cryK; Tue, 05 Nov 2024 02:11:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XjBfg5HH7z42dP; Tue, 5 Nov 2024 02:11:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730772715; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=VFYP8oGo0GhfP2Y/l7Q4EmNujPWnA7b1UYLfMbq05MU=; b=MJYPHr6bH5NflvLfTzFv8IYAsuyWrD13309xhONfXccQznPgULvCcdoLmKn/sNVT5o9hB2 3x63PAW1AgiqE5H2peXmFshTqcGTRZRzU+hjvSiQD+iHXQjPmUfzQ+DDFWHJaSj09PbXYs GBjbebrvckvvpunCuXCsXsGnMFv0VDUK4sv5yoL9akwoXcqwyt6R99a2O2rql9ub9eIGgA g5klcSdbv5drGqc2Gn8snHBMUoJ6K/3c/VY/YEvxt/J1geaNLbuVVMDEoGRGHBBOucX1aG puwWgpUgXENB3k/pmhjZXgcGSzkuPEikxlnaOqBJ1QL9U3TkD+k/atXU6LHSew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730772715; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=VFYP8oGo0GhfP2Y/l7Q4EmNujPWnA7b1UYLfMbq05MU=; b=bIrQtPIHqqih4mjdqK46zCMS7c7I3X1BZtrfwjP9U8vDNnN21C/o7LQNRCBvFHLj/nht3b /l3Kdob8g1khOzOTb/EhaZveLlNrmUV0rHGanIplRUry/dlH22At2RiA+NaNY23tEYd6Ou wKwTK92GVKuWGM0WF8ECW9vAzGtHPetvUXi3wyEE8Tnc6m+YyoYiJRTRyKLOSig+LcsaEM viSf5IKTVFK2FR+3AIpWxoNdE74VFKNhg8mtgRd03pd8+5HXVlmFuPn0dVjXDZ4CAIw1qt bZc83RrHrGoEWfS/U8htzaBDI2MOZyN08UkqBxs6oRdMqIiJkXw4htDIpukrcw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730772715; a=rsa-sha256; cv=none; b=PgFJ6c7qc+tjt9B9zrOpD817wEWjSXmXaQx4I1tEb7aoQAUBJE5VsZylusGSZAdh6Y01Pr NzpO33k4k7FdHMZhMEZl5pk/v/hjLRZ7r7BNHtDrPbmriY9US03k5gk8WI4bxCeuMt4UPW FT+DwptqmfQLdCV1Ak44fJHxwJVsjzxPeK96gAejQUlx4oowvSimORMl/aMwMLm5iEBIfz /Xhx3rL20vMuvNwAf2A4RhJyZBeBBa4GiKZlQxZ6e5nyACcKZZCvWXuIU5vteZjgnOKSPD WjCvH7DrU1h8BlnFyokbPiPoFIe5P1WyZpBpAXKTrG/ZNRfFF2Ni5xFErDyR6Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XjBfg4vBRzyTn; Tue, 5 Nov 2024 02:11:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4A52BtZM019290; Tue, 5 Nov 2024 02:11:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4A52BtpM019287; Tue, 5 Nov 2024 02:11:55 GMT (envelope-from git) Date: Tue, 5 Nov 2024 02:11:55 GMT Message-Id: <202411050211.4A52BtpM019287@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jose Luis Duran Subject: git: aa90b92ac289 - main - git-arc: Fix find_author() for external users List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jlduran X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: aa90b92ac289b2a7eec882caf870e56dbed16a5c Auto-Submitted: auto-generated The branch main has been updated by jlduran: URL: https://cgit.FreeBSD.org/src/commit/?id=aa90b92ac289b2a7eec882caf870e56dbed16a5c commit aa90b92ac289b2a7eec882caf870e56dbed16a5c Author: Jose Luis Duran AuthorDate: 2024-11-05 01:32:25 +0000 Commit: Jose Luis Duran CommitDate: 2024-11-05 02:10:15 +0000 git-arc: Fix find_author() for external users When an external user submits a review in Phabricator, the find_author() subroutine may receive the author_name and author_addr as "null" from the JSON API with git-arc patch. This "null" string gets tested for length by "[ -n", and returning that is greater than zero, in other words, the shell does not understand that "null" means nothing in this case. Fix it by adding a guard, that sets an empty string when the content is "null". While here, standardize the indentation style for find_author() Reviewed by: emaste, markj Approved by: emaste (mentor) Differential Revision: https://reviews.freebsd.org/D46789 --- tools/tools/git/git-arc.sh | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/tools/tools/git/git-arc.sh b/tools/tools/git/git-arc.sh index cca70f61a4cd..f3cae28e3009 100644 --- a/tools/tools/git/git-arc.sh +++ b/tools/tools/git/git-arc.sh @@ -493,16 +493,16 @@ find_author() case "${addr}" in *.*) ;; # external user *) - echo "${name} <${addr}@FreeBSD.org>" - return - ;; + echo "${name} <${addr}@FreeBSD.org>" + return + ;; esac # 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. if [ -n "$author_name" -a -n "$author_addr" ]; then - echo "${author_name} <${author_addr}>" - return + echo "${author_name} <${author_addr}>" + return fi # Choice 3: We can find this user in the FreeBSD repo. They've submited @@ -510,8 +510,8 @@ find_author() # similar to their phab username. email=$(git log -1 --author "$(echo ${addr} | tr _ .)" --pretty="%aN <%aE>") if [ -n "${email}" ]; then - echo "${email}" - return + echo "${email}" + return fi # Choice 4: We know this user. They've committed before, and they happened @@ -519,11 +519,11 @@ find_author() # might not be a good idea, since names can be somewhat common (there # are two Andrew Turners that have contributed to FreeBSD, for example). if ! (echo "${name}" | grep -w "[Uu]ser" -q); then - email=$(git log -1 --author "${name}" --pretty="%aN <%aE>") - if [ -n "$email" ]; then - echo "$email" - return - fi + email=$(git log -1 --author "${name}" --pretty="%aN <%aE>") + if [ -n "$email" ]; then + echo "$email" + return + fi fi # Choice 5: Wing it as best we can. In this scenario, we replace the last _ @@ -534,8 +534,8 @@ find_author() a=$(printf "%s <%s>\n" "${name}" $(echo "$addr" | sed -e 's/\(.*\)_/\1@/')) echo "Making best guess: Truning ${addr} to ${a}" if ! prompt; then - echo "ABORT" - return + echo "ABORT" + return fi echo "${a}" } @@ -572,6 +572,16 @@ patch_commit() jq -r '.response | flatten | .[]' > "$diff_data" author_addr=$(jq -r ".authorEmail?" "$diff_data" | sort -u) author_name=$(jq -r ".authorName?" "$diff_data" | sort -u) + + # JSON will return "null" when a field is not populated. + # Turn this string into an empty one. + if [ "$author_addr" = "null" ]; then + author_addr="" + fi + if [ "$author_name" = "null" ]; then + author_name="" + fi + author=$(find_author "$user_addr" "$user_name" "$author_addr" "$author_name") rm "$diff_data"