Skip to content

Commit 9c1ee55

Browse files
authored
Merge pull request #6 from nix-open-org/review-list-files
List all files in the regular review
2 parents 163aa6b + 622acc0 commit 9c1ee55

File tree

1 file changed

+43
-11
lines changed

1 file changed

+43
-11
lines changed

scripts/review-body.sh

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,62 @@ rev=$(git -C "$root" rev-parse HEAD)
1919

2020
echo "Because the documentation in this repository may slowly deviate from reality, this monthly issue is created to regularly review the files.
2121
22-
If you're pinged, please ensure that the relevant documentation matches reality.
22+
All files are listed below with their associated code owners, who are asked to ensure that their contents match reality.
2323
24-
- If that's not the case, please investigate how this happened and address this so it doesn't happen again.
24+
- If that's not the case, please investigate how this happened and address it so that it doesn't happen again.
2525
26-
To mitigate the current inconsistency:
26+
To mitigate an inconsistency:
2727
- If a PR was merged without updating reality, update reality to match the new documentation, then post a comment in this issue with what was done.
2828
- If reality was updated without a PR, open a PR to update the documentation, then post a comment in this issue with a link to the PR.
2929
3030
- Once the documentation matches reality, tick the checkmark.
3131
3232
If all checkmarks are ticked, the issue can be closed.
3333
34-
## Code owners
34+
## Files
3535
36-
These are all [current code owner entries](../tree/$rev/.github/CODEOWNERS):
36+
These are the [current code owners](https://github.com/$repo/tree/$rev/.github/CODEOWNERS) for each file:
3737
"
3838

39-
# TODO: List all files in the repo, link to them directly and look up codeowners using some glob matching/codeowners library/CLI, warn for files without code owner
40-
while read -r file users; do
41-
if [[ "$file" == "#" || "$file" == "" ]]; then
42-
continue
39+
declare -A codeowners
40+
41+
while read -r file owners; do
42+
if [[ "$owners" != "(unowned)" ]]; then
43+
codeowners[$file]=$owners
4344
fi
44-
echo "- [ ] \`$file\`: $users"
45-
done < "$root"/.github/CODEOWNERS
45+
done < <(cd "$root"; codeowners)
46+
47+
listDir() {
48+
local indent=$1
49+
local dir=$2
50+
local -a entries dirs files
51+
local subpath link
52+
53+
readarray -d '' entries < <(git -C "$root/$dir" ls-tree "$rev" --name-only -z)
54+
# This is just so we can order directories before files,
55+
# which makes the result much nicer
56+
for entry in "${entries[@]}"; do
57+
subpath=${dir:+$dir/}$entry
58+
if [[ -d "$root/$subpath" ]]; then
59+
dirs+=("$entry")
60+
else
61+
files+=("$entry")
62+
fi
63+
done
64+
65+
for entry in "${dirs[@]}" "${files[@]}"; do
66+
subpath=${dir:+$dir/}$entry
67+
link="[\`$entry\`](https://github.com/$repo/tree/$rev/$subpath)"
68+
if [[ -d "$root/$subpath" ]]; then
69+
echo "$indent- $link"
70+
listDir "$indent " "$subpath"
71+
else
72+
echo "$indent- [ ] $link: ${codeowners[$subpath]:-"**Nobody!**"}"
73+
fi
74+
done
75+
}
76+
77+
listDir "" ""
4678

4779
echo ""
4880

0 commit comments

Comments
 (0)