Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports-kde
Path: blob/main/Tools/scripts/find-work-for-installed-ports.sh
16462 views
1
#!/bin/sh
2
3
# Tool to find work (such as unassigned Bugzilla PRs) to port committers or
4
# perhaps other developers based on the list of locally installed ports.
5
# More sources can be added later (such as GitHub pull requests).
6
#
7
# SPDX-License-Identifier: BSD-2-Clause
8
# Copyright (c) 2025 René Ladan <[email protected]>
9
# [email protected]
10
11
set -eu
12
13
# Look for PRs in Bugzilla having $1 in the summary line (as opposed to the full
14
# PR content), and add each such PR to the output (PR number, assignee, summary)
15
# if it is not assigned some FreeBSD.org, with the exception of
16
# [email protected]. The matching is case-insensitive.
17
get_PRs()
18
{
19
catport=${1}
20
category="$(echo "${catport}" | cut -f 1 -d /)"
21
port="$(echo "${catport}" | cut -f 2 -d /)"
22
timeout=20 # seconds
23
24
echo "getting Bugzilla PRs having ${catport} in the synopsis" >&2
25
# content= looks for the search string in all of the pr content,
26
# summary= only looks in the summary line
27
url="https://bugs.freebsd.org/bugzilla/rest/bug?bug_status=__open__&product=Ports%20%26%20Packages&summary=${category}%2f${port}"
28
raw="$(fetch -q -T ${timeout} -o - "${url}")"
29
# Enable the next line to get full JSON output in per-port files for debugging
30
# echo "${raw}" > "${category}-${port}.json"
31
if [ -z "${raw}" ] ; then
32
echo "${catport}: no REST reply within ${timeout} seconds from URL: ${url}" >&2
33
exit 67
34
fi
35
pr_list="$(echo "${raw}" | jq '[.bugs | map(select(.assigned_to | test("[email protected]";"i") or test("@freebsd.org";"i") == false)).[] | {id,assigned_to,summary}]')"
36
37
# The below code is just to get one line per PR in the output.
38
num_prs=$(echo "${pr_list}" | jq length)
39
if [ ${num_prs} -gt 0 ] ; then
40
for i in $(jot ${num_prs} 0) ; do
41
echo "${pr_list}" | jq -r --argjson i ${i} '[.[$i].id,.[$i].assigned_to,.[$i].summary] | @tsv'
42
done
43
fi
44
}
45
46
if ! which jq >/dev/null ; then
47
echo "Please install textproc/jq" >&2
48
exit 66
49
fi
50
51
# Iterate through all installed ports which are not maintained by a FreeBSD.org
52
# address (this includes ports-bugs and possibly you), and for each such port
53
# see if there is output from get_PR() and if so, report it grouped by the port
54
# maintainer.
55
for p in $(pkg query -e '%m !~ *@FreeBSD.org' %o,%m) ; do
56
origin=$(echo "${p}" | cut -f 1 -d ,)
57
maintainer=$(echo "${p}" | cut -f 2 -d ,)
58
59
# see if there is a Bugzilla report for ${origin}
60
bz="$(get_PRs "${origin}")"
61
if [ -n "${bz}" ] ; then
62
printf "** %s\n%s\n" "${maintainer}" "${bz}"
63
fi
64
done
65
66