2 # shellcheck disable=SC2310,SC2312
3 # The above line must be directly after the shebang line.
4 # Disables these warnings:
5 # SC2310 - This function is invoked in an 'if' condition so set -e will be disabled.
6 # Invoke separately if failures should cause the script to exit.
7 # SC2312 - Consider invoking this command separately to avoid masking its return value
10 # SPDX-License-Identifier: GPL-2.0-only
15 # Identifies new users in gerrit so that they can be greeted and marked
21 PROGNAME
="$(basename "${PROGRAM}")"
23 COMMIT_COUNT
=5 # Consider a user to be new until they have this many commits
26 KNOWN_AUTHOR_FILE
="./authorlist.txt"
27 NEW_AUTHOR_FILE
="./new_authors.txt"
29 GERRIT_REPO
="review.coreboot.org"
32 echo "${PROGNAME} version ${VERSION}"
37 echo "Usage: ${PROGNAME} <gerrit username>"
38 echo "example: ${PROGNAME} martinlroth"
51 if ! jq
--version >/dev
/null
2>&1; then
52 echo "Error: jq is not installed. Please install it with your package manager."
56 if [[ -z ${GERRIT_USER} ]]; then
57 echo "Error: Please specify gerrit username on the command line." >&2
59 if [[ -z ${GERRIT_USER} || ${GERRIT_USER} == "--help" || ${GERRIT_USER} == "-h" ]]; then
64 echo "List of known users with more than 5 commits: ${KNOWN_AUTHOR_FILE}"
65 echo "List of new user's patches: ${NEW_AUTHOR_FILE}"
66 echo "Key: . = author in known user list or new user commit already seen"
67 echo " : = author getting added to known user list"
70 touch "${NEW_AUTHOR_FILE}" "${KNOWN_AUTHOR_FILE}"
72 # Get all coreboot patches that aren't by known users, newer than the age set above
73 patchlist
="$(ssh -p 29418 "${GERRIT_USER}@${GERRIT_REPO}" gerrit query --format=JSON --no-limit --current-patch-set "repo:coreboot AND status:open NOT age:${AGE} NOT ownerin
:Reviewers NOT ownerin
:\\\"Core Developers
\\\"" |
74 jq -Mr '.currentPatchSet.uploader.name + ", " + .currentPatchSet.uploader.email + ", " + .currentPatchSet.revision + ", " + (.number | tostring)' |
77 if [[ -z ${patchlist} ]]; then
78 echo "Error: No patches returned." >&2
81 echo "$(wc -l <<<"${patchlist}") patches found."
84 # Loop through all patches found, looking for any that are not by a known author.
85 # If an author with more than 5 patches is found, add them to a list to filter out in the future.
86 # If we find a new patch, print it, then add it to a list so that it isn't reported again.
88 for patch in ${patchlist}; do
89 owner
="$(echo "${patch}" | cut -f1 -d',')"
90 owner_email
="$(echo "${patch}" | cut -f2 -d',')"
91 commit_id
="$(echo "${patch}" | cut -f4 -d',')"
93 if grep -qi "${owner}" "${KNOWN_AUTHOR_FILE}" || grep -qi "${owner_email}" "${KNOWN_AUTHOR_FILE}" || grep -q "${commit_id}" "${NEW_AUTHOR_FILE}"; then
98 # Get the author's commit count
99 # shellcheck disable=SC2126 # (Consider using grep -c instead of grep | wc)
100 commit_count
="$(ssh -p 29418 "${GERRIT_USER}@${GERRIT_REPO}" gerrit query --format=JSON "limit:6 AND repo:coreboot AND owner:${owner_email} and status
:merged
" |
101 jq -Mr '.owner.name + ", " + .owner.email' |
104 if [[ ${commit_count} -ge ${COMMIT_COUNT} ]]; then
106 echo "${owner}, ${owner_email}" >>"${KNOWN_AUTHOR_FILE}"
110 printf "\n%s looks to be a patch by a new author.\n" "${patch}"
111 echo "${patch}" >>"${NEW_AUTHOR_FILE}"
115 if [[ ${new_users} -eq 0 ]]; then
116 echo "No new patches by new users found."