Path: blob/main/Tools/scripts/find-work-for-installed-ports.sh
18157 views
#!/bin/sh12# Tool to find work (such as unassigned Bugzilla PRs) to port committers or3# perhaps other developers based on the list of locally installed ports.4# More sources can be added later (such as GitHub pull requests).5#6# SPDX-License-Identifier: BSD-2-Clause7# Copyright (c) 2025 René Ladan <[email protected]>8# [email protected]910set -eu1112# Look for PRs in Bugzilla having $1 in the summary line (as opposed to the full13# PR content), and add each such PR to the output (PR number, assignee, summary)14# if it is not assigned some FreeBSD.org, with the exception of15# [email protected]. The matching is case-insensitive.16get_PRs()17{18catport=${1}19category="$(echo "${catport}" | cut -f 1 -d /)"20port="$(echo "${catport}" | cut -f 2 -d /)"21timeout=20 # seconds2223echo "getting Bugzilla PRs having ${catport} in the synopsis" >&224# content= looks for the search string in all of the pr content,25# summary= only looks in the summary line26url="https://bugs.freebsd.org/bugzilla/rest/bug?bug_status=__open__&product=Ports%20%26%20Packages&summary=${category}%2f${port}"27raw="$(fetch -q -T ${timeout} -o - "${url}")"28# Enable the next line to get full JSON output in per-port files for debugging29# echo "${raw}" > "${category}-${port}.json"30if [ -z "${raw}" ] ; then31echo "${catport}: no REST reply within ${timeout} seconds from URL: ${url}" >&232exit 6733fi34pr_list="$(echo "${raw}" | jq '[.bugs | map(select(.assigned_to | test("[email protected]";"i") or test("@freebsd.org";"i") == false)).[] | {id,assigned_to,summary}]')"3536# The below code is just to get one line per PR in the output.37num_prs=$(echo "${pr_list}" | jq length)38if [ ${num_prs} -gt 0 ] ; then39for i in $(jot ${num_prs} 0) ; do40echo "${pr_list}" | jq -r --argjson i ${i} '[.[$i].id,.[$i].assigned_to,.[$i].summary] | @tsv'41done42fi43}4445if ! which jq >/dev/null ; then46echo "Please install textproc/jq" >&247exit 6648fi4950# Iterate through all installed ports which are not maintained by a FreeBSD.org51# address (this includes ports-bugs and possibly you), and for each such port52# see if there is output from get_PR() and if so, report it grouped by the port53# maintainer.54for p in $(pkg query -e '%m !~ *@FreeBSD.org' %o,%m) ; do55origin=$(echo "${p}" | cut -f 1 -d ,)56maintainer=$(echo "${p}" | cut -f 2 -d ,)5758# see if there is a Bugzilla report for ${origin}59bz="$(get_PRs "${origin}")"60if [ -n "${bz}" ] ; then61printf "** %s\n%s\n" "${maintainer}" "${bz}"62fi63done646566