housebroken-cli 0.14.0__tar.gz → 0.16.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {housebroken_cli-0.14.0 → housebroken_cli-0.16.0}/PKG-INFO +6 -4
- {housebroken_cli-0.14.0 → housebroken_cli-0.16.0}/README.md +5 -3
- {housebroken_cli-0.14.0 → housebroken_cli-0.16.0}/pyproject.toml +1 -1
- {housebroken_cli-0.14.0 → housebroken_cli-0.16.0}/scripts/branch-check.sh +35 -33
- {housebroken_cli-0.14.0 → housebroken_cli-0.16.0}/scripts/check-ai-policy.sh +26 -7
- {housebroken_cli-0.14.0 → housebroken_cli-0.16.0}/scripts/claim-check.sh +4 -2
- {housebroken_cli-0.14.0 → housebroken_cli-0.16.0}/scripts/close.sh +24 -17
- {housebroken_cli-0.14.0 → housebroken_cli-0.16.0}/scripts/comment-check.sh +6 -4
- {housebroken_cli-0.14.0 → housebroken_cli-0.16.0}/scripts/common.sh +33 -27
- {housebroken_cli-0.14.0 → housebroken_cli-0.16.0}/scripts/declare.sh +5 -3
- {housebroken_cli-0.14.0 → housebroken_cli-0.16.0}/scripts/edit-pr.sh +17 -15
- {housebroken_cli-0.14.0 → housebroken_cli-0.16.0}/scripts/file-issue.sh +14 -11
- {housebroken_cli-0.14.0 → housebroken_cli-0.16.0}/scripts/file-pr.sh +31 -29
- {housebroken_cli-0.14.0 → housebroken_cli-0.16.0}/scripts/gate-hook.sh +29 -5
- {housebroken_cli-0.14.0 → housebroken_cli-0.16.0}/scripts/proof.sh +23 -21
- {housebroken_cli-0.14.0 → housebroken_cli-0.16.0}/scripts/push.sh +13 -11
- {housebroken_cli-0.14.0 → housebroken_cli-0.16.0}/scripts/ref-check.sh +6 -4
- housebroken_cli-0.16.0/scripts/refuse.sh +63 -0
- {housebroken_cli-0.14.0 → housebroken_cli-0.16.0}/scripts/reply.sh +26 -19
- {housebroken_cli-0.14.0 → housebroken_cli-0.16.0}/scripts/review.sh +23 -21
- {housebroken_cli-0.14.0 → housebroken_cli-0.16.0}/skills/housebroken/SKILL.md +17 -11
- housebroken_cli-0.16.0/src/housebroken/__init__.py +1 -0
- housebroken_cli-0.14.0/src/housebroken/__init__.py +0 -1
- {housebroken_cli-0.14.0 → housebroken_cli-0.16.0}/.gitignore +0 -0
- {housebroken_cli-0.14.0 → housebroken_cli-0.16.0}/LICENSE +0 -0
- {housebroken_cli-0.14.0 → housebroken_cli-0.16.0}/bin/housebroken +0 -0
- {housebroken_cli-0.14.0 → housebroken_cli-0.16.0}/hatch_build.py +0 -0
- {housebroken_cli-0.14.0 → housebroken_cli-0.16.0}/scripts/ci-legs.sh +0 -0
- {housebroken_cli-0.14.0 → housebroken_cli-0.16.0}/scripts/comment-census.sh +0 -0
- {housebroken_cli-0.14.0 → housebroken_cli-0.16.0}/scripts/diff-defaults.sh +0 -0
- {housebroken_cli-0.14.0 → housebroken_cli-0.16.0}/scripts/distinct-outside.sh +0 -0
- {housebroken_cli-0.14.0 → housebroken_cli-0.16.0}/scripts/fork-hygiene.sh +0 -0
- {housebroken_cli-0.14.0 → housebroken_cli-0.16.0}/scripts/inbox.sh +0 -0
- {housebroken_cli-0.14.0 → housebroken_cli-0.16.0}/scripts/notes.sh +0 -0
- {housebroken_cli-0.14.0 → housebroken_cli-0.16.0}/scripts/pr-sweep.sh +0 -0
- {housebroken_cli-0.14.0 → housebroken_cli-0.16.0}/scripts/prior-art.sh +0 -0
- {housebroken_cli-0.14.0 → housebroken_cli-0.16.0}/scripts/verify-filed-pr.sh +0 -0
- {housebroken_cli-0.14.0 → housebroken_cli-0.16.0}/src/housebroken/cli.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: housebroken-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.16.0
|
|
4
4
|
Summary: Agent-written pull requests that do not make a mess in someone else's house.
|
|
5
5
|
Project-URL: Repository, https://github.com/lenamonj/housebroken
|
|
6
6
|
License-Expression: MIT
|
|
@@ -52,7 +52,7 @@ the CLA known before filing, the SECURITY.md route taken when it applies
|
|
|
52
52
|
A pull request passes through the door in order, and stops at the first rule it fails. Each rule is a script where a script can hold it. The maintainers' own verdicts that shaped them are kept separately, in [docs/lessons.md](https://github.com/lenamonj/housebroken/blob/main/docs/lessons.md).
|
|
53
53
|
|
|
54
54
|
**1. Read the house rules before knocking.**
|
|
55
|
-
`check-ai-policy.sh` reads every contributing guide, code of conduct, policy or provenance document, template and agent instruction file on the repository's branch and in the organization's `.github` repository, matched by name without regard to case (READMEs capped at 40, shallowest first, and the cap printed), joins wrapped lines into sentences, and prints each sentence that names AI with its reading: BAN, DISCLOSE, MENTION or CLEAN. A file GitHub would not give, a throttled call or a truncated listing reads UNREAD, never CLEAN, and nothing files on it. A word list reads no grammar, so MENTION
|
|
55
|
+
`check-ai-policy.sh` reads every contributing guide, code of conduct, policy or provenance document, template and agent instruction file on the repository's branch and in the organization's `.github` repository, matched by name without regard to case (READMEs capped at 40, shallowest first, and the cap printed), joins wrapped lines into sentences, and prints each sentence that names AI with its reading: BAN, DISCLOSE, MENTION or CLEAN. A file GitHub would not give, a throttled call or a truncated listing reads UNREAD, never CLEAN, and nothing files on it. DISCLOSE is read where a sentence reads as asking the contributor to say AI was used, so most credits, thanks and remarks a project makes about itself read MENTION; the list still misreads some, such as a heading "AI Disclosure" over a credit. A word list reads no grammar and a disclosure rule seldom stands alone, so DISCLOSE and MENTION are both holds: nothing files until the lines are read and what they mean is recorded with `--reading`. A project that bans AI-written contributions never gets one. A project that asks for disclosure gets one truthful sentence in the body. `distinct-outside.sh` counts outside contributors merged in the last 120 days; a project that has merged none is closed to outsiders whatever its README says.
|
|
56
56
|
|
|
57
57
|
**2. Is it already on the table?**
|
|
58
58
|
`prior-art.sh` lists the issues and pull requests, open, closed and merged, that touch the file or symbol, with the type taken from the API and the closing ruling quoted for every closed item. A search that matched more than it returned, or a read that failed, says so, and such a printout is saved only when marked partial. The filing gate requires every file the branch changes to be one of its terms. An open pull request that fixes the same thing, or a closed issue that ruled the behaviour intended, ends the work. A ruling is never argued with.
|
|
@@ -78,7 +78,7 @@ A memory-safety, remote-abort, injection or path-escape finding goes by the proj
|
|
|
78
78
|
**9. File through the gate.**
|
|
79
79
|
`branch-check.sh` refuses a dirty working tree, a file whose mode disagrees with its siblings, a file the repository's own `.gitignore` excludes, a working artifact, a commit carrying a tool trailer, a session link or a tool identity, a sign-off naming a username, a branch not on top of its base, any comment added to code, a warning suppression that does not name what it hides or that no build log shows firing, reflection added to a .NET project that declares AOT or trim support without an AOT publish log of it, a credential or a path under your own home in any commit of the branch, not only the final diff, a lockfile, generated file or binary nobody named, an agent's working file, and a file rewritten for its line endings; it notes a base the upstream has moved past, a user path that may be a fixture and every absolute claim in added prose, and stamps the head it passed.
|
|
80
80
|
`review.sh` names the adversarial reviewer: a different model from the one that wrote the change, one tier down, never below Sonnet. Before it runs, the author writes a declaration (`declare.sh`): what the change was not tested against, and every assumption with what breaks if it is wrong and how it was checked. "Nothing" is refused as an answer. The review reads the declaration as one of its texts and attacks each line. The reviewer gets a fresh context, hard read-only limits, and before it reads the diff it writes its own fix from the bug alone, so it is not anchored on ours; the report names that fix as a diff and the gate refuses one that does not, a POST AS IS over an open BLOCKING or SHOULD FIX finding, and a POST AS IS over items the reviewer skipped. Its attack list starts with every claim the prose makes and includes the form of the code: the reviewer writes the changed block the way the strongest engineer in that language would, in the repository's own idioms, and a smaller or clearer version is a finding; every finding carries evidence it produced itself, and its report is bound to the head and the text it read. A fix is a new head and gets a new review.
|
|
81
|
-
`file-pr.sh` is the only way a pull request is opened. It refuses without a prior-art printout under a day old that searched every file the branch changes, a policy printout under a day old that reads neither BAN nor UNREAD, with a recorded reading if it reads MENTION, a body that discloses when the policy asks, keeps the project's template and runs to at most 120 words of its own beside it (the answer to the template's AI question counted apart, at most 50), a branch stamp for the exact head whose base the upstream has not since changed under the branch's files, a proof stamp for that head, a declaration that passes, a POST AS IS review of that head, that body and that declaration, fewer than three open pull requests of yours on the repository, and ten minutes since the last filing there.
|
|
81
|
+
`file-pr.sh` is the only way a pull request is opened. It refuses without a prior-art printout under a day old that searched every file the branch changes, a policy printout under a day old that reads neither BAN nor UNREAD, with a recorded reading if it reads DISCLOSE or MENTION, a body that discloses when the policy asks, keeps the project's template and runs to at most 120 words of its own beside it (the answer to the template's AI question counted apart, at most 50), a branch stamp for the exact head whose base the upstream has not since changed under the branch's files, a proof stamp for that head, a declaration that passes, a POST AS IS review of that head, that body and that declaration, fewer than three open pull requests of yours on the repository, and ten minutes since the last filing there.
|
|
82
82
|
`file-issue.sh` is the only way an issue is opened. It refuses without the same prior-art and policy printouts, refuses the same footers, trailers and dashes, keeps the same ten minutes, and refuses a body that offers or describes a fix without a link to that work, a branch or commit outside the repository, a comparison across forks or a filed pull request, so work that exists is attributable to whoever did it.
|
|
83
83
|
|
|
84
84
|
**10. Watch it land.**
|
|
@@ -142,7 +142,9 @@ An upgrade moves the package and not those two copies, so after one run `housebr
|
|
|
142
142
|
| `scripts/gate-hook.sh` | a Claude Code hook that refuses GitHub writes outside the gates |
|
|
143
143
|
| `scripts/fork-hygiene.sh` | branches deleted after merge or close, orphan forks listed |
|
|
144
144
|
|
|
145
|
-
The scripts are bash, 3.2 or newer, and need `gh` and `jq`; `scripts/common.sh` is what they share. Each script's header says what it assumes. `bash tests/run.sh` runs every test offline, behind a stub `gh`.
|
|
145
|
+
The scripts are bash, 3.2 or newer, and need `gh` and `jq`; `scripts/common.sh` is what they share and `scripts/refuse.sh` is how each one says no. Each script's header says what it assumes. `bash tests/run.sh` runs every test offline, behind a stub `gh`.
|
|
146
|
+
|
|
147
|
+
The line that says `REFUSED` ends with a name in brackets, as in `REFUSED: the clone is on no branch [push-on-no-branch]`, and so does a refusal of the hook. The name is the rule's own and stays the same if the message is ever reworded. Each refusal, and each reason a refusal lists, also adds one line to `~/.housebroken/refusals.tsv`: the time, the name, and the repository when the gate had read one; the hook writes `-` in its place. The file holds no message text, housebroken sends it nowhere, and it can be deleted at any time.
|
|
146
148
|
|
|
147
149
|
## Not in scope
|
|
148
150
|
|
|
@@ -40,7 +40,7 @@ the CLA known before filing, the SECURITY.md route taken when it applies
|
|
|
40
40
|
A pull request passes through the door in order, and stops at the first rule it fails. Each rule is a script where a script can hold it. The maintainers' own verdicts that shaped them are kept separately, in [docs/lessons.md](docs/lessons.md).
|
|
41
41
|
|
|
42
42
|
**1. Read the house rules before knocking.**
|
|
43
|
-
`check-ai-policy.sh` reads every contributing guide, code of conduct, policy or provenance document, template and agent instruction file on the repository's branch and in the organization's `.github` repository, matched by name without regard to case (READMEs capped at 40, shallowest first, and the cap printed), joins wrapped lines into sentences, and prints each sentence that names AI with its reading: BAN, DISCLOSE, MENTION or CLEAN. A file GitHub would not give, a throttled call or a truncated listing reads UNREAD, never CLEAN, and nothing files on it. A word list reads no grammar, so MENTION
|
|
43
|
+
`check-ai-policy.sh` reads every contributing guide, code of conduct, policy or provenance document, template and agent instruction file on the repository's branch and in the organization's `.github` repository, matched by name without regard to case (READMEs capped at 40, shallowest first, and the cap printed), joins wrapped lines into sentences, and prints each sentence that names AI with its reading: BAN, DISCLOSE, MENTION or CLEAN. A file GitHub would not give, a throttled call or a truncated listing reads UNREAD, never CLEAN, and nothing files on it. DISCLOSE is read where a sentence reads as asking the contributor to say AI was used, so most credits, thanks and remarks a project makes about itself read MENTION; the list still misreads some, such as a heading "AI Disclosure" over a credit. A word list reads no grammar and a disclosure rule seldom stands alone, so DISCLOSE and MENTION are both holds: nothing files until the lines are read and what they mean is recorded with `--reading`. A project that bans AI-written contributions never gets one. A project that asks for disclosure gets one truthful sentence in the body. `distinct-outside.sh` counts outside contributors merged in the last 120 days; a project that has merged none is closed to outsiders whatever its README says.
|
|
44
44
|
|
|
45
45
|
**2. Is it already on the table?**
|
|
46
46
|
`prior-art.sh` lists the issues and pull requests, open, closed and merged, that touch the file or symbol, with the type taken from the API and the closing ruling quoted for every closed item. A search that matched more than it returned, or a read that failed, says so, and such a printout is saved only when marked partial. The filing gate requires every file the branch changes to be one of its terms. An open pull request that fixes the same thing, or a closed issue that ruled the behaviour intended, ends the work. A ruling is never argued with.
|
|
@@ -66,7 +66,7 @@ A memory-safety, remote-abort, injection or path-escape finding goes by the proj
|
|
|
66
66
|
**9. File through the gate.**
|
|
67
67
|
`branch-check.sh` refuses a dirty working tree, a file whose mode disagrees with its siblings, a file the repository's own `.gitignore` excludes, a working artifact, a commit carrying a tool trailer, a session link or a tool identity, a sign-off naming a username, a branch not on top of its base, any comment added to code, a warning suppression that does not name what it hides or that no build log shows firing, reflection added to a .NET project that declares AOT or trim support without an AOT publish log of it, a credential or a path under your own home in any commit of the branch, not only the final diff, a lockfile, generated file or binary nobody named, an agent's working file, and a file rewritten for its line endings; it notes a base the upstream has moved past, a user path that may be a fixture and every absolute claim in added prose, and stamps the head it passed.
|
|
68
68
|
`review.sh` names the adversarial reviewer: a different model from the one that wrote the change, one tier down, never below Sonnet. Before it runs, the author writes a declaration (`declare.sh`): what the change was not tested against, and every assumption with what breaks if it is wrong and how it was checked. "Nothing" is refused as an answer. The review reads the declaration as one of its texts and attacks each line. The reviewer gets a fresh context, hard read-only limits, and before it reads the diff it writes its own fix from the bug alone, so it is not anchored on ours; the report names that fix as a diff and the gate refuses one that does not, a POST AS IS over an open BLOCKING or SHOULD FIX finding, and a POST AS IS over items the reviewer skipped. Its attack list starts with every claim the prose makes and includes the form of the code: the reviewer writes the changed block the way the strongest engineer in that language would, in the repository's own idioms, and a smaller or clearer version is a finding; every finding carries evidence it produced itself, and its report is bound to the head and the text it read. A fix is a new head and gets a new review.
|
|
69
|
-
`file-pr.sh` is the only way a pull request is opened. It refuses without a prior-art printout under a day old that searched every file the branch changes, a policy printout under a day old that reads neither BAN nor UNREAD, with a recorded reading if it reads MENTION, a body that discloses when the policy asks, keeps the project's template and runs to at most 120 words of its own beside it (the answer to the template's AI question counted apart, at most 50), a branch stamp for the exact head whose base the upstream has not since changed under the branch's files, a proof stamp for that head, a declaration that passes, a POST AS IS review of that head, that body and that declaration, fewer than three open pull requests of yours on the repository, and ten minutes since the last filing there.
|
|
69
|
+
`file-pr.sh` is the only way a pull request is opened. It refuses without a prior-art printout under a day old that searched every file the branch changes, a policy printout under a day old that reads neither BAN nor UNREAD, with a recorded reading if it reads DISCLOSE or MENTION, a body that discloses when the policy asks, keeps the project's template and runs to at most 120 words of its own beside it (the answer to the template's AI question counted apart, at most 50), a branch stamp for the exact head whose base the upstream has not since changed under the branch's files, a proof stamp for that head, a declaration that passes, a POST AS IS review of that head, that body and that declaration, fewer than three open pull requests of yours on the repository, and ten minutes since the last filing there.
|
|
70
70
|
`file-issue.sh` is the only way an issue is opened. It refuses without the same prior-art and policy printouts, refuses the same footers, trailers and dashes, keeps the same ten minutes, and refuses a body that offers or describes a fix without a link to that work, a branch or commit outside the repository, a comparison across forks or a filed pull request, so work that exists is attributable to whoever did it.
|
|
71
71
|
|
|
72
72
|
**10. Watch it land.**
|
|
@@ -130,7 +130,9 @@ An upgrade moves the package and not those two copies, so after one run `housebr
|
|
|
130
130
|
| `scripts/gate-hook.sh` | a Claude Code hook that refuses GitHub writes outside the gates |
|
|
131
131
|
| `scripts/fork-hygiene.sh` | branches deleted after merge or close, orphan forks listed |
|
|
132
132
|
|
|
133
|
-
The scripts are bash, 3.2 or newer, and need `gh` and `jq`; `scripts/common.sh` is what they share. Each script's header says what it assumes. `bash tests/run.sh` runs every test offline, behind a stub `gh`.
|
|
133
|
+
The scripts are bash, 3.2 or newer, and need `gh` and `jq`; `scripts/common.sh` is what they share and `scripts/refuse.sh` is how each one says no. Each script's header says what it assumes. `bash tests/run.sh` runs every test offline, behind a stub `gh`.
|
|
134
|
+
|
|
135
|
+
The line that says `REFUSED` ends with a name in brackets, as in `REFUSED: the clone is on no branch [push-on-no-branch]`, and so does a refusal of the hook. The name is the rule's own and stays the same if the message is ever reworded. Each refusal, and each reason a refusal lists, also adds one line to `~/.housebroken/refusals.tsv`: the time, the name, and the repository when the gate had read one; the hook writes `-` in its place. The file holds no message text, housebroken sends it nowhere, and it can be deleted at any time.
|
|
134
136
|
|
|
135
137
|
## Not in scope
|
|
136
138
|
|
|
@@ -35,6 +35,8 @@
|
|
|
35
35
|
#
|
|
36
36
|
# Exits 0 when nothing blocks, 1 on a refusal, 2 on a usage error.
|
|
37
37
|
set -u
|
|
38
|
+
# shellcheck source=scripts/refuse.sh
|
|
39
|
+
. "$(cd "$(dirname "$0")" && pwd)/refuse.sh"
|
|
38
40
|
|
|
39
41
|
usage() { awk 'NR>1 && /^#/ {sub(/^# ?/, ""); print; next} NR>1 {exit}' "$0"; }
|
|
40
42
|
|
|
@@ -54,52 +56,52 @@ while [ "$#" -gt 0 ]; do
|
|
|
54
56
|
--base)
|
|
55
57
|
shift
|
|
56
58
|
base="${1:-}"
|
|
57
|
-
[ -n "$base" ] || {
|
|
59
|
+
[ -n "$base" ] || { refused branch-check-base-no-ref "--base needs a ref" >&2; exit 2; }
|
|
58
60
|
;;
|
|
59
61
|
--base=*) base="${1#--base=}" ;;
|
|
60
62
|
--asked)
|
|
61
63
|
shift
|
|
62
64
|
asked="${1:-}"
|
|
63
|
-
[ -n "$asked" ] || {
|
|
65
|
+
[ -n "$asked" ] || { refused branch-check-asked-no-url "--asked needs the URL of the maintainer's ask" >&2; exit 2; }
|
|
64
66
|
;;
|
|
65
67
|
--asked=*) asked="${1#--asked=}" ;;
|
|
66
68
|
--warning-log)
|
|
67
69
|
shift
|
|
68
70
|
warnlog="${1:-}"
|
|
69
|
-
[ -f "$warnlog" ] || {
|
|
71
|
+
[ -f "$warnlog" ] || { refused branch-check-warning-log-no-file "--warning-log needs a build log file" >&2; exit 2; }
|
|
70
72
|
;;
|
|
71
73
|
--aot-log)
|
|
72
74
|
shift
|
|
73
75
|
aotlog="${1:-}"
|
|
74
|
-
[ -f "$aotlog" ] || {
|
|
76
|
+
[ -f "$aotlog" ] || { refused branch-check-aot-log-no-file "--aot-log needs an AOT publish log file" >&2; exit 2; }
|
|
75
77
|
;;
|
|
76
78
|
--allow)
|
|
77
79
|
shift
|
|
78
|
-
[ -n "${1:-}" ] || {
|
|
80
|
+
[ -n "${1:-}" ] || { refused branch-check-allow-no-path "--allow needs a path" >&2; exit 2; }
|
|
79
81
|
allows+=("$1")
|
|
80
82
|
;;
|
|
81
|
-
-*)
|
|
83
|
+
-*) refused branch-check-unknown-option "unknown option $1" >&2; exit 2 ;;
|
|
82
84
|
*) clone="$1" ;;
|
|
83
85
|
esac
|
|
84
86
|
shift
|
|
85
87
|
done
|
|
86
88
|
|
|
87
|
-
cd "$clone" 2>/dev/null || {
|
|
88
|
-
git rev-parse --git-dir >/dev/null 2>&1 || {
|
|
89
|
+
cd "$clone" 2>/dev/null || { refused branch-check-not-a-directory "$clone is not a directory" >&2; exit 2; }
|
|
90
|
+
git rev-parse --git-dir >/dev/null 2>&1 || { refused branch-check-not-a-clone "$clone is not a git clone" >&2; exit 2; }
|
|
89
91
|
# Git prints paths from the top and reads pathspecs from here, so anywhere else
|
|
90
92
|
# every scan below would match nothing.
|
|
91
|
-
cd "$(git rev-parse --show-toplevel)" || {
|
|
93
|
+
cd "$(git rev-parse --show-toplevel)" || { refused branch-check-top-unreachable "cannot reach the top of $clone" >&2; exit 2; }
|
|
92
94
|
|
|
93
95
|
if [ -z "$base" ]; then
|
|
94
96
|
for candidate in upstream/main upstream/master origin/main origin/master; do
|
|
95
97
|
if git rev-parse --verify -q "$candidate" >/dev/null 2>&1; then base="$candidate"; break; fi
|
|
96
98
|
done
|
|
97
99
|
fi
|
|
98
|
-
[ -n "$base" ] || {
|
|
99
|
-
git rev-parse --verify -q "$base" >/dev/null 2>&1 || {
|
|
100
|
+
[ -n "$base" ] || { refused branch-check-no-base-resolved "no base ref resolved - pass --base REF" >&2; exit 2; }
|
|
101
|
+
git rev-parse --verify -q "$base" >/dev/null 2>&1 || { refused branch-check-base-unresolvable "base $base does not resolve" >&2; exit 2; }
|
|
100
102
|
|
|
101
103
|
blocked=0
|
|
102
|
-
block() {
|
|
104
|
+
block() { refused "$1" "$2"; blocked=1; }
|
|
103
105
|
# Whether the base already carries a path. "rev:path" is not used because Git
|
|
104
106
|
# for Windows' shell rewrites an argument shaped like "a/b:.c/d" as a path list.
|
|
105
107
|
in_base() { [ -n "$(git ls-tree --name-only "$base" -- "$1" 2>/dev/null)" ]; }
|
|
@@ -109,7 +111,7 @@ echo "== branch check: $(git rev-parse --abbrev-ref HEAD) against $base =="
|
|
|
109
111
|
# What you tested is what you file, or you do not know what you are filing.
|
|
110
112
|
dirty=$(git status --porcelain)
|
|
111
113
|
if [ -n "$dirty" ]; then
|
|
112
|
-
block "the working tree is dirty, so the commits are not what you tested"
|
|
114
|
+
block branch-check-tree-dirty "the working tree is dirty, so the commits are not what you tested"
|
|
113
115
|
printf '%s\n' "$dirty" | sed 's/^/ /'
|
|
114
116
|
fi
|
|
115
117
|
|
|
@@ -120,23 +122,23 @@ case "$full" in
|
|
|
120
122
|
rest="${full#refs/remotes/}"; remote="${rest%%/*}"; rbranch="${rest#*/}"
|
|
121
123
|
live=$(git ls-remote "$remote" "refs/heads/$rbranch" 2>/dev/null | awk '{print $1}')
|
|
122
124
|
if [ -z "$live" ]; then
|
|
123
|
-
block "cannot read $rbranch from $remote, so whether $base is current is unknown"
|
|
125
|
+
block branch-check-remote-unreadable "cannot read $rbranch from $remote, so whether $base is current is unknown"
|
|
124
126
|
elif [ "$live" != "$(git rev-parse "$base")" ]; then
|
|
125
127
|
echo "CHECK: the base moved: $remote has $rbranch at ${live:0:12}, $base is $(git rev-parse --short=12 "$base") - file-pr.sh refuses when the new commits touch this branch's files"
|
|
126
128
|
fi
|
|
127
129
|
;;
|
|
128
|
-
*) block "base $base is not a remote-tracking ref, so whether it is current cannot be checked - pass --base <remote>/<branch>" ;;
|
|
130
|
+
*) block branch-check-base-not-tracking "base $base is not a remote-tracking ref, so whether it is current cannot be checked - pass --base <remote>/<branch>" ;;
|
|
129
131
|
esac
|
|
130
132
|
|
|
131
133
|
if ! git merge-base --is-ancestor "$base" HEAD 2>/dev/null; then
|
|
132
|
-
block "HEAD is not on top of $base - rebase before filing"
|
|
134
|
+
block branch-check-not-on-base "HEAD is not on top of $base - rebase before filing"
|
|
133
135
|
fi
|
|
134
136
|
|
|
135
137
|
namestat=$(gdiff --name-status -M "$base..HEAD" 2>/dev/null)
|
|
136
138
|
files=$(printf '%s\n' "$namestat" | awk -F'\t' 'NF == 3 {print $3} NF == 2 {print $2}')
|
|
137
139
|
renames=$(printf '%s\n' "$namestat" | awk -F'\t' 'NF == 3 {print $2 "\t" $3}')
|
|
138
140
|
if [ -z "$files" ]; then
|
|
139
|
-
block "no files differ from $base - there is nothing to file"
|
|
141
|
+
block branch-check-no-files-differ "no files differ from $base - there is nothing to file"
|
|
140
142
|
fi
|
|
141
143
|
|
|
142
144
|
# Prints why a path is a working artifact, or nothing when it is not one.
|
|
@@ -172,7 +174,7 @@ while IFS= read -r f; do
|
|
|
172
174
|
norm=$(printf '%s\n' "$sibs" | grep -c '^100644$')
|
|
173
175
|
exec=$(printf '%s\n' "$sibs" | grep -c '^100755$')
|
|
174
176
|
if [ "$norm" -gt "$exec" ]; then
|
|
175
|
-
block "$f is committed 100755 but $norm of its $ext siblings are 100644"
|
|
177
|
+
block branch-check-mode-unlike-siblings "$f is committed 100755 but $norm of its $ext siblings are 100644"
|
|
176
178
|
fi
|
|
177
179
|
fi
|
|
178
180
|
fi
|
|
@@ -185,12 +187,12 @@ while IFS= read -r f; do
|
|
|
185
187
|
# files build output.
|
|
186
188
|
if ! in_base "$f"; then
|
|
187
189
|
if git check-ignore -q --no-index -- "$f" 2>/dev/null; then
|
|
188
|
-
block "$f is added by this branch and the repository's .gitignore excludes it"
|
|
190
|
+
block branch-check-file-gitignored "$f is added by this branch and the repository's .gitignore excludes it"
|
|
189
191
|
fi
|
|
190
192
|
fi
|
|
191
193
|
|
|
192
194
|
why=$(artifact_why "$f")
|
|
193
|
-
[ -z "$why" ] || block "$f $why"
|
|
195
|
+
[ -z "$why" ] || block branch-check-artifact-in-diff "$f $why"
|
|
194
196
|
done <<EOF
|
|
195
197
|
$files
|
|
196
198
|
EOF
|
|
@@ -201,7 +203,7 @@ EOF
|
|
|
201
203
|
trailers=$(git log --format='%h author %an <%ae>, committer %cn <%ce>%n%b' "$base..HEAD" 2>/dev/null \
|
|
202
204
|
| grep -iE '^co-authored-by:.*(claude|anthropic|copilot|cursor|aider|codex|gemini)|^claude-session:|claude\.ai/code/session_|generated with .*claude|noreply@anthropic\.com|cursoragent@cursor\.com|noreply@aider\.chat')
|
|
203
205
|
if [ -n "$trailers" ]; then
|
|
204
|
-
block "a commit carries a tool trailer or a session link, or a tool identity, which no project asked for"
|
|
206
|
+
block branch-check-tool-mark-in-commit "a commit carries a tool trailer or a session link, or a tool identity, which no project asked for"
|
|
205
207
|
printf '%s\n' "$trailers" | sed 's/^/ /'
|
|
206
208
|
fi
|
|
207
209
|
|
|
@@ -210,7 +212,7 @@ fi
|
|
|
210
212
|
# catching them.
|
|
211
213
|
usernames=$(git log --format='%b' "$base..HEAD" 2>/dev/null | grep -E '^Signed-off-by: [^ <]+ <')
|
|
212
214
|
if [ -n "$usernames" ]; then
|
|
213
|
-
block "a Signed-off-by names a username; the DCO asks for a real name"
|
|
215
|
+
block branch-check-signoff-username "a Signed-off-by names a username; the DCO asks for a real name"
|
|
214
216
|
printf '%s\n' "$usernames" | sed 's/^/ /'
|
|
215
217
|
fi
|
|
216
218
|
|
|
@@ -221,9 +223,9 @@ comment_args=(--base "$base")
|
|
|
221
223
|
comments=$(bash "$here/comment-check.sh" . "${comment_args[@]}" 2>&1); comment_rc=$?
|
|
222
224
|
case "$comment_rc" in
|
|
223
225
|
0) ;;
|
|
224
|
-
1) block "the branch adds comments to code that nobody asked for"
|
|
226
|
+
1) block branch-check-comments-added "the branch adds comments to code that nobody asked for"
|
|
225
227
|
printf '%s\n' "$comments" | grep -E '^(REFUSED|CHECK): ' | sed 's/^REFUSED: / /' ;;
|
|
226
|
-
*) block "comment-check.sh could not run: $comments" ;;
|
|
228
|
+
*) block branch-check-comment-check-failed "comment-check.sh could not run: $comments" ;;
|
|
227
229
|
esac
|
|
228
230
|
printf '%s\n' "$comments" | grep -E '^CHECK: ' | sed 's/^/ /'
|
|
229
231
|
|
|
@@ -264,7 +266,7 @@ if [ -n "$suppressions" ]; then
|
|
|
264
266
|
fi
|
|
265
267
|
done <<< "$suppressions"
|
|
266
268
|
if [ -n "$unshown" ]; then
|
|
267
|
-
block "the branch adds a warning suppression, and no build log shows the warning firing ($unshown)"
|
|
269
|
+
block branch-check-suppression-unshown "the branch adds a warning suppression, and no build log shows the warning firing ($unshown)"
|
|
268
270
|
printf '%s\n' "$suppressions" | sed 's/^/ /'
|
|
269
271
|
fi
|
|
270
272
|
fi
|
|
@@ -289,7 +291,7 @@ if [ -n "$aotdecl" ]; then
|
|
|
289
291
|
done
|
|
290
292
|
fi
|
|
291
293
|
if [ -n "$reflection" ] && [ "$published" -eq 0 ]; then
|
|
292
|
-
block "the branch adds reflection to a project that declares AOT or trim support (${aotdecl% }), and no --aot-log shows an AOT publish of it"
|
|
294
|
+
block branch-check-reflection-under-aot "the branch adds reflection to a project that declares AOT or trim support (${aotdecl% }), and no --aot-log shows an AOT publish of it"
|
|
293
295
|
printf '%s\n' "$reflection" | sed 's/^/ /'
|
|
294
296
|
fi
|
|
295
297
|
fi
|
|
@@ -315,7 +317,7 @@ while IFS= read -r f; do
|
|
|
315
317
|
stat=$(gdiff --numstat -M "$base..HEAD" -- "${spec[@]}" | head -1)
|
|
316
318
|
# A file with no diff was not scanned, and that is never the same as clean.
|
|
317
319
|
if [ -z "$stat" ]; then
|
|
318
|
-
block "git gave no diff for $f, so nothing in it was scanned"
|
|
320
|
+
block branch-check-no-diff-for-file "git gave no diff for $f, so nothing in it was scanned"
|
|
319
321
|
continue
|
|
320
322
|
fi
|
|
321
323
|
is_test_path "$f" || nadded=$((nadded + $(printf '%s' "$stat" | awk '{print ($1 == "-") ? 0 : $1}')))
|
|
@@ -324,20 +326,20 @@ while IFS= read -r f; do
|
|
|
324
326
|
leaks=$(printf '%s\n' "$addedf" | grep -oE "$leak_re" | sort -u)
|
|
325
327
|
netleaks="$netleaks
|
|
326
328
|
$leaks"
|
|
327
|
-
[ -z "$leaks" ] || block "$f adds a personal path or a credential: $(printf '%s' "$leaks" | tr '\n' ' ')"
|
|
329
|
+
[ -z "$leaks" ] || block branch-check-leak-in-diff "$f adds a personal path or a credential: $(printf '%s' "$leaks" | tr '\n' ' ')"
|
|
328
330
|
paths=$(printf '%s\n' "$addedf" | grep -oE "$path_re" | sort -u)
|
|
329
331
|
[ -z "$paths" ] || echo "CHECK: $f adds a user path, a fixture or an example unless it is yours: $(printf '%s' "$paths" | tr '\n' ' ')"
|
|
330
332
|
case "$f" in
|
|
331
333
|
package-lock.json|*/package-lock.json|yarn.lock|*/yarn.lock|pnpm-lock.yaml|*/pnpm-lock.yaml|Cargo.lock|*/Cargo.lock|go.sum|*/go.sum|poetry.lock|*/poetry.lock|uv.lock|*/uv.lock|Gemfile.lock|*/Gemfile.lock|composer.lock|*/composer.lock|packages.lock.json|*/packages.lock.json|vendor/*|*/vendor/*|node_modules/*|*/node_modules/*|*.min.js|*.pb.go|*_generated.*|*.g.cs|*.designer.cs|*.Designer.cs)
|
|
332
|
-
block "$f is a lockfile, vendored or generated file - a build rewrote it, or pass --allow $f if the change is about it" ;;
|
|
334
|
+
block branch-check-generated-file "$f is a lockfile, vendored or generated file - a build rewrote it, or pass --allow $f if the change is about it" ;;
|
|
333
335
|
esac
|
|
334
336
|
case "$stat" in
|
|
335
|
-
-*) block "$f is binary - pass --allow $f if the change needs it" ;;
|
|
337
|
+
-*) block branch-check-binary-file "$f is binary - pass --allow $f if the change needs it" ;;
|
|
336
338
|
*)
|
|
337
339
|
total=$(printf '%s' "$stat" | awk '{print $1 + $2}')
|
|
338
340
|
real=$(gdiff --numstat -M --ignore-space-at-eol --ignore-cr-at-eol "$base..HEAD" -- "${spec[@]}" | awk '{print $1 + $2}')
|
|
339
341
|
if [ "$total" -ge 10 ] && [ $((${real:-0} * 2)) -lt "$total" ]; then
|
|
340
|
-
block "$f changes $total lines, of which ${real:-0} differ beyond whitespace and line endings - restore the file's own endings"
|
|
342
|
+
block branch-check-whitespace-rewrite "$f changes $total lines, of which ${real:-0} differ beyond whitespace and line endings - restore the file's own endings"
|
|
341
343
|
fi
|
|
342
344
|
;;
|
|
343
345
|
esac
|
|
@@ -354,12 +356,12 @@ if [ "$(git rev-list --count "$base..HEAD")" -gt 1 ]; then
|
|
|
354
356
|
history=$(gitq log -p -U0 -M --no-ext-diff --no-textconv --no-color --format= "$base..HEAD" | added_lines)
|
|
355
357
|
gone=$(printf '%s\n' "$history" | while IFS=$'\t' read -r f line; do allowed "$f" || printf '%s\n' "$line"; done \
|
|
356
358
|
| grep -oE "$leak_re" | sort -u | grep -vxF -e "" -f <(printf '%s\n' "$netleaks"))
|
|
357
|
-
[ -z "$gone" ] || block "the branch's history carries a personal path or a credential: $(printf '%s' "$gone" | tr '\n' ' ')- a later commit does not remove it from what is pushed; rewrite the commits"
|
|
359
|
+
[ -z "$gone" ] || block branch-check-leak-in-history "the branch's history carries a personal path or a credential: $(printf '%s' "$gone" | tr '\n' ' ')- a later commit does not remove it from what is pushed; rewrite the commits"
|
|
358
360
|
while IFS= read -r f; do
|
|
359
361
|
[ -n "$f" ] || continue
|
|
360
362
|
printf '%s\n' "$files" | grep -qxF -- "$f" && continue
|
|
361
363
|
why=$(artifact_why "$f")
|
|
362
|
-
[ -z "$why" ] || block "$f is in this branch's history: it $why, and a later commit does not remove it from what is pushed; rewrite the commits"
|
|
364
|
+
[ -z "$why" ] || block branch-check-artifact-in-history "$f is in this branch's history: it $why, and a later commit does not remove it from what is pushed; rewrite the commits"
|
|
363
365
|
done <<< "$(gitq log --name-only --format= "$base..HEAD" | sort -u)"
|
|
364
366
|
fi
|
|
365
367
|
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
# --accept-truncated read a repository whose tree GitHub truncates (over
|
|
26
26
|
# 100,000 entries) after its policy was read by hand; the
|
|
27
27
|
# printout records that it was
|
|
28
|
-
# --reading <text> what a MENTION means for this change, read by
|
|
29
|
-
# an agent; saved with --out, and the filing
|
|
30
|
-
#
|
|
28
|
+
# --reading <text> what a MENTION or a DISCLOSE means for this change, read by
|
|
29
|
+
# a person or an agent; saved with --out, and the filing
|
|
30
|
+
# gates hold either until one is there
|
|
31
31
|
#
|
|
32
32
|
# Lines are joined into paragraphs before they are read, because a hard-wrapped
|
|
33
33
|
# ban names AI on one line and forbids it on the next, and a paragraph is read
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
# a sentence requires that AI use be disclosed, MENTION when AI is named without
|
|
39
39
|
# either, CLEAN when no policy file names it, UNREAD when GitHub refused,
|
|
40
40
|
# throttled or truncated any listing or file, so a failure is never read as
|
|
41
|
-
# silence. A word list reads no grammar, so MENTION is a hold, not a pass
|
|
41
|
+
# silence. A word list reads no grammar, so MENTION is a hold, not a pass, and
|
|
42
|
+
# so is DISCLOSE: a disclosure rule seldom stands alone in a policy. Every
|
|
42
43
|
# policy-named file is read; READMEs are capped at 40 per repository, the
|
|
43
44
|
# shallowest first, and the cap is printed.
|
|
44
45
|
# The printout ends with the project's CI legs, as ci-legs.sh prints them: the
|
|
@@ -76,7 +77,23 @@ AI='\bAIs?\b|\bA\.I\.|artificial intelligence|\bLLMs?\b|large language models?|\
|
|
|
76
77
|
# object in the same clause is the work or the AI term: "a client rejects that
|
|
77
78
|
# manifest" beside "Claude Code" is a README describing a tool.
|
|
78
79
|
BAN_RE="(\b(not|never|cannot)|n.t)( be)? (accept|allow|permit|welcome|merg|review|consider)|prohibit|forbid|disallow|\bbans?\b|banned|unwelcome|unacceptable|not acceptable|zero tolerance|will be (closed|rejected|declined|refused)|closed without|\b(reject|decline|refuse)[sd]?\b[^,;:.]*(contribution|pull request|\bPRs?\b|patch|submission|merge request|$AI)|\b(are|is|get|gets) (rejected|declined|refused)\b|refrain from|\bno[- ](ai|llm|machine-generated|generative)s?([- ](use|usage|generated|written|assisted|tools?|code|contributions?|content|output|PRs?|patch|polic|rules?|ai|llms?)|[.!]|$)|(do not|don.t|never|must not|may not|should not|shouldn.t) (use|submit|send|open|contribute)[^,;:]*($AI)|avoid( using)?[^,;:]*($AI)|($AI)[^,;:]* (must|may|should|can) not be (used|submitted|contributed|sent)"
|
|
79
|
-
|
|
80
|
+
# A disclosure word counts where the sentence reads as asking the contributor to
|
|
81
|
+
# say AI was used. A credit, a thanks, the project speaking of itself ("we used
|
|
82
|
+
# AI", "to be transparent about our usage") and a rule about something else ("if
|
|
83
|
+
# you use AI, comments must be correct") mostly read MENTION now. The list reads
|
|
84
|
+
# no grammar and still misreads some: a heading "AI Disclosure" over a credit, a
|
|
85
|
+
# lone maintainer's "I used AI", "disclosure" of something other than AI use. So
|
|
86
|
+
# DISCLOSE is held for a recorded reading as MENTION is, and what the list
|
|
87
|
+
# misses reads MENTION, which holds the filing too.
|
|
88
|
+
DISCLOSE_RE='disclos|(\bAI\b|\bLLMs?\b)[a-z -]{0,12}disclaimer|declar[a-z]* [^.;]{0,40}\b(use|usage|using|assistance|involvement)\b|(must|should|need to|have to|required to|please|make sure to|be sure to) [^.;]{0,20}reveal|(must|should|please|need to|have to|required to) (state|say|indicate|mention|specify)|(please|must|should|need to|have to|expected to) be transparent|label(l)?ed as|clearly (state|indicate|mark)|\bI (have )?used (AI\b|an AI\b|generative AI\b|LLMs?\b)|which (ai|llm) tool|ai transcript|let us know [^.;]{0,50}(\bAI\b|\bLLMs?\b)|tell us [^.;]{0,50}(\bAI\b|\bLLMs?\b)|assisted-by|generated-by|\bmark(ed)? (ai|llm)|(\bAI\b|\bLLM)[a-z -]{0,30}(must|should) be (clearly )?(marked|labell?ed)'
|
|
89
|
+
# Disclosure of a vulnerability is not disclosure of AI use: those phrases are
|
|
90
|
+
# taken out of a sentence, every one of them, before the list above is tried.
|
|
91
|
+
# awk, because sed has no portable way to ignore case.
|
|
92
|
+
aside_other_disclosure() {
|
|
93
|
+
awk '{ while (match(tolower($0), /(vulnerabilit[a-z]*|security|coordinated|responsible)[ -]disclosure/))
|
|
94
|
+
$0 = substr($0, 1, RSTART - 1) substr($0, RSTART + RLENGTH)
|
|
95
|
+
print }'
|
|
96
|
+
}
|
|
80
97
|
|
|
81
98
|
branch_opt=""
|
|
82
99
|
out=0
|
|
@@ -197,7 +214,7 @@ scan() {
|
|
|
197
214
|
[ "$nhits" -le "$MAX_PRINTED" ] || echo " (and $((nhits - MAX_PRINTED)) more, all of them read)"
|
|
198
215
|
# What a project does itself is not what it asks of a contributor.
|
|
199
216
|
printf '%s\n' "$hits" | sed -E 's/[Ww]e (do not|don.t) use//g' | grep -aqiE "$BAN_RE" && ban=1
|
|
200
|
-
printf '%s\n' "$hits" | grep -aqiE "$DISCLOSE_RE" && disclose=1
|
|
217
|
+
printf '%s\n' "$hits" | aside_other_disclosure | grep -aqiE "$DISCLOSE_RE" && disclose=1
|
|
201
218
|
else
|
|
202
219
|
echo " (clean) $label$f"
|
|
203
220
|
fi
|
|
@@ -241,7 +258,9 @@ for repo in "${repos[@]}"; do
|
|
|
241
258
|
if [ "$ban" -eq 1 ]; then echo "RESULT: BAN (a policy file forbids or closes AI-written contributions; never file here)"
|
|
242
259
|
elif [ "$unread" -gt 0 ]; then echo "RESULT: UNREAD ($unread policy file(s) or listing(s) could not be fetched; rerun when GitHub answers)"
|
|
243
260
|
elif [ "$truncated" -eq 1 ]; then echo "RESULT: UNREAD (GitHub truncated the file listing; read the policy by hand, then rerun with --accept-truncated)"
|
|
244
|
-
elif [ "$disclose" -eq 1 ]; then
|
|
261
|
+
elif [ "$disclose" -eq 1 ]; then
|
|
262
|
+
echo "RESULT: DISCLOSE (a policy file requires AI use to be disclosed; say so in the body; read the lines above, then rerun with --reading 'what they mean for this change')"
|
|
263
|
+
[ -z "$reading" ] || echo "READING: $reading"
|
|
245
264
|
elif [ "$found" -eq 1 ]; then
|
|
246
265
|
echo "RESULT: MENTION (a policy file names AI and no sentence reads as a ban or a disclosure rule; read the lines above, then rerun with --reading 'what they mean for this change')"
|
|
247
266
|
[ -z "$reading" ] || echo "READING: $reading"
|
|
@@ -16,15 +16,17 @@
|
|
|
16
16
|
# Exits 1 when it finds claims to re-derive, 0 when it finds none, 2 on a usage
|
|
17
17
|
# error. Exit 1 is not a refusal to send; it is a refusal to send unread.
|
|
18
18
|
set -u
|
|
19
|
+
# shellcheck source=scripts/refuse.sh
|
|
20
|
+
. "$(cd "$(dirname "$0")" && pwd)/refuse.sh"
|
|
19
21
|
|
|
20
22
|
usage() { awk 'NR>1 && /^#/ {sub(/^# ?/, ""); print; next} NR>1 {exit}' "$0"; }
|
|
21
23
|
|
|
22
24
|
case "${1:-}" in
|
|
23
25
|
--help|-h) usage; exit 0 ;;
|
|
24
|
-
"")
|
|
26
|
+
"") refused claim-check-no-file-named "name the file holding the text" >&2; exit 2 ;;
|
|
25
27
|
esac
|
|
26
28
|
file="$1"
|
|
27
|
-
[ -f "$file" ] || {
|
|
29
|
+
[ -f "$file" ] || { refused claim-check-file-missing "$file does not exist" >&2; exit 2; }
|
|
28
30
|
|
|
29
31
|
# Strip fenced code and quoted lines: a number inside pasted output is evidence,
|
|
30
32
|
# not a claim being made. A table row is ours, and so is what it counts.
|
|
@@ -34,46 +34,53 @@
|
|
|
34
34
|
# close that failed, 1 when the close went through but the notes line could
|
|
35
35
|
# not be written or the fork branch could not be deleted.
|
|
36
36
|
set -u
|
|
37
|
+
# shellcheck source=scripts/refuse.sh
|
|
38
|
+
. "$(cd "$(dirname "$0")" && pwd)/refuse.sh"
|
|
37
39
|
|
|
38
40
|
usage() { awk 'NR>1 && /^#/ {sub(/^# ?/, ""); print; next} NR>1 {exit}' "$0"; }
|
|
39
41
|
case "${1:-}" in --help|-h) usage; exit 0 ;; esac
|
|
40
42
|
|
|
41
43
|
repo="${1:-}"; num="${2:-}"
|
|
42
|
-
case "$repo" in */*) ;; *)
|
|
43
|
-
case "$num" in ''|*[!0-9]*)
|
|
44
|
+
case "$repo" in */*) ;; *) refused close-repo-form "name the repository as owner/repo" >&2; exit 2 ;; esac
|
|
45
|
+
case "$num" in ''|*[!0-9]*) refused close-no-number "name the pull request number" >&2; exit 2 ;; esac
|
|
44
46
|
shift 2
|
|
45
47
|
body=""; clone=""
|
|
46
48
|
while [ "$#" -gt 0 ]; do
|
|
47
49
|
case "$1" in
|
|
48
50
|
--body-file) body="${2:-}"; shift ;;
|
|
49
51
|
--clone) clone="${2:-}"; shift ;;
|
|
50
|
-
*)
|
|
52
|
+
*) refused close-unknown-argument "unknown argument $1" >&2; exit 2 ;;
|
|
51
53
|
esac
|
|
52
54
|
shift
|
|
53
55
|
done
|
|
54
|
-
[ -f "$body" ] || {
|
|
56
|
+
[ -f "$body" ] || { refused close-body-file-missing "--body-file names no file" >&2; exit 2; }
|
|
55
57
|
here=$(cd "$(dirname "$0")" && pwd)
|
|
56
58
|
# shellcheck source=scripts/common.sh
|
|
57
59
|
. "$here/common.sh"
|
|
58
60
|
home="${HOUSEBROKEN_HOME:-$HOME/.housebroken}"
|
|
59
61
|
|
|
60
|
-
|
|
61
|
-
refuse() {
|
|
62
|
-
|
|
62
|
+
reasons=""
|
|
63
|
+
refuse() { refusal_log "$1"; reasons="$reasons
|
|
64
|
+
$2 [$1]"; }
|
|
65
|
+
refuse_line() { # a "name|message" line from a shared check; one with no name is listed as it came
|
|
66
|
+
if [[ "$1" == *"|"* ]]; then refuse "${1%%|*}" "${1#*|}"; return; fi
|
|
67
|
+
refusal_log ""; reasons="$reasons
|
|
68
|
+
$1"
|
|
69
|
+
}
|
|
63
70
|
|
|
64
71
|
# The first line of our own words: not code, not a quote, and with a letter in it.
|
|
65
72
|
# shellcheck disable=SC2016 # the backticks are markdown, matched literally
|
|
66
73
|
own=$(awk '/^(```|~~~)/ {f = !f; next} !f && !/^ *>/' "$body" | sed 's/`[^`]*`//g' | grep -m1 '[[:alpha:]]')
|
|
67
|
-
[ -n "$own" ] || refuse "it carries no note of its own; say why it is withdrawn and where the work went"
|
|
68
|
-
while IFS= read -r r; do
|
|
74
|
+
[ -n "$own" ] || refuse close-no-note-of-its-own "it carries no note of its own; say why it is withdrawn and where the work went"
|
|
75
|
+
while IFS= read -r r; do refuse_line "$r"; done < <(tone_refusals "$body" 0 "a close note is one to three")
|
|
69
76
|
|
|
70
77
|
refargs=("$repo" "$body"); [ -n "$clone" ] && refargs+=(--clone "$clone")
|
|
71
78
|
if ! refs=$(bash "$here/ref-check.sh" "${refargs[@]}" 2>&1); then
|
|
72
|
-
refuse "it names something that does not exist: $(printf '%s\n' "$refs" | grep 'NOT FOUND' | tr -s ' ' | tr '\n' ';')"
|
|
79
|
+
refuse close-reference-not-found "it names something that does not exist: $(printf '%s\n' "$refs" | grep 'NOT FOUND' | tr -s ' ' | tr '\n' ';')"
|
|
73
80
|
fi
|
|
74
81
|
|
|
75
82
|
user="${HOUSEBROKEN_USER:-$(gh api user --jq .login 2>/dev/null)}"
|
|
76
|
-
[ -n "$user" ] || {
|
|
83
|
+
[ -n "$user" ] || { refused close-gh-unauthenticated "gh is not authenticated, so whose pull request this is cannot be read" >&2; exit 2; }
|
|
77
84
|
fork_owner=""; fork=""; branch=""
|
|
78
85
|
if pr=$(gh pr view "$num" --repo "$repo" --json author,state,headRefName,headRepository,headRepositoryOwner 2>/dev/null); then
|
|
79
86
|
author=$(printf '%s' "$pr" | jq -r '.author.login // "?"' | tr -d '\r')
|
|
@@ -81,21 +88,21 @@ if pr=$(gh pr view "$num" --repo "$repo" --json author,state,headRefName,headRep
|
|
|
81
88
|
fork_owner=$(printf '%s' "$pr" | jq -r '.headRepositoryOwner.login // ""' | tr -d '\r')
|
|
82
89
|
fork=$(printf '%s' "$pr" | jq -r '.headRepository.name // ""' | tr -d '\r')
|
|
83
90
|
branch=$(printf '%s' "$pr" | jq -r '.headRefName // ""' | tr -d '\r')
|
|
84
|
-
[ "$author" = "$user" ] || refuse "$repo#$num is $author's, not yours"
|
|
85
|
-
[ "$state" = "OPEN" ] || refuse "$repo#$num is $state; only an open pull request is closed"
|
|
91
|
+
[ "$author" = "$user" ] || refuse close-not-yours "$repo#$num is $author's, not yours"
|
|
92
|
+
[ "$state" = "OPEN" ] || refuse close-not-open "$repo#$num is $state; only an open pull request is closed"
|
|
86
93
|
else
|
|
87
|
-
refuse "cannot read $repo#$num, so whose it is and whether it is open are unknown"
|
|
94
|
+
refuse close-thread-unreadable "cannot read $repo#$num, so whose it is and whether it is open are unknown"
|
|
88
95
|
fi
|
|
89
96
|
|
|
90
97
|
log="$home/replies/${repo%%/*}-${repo##*/}.log"
|
|
91
98
|
if [ -f "$log" ]; then
|
|
92
99
|
last=$(tail -1 "$log" | awk '{print $1}')
|
|
93
100
|
since=$(( $(date -u +%s) - ${last:-0} ))
|
|
94
|
-
[ "$since" -ge 600 ] || refuse "your last comment on $repo went out ${since}s ago; space them ten minutes apart"
|
|
101
|
+
[ "$since" -ge 600 ] || refuse close-too-soon-after-last "your last comment on $repo went out ${since}s ago; space them ten minutes apart"
|
|
95
102
|
fi
|
|
96
103
|
|
|
97
|
-
if [ -n "$
|
|
98
|
-
|
|
104
|
+
if [ -n "$reasons" ]; then
|
|
105
|
+
refused close-not-ready "the close of $repo#$num is not ready:$reasons" >&2
|
|
99
106
|
exit 2
|
|
100
107
|
fi
|
|
101
108
|
claims=$(bash "$here/claim-check.sh" "$body" 2>&1) || printf 'Posting these claims, which step 10 had you re-derive with housebroken claims first:\n%s\n' "$claims" >&2
|
|
@@ -29,6 +29,8 @@
|
|
|
29
29
|
# * is one only when a space follows, so *out = 0; is code. Docstrings, comments
|
|
30
30
|
# that share a line with code, and files of any other kind are not measured.
|
|
31
31
|
set -u
|
|
32
|
+
# shellcheck source=scripts/refuse.sh
|
|
33
|
+
. "$(cd "$(dirname "$0")" && pwd)/refuse.sh"
|
|
32
34
|
|
|
33
35
|
usage() { awk 'NR>1 && /^#/ {sub(/^# ?/, ""); print; next} NR>1 {exit}' "$0"; }
|
|
34
36
|
# shellcheck source=scripts/common.sh
|
|
@@ -89,14 +91,14 @@ siblings_open_with_comment() {
|
|
|
89
91
|
work=$(mktemp -d) || exit 2
|
|
90
92
|
trap 'rm -rf "$work"' EXIT
|
|
91
93
|
|
|
92
|
-
|
|
94
|
+
found=0
|
|
93
95
|
measured=0
|
|
94
96
|
report() {
|
|
95
97
|
if [ -n "$asked" ]; then
|
|
96
98
|
echo "CHECK: $* (asked for in $asked)"
|
|
97
99
|
else
|
|
98
|
-
|
|
99
|
-
|
|
100
|
+
refused comment-check-comment-added "$*"
|
|
101
|
+
found=1
|
|
100
102
|
fi
|
|
101
103
|
}
|
|
102
104
|
|
|
@@ -162,7 +164,7 @@ while IFS= read -r f; do
|
|
|
162
164
|
done < "$work/hits"
|
|
163
165
|
done < <(printf '%s\n' "$namestat" | awk -F'\t' 'NF == 3 {print $3} NF == 2 {print $2}')
|
|
164
166
|
|
|
165
|
-
if [ "$
|
|
167
|
+
if [ "$found" -ne 0 ]; then
|
|
166
168
|
echo "comment-check: refused. A comment goes into someone else's code only when its maintainer asks for it."
|
|
167
169
|
exit 1
|
|
168
170
|
fi
|