Skip to content

Commit 24d6790

Browse files
authored
feat(cli): manage repository protection rules (#2193)
1 parent 8b3edcf commit 24d6790

6 files changed

Lines changed: 684 additions & 16 deletions

File tree

‎crates/buzz-cli/README.md‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ buzz channels list
2222

2323
## Usage
2424

25-
All output is JSON on stdout. Errors are JSON on stderr. Exit codes: 0=ok, 1=user error, 2=network, 3=auth, 4=other.
25+
All output is JSON on stdout. Errors are JSON on stderr. Exit codes: 0=ok, 1=user error, 2=network, 3=auth, 4=other, 5=write conflict.
2626

2727
```bash
2828
# Set relay URL (defaults to http://localhost:3000)
@@ -82,11 +82,20 @@ buzz mem set <slug> "my-value"
8282
buzz mem patch <slug> --base-hash <hex> < diff.patch # or --no-base-hash
8383
buzz mem rm <slug>
8484

85+
# Repository protection
86+
buzz repos protect list --id my-repo
87+
buzz repos protect set --id my-repo --ref refs/heads/main --push admin --no-force-push --no-delete
88+
buzz repos protect remove --id my-repo --ref refs/heads/main
89+
8590
# Pipe to jq
8691
buzz channels list | jq '.[].name'
8792
```
8893

89-
## 60 Subcommands across 13 Groups
94+
`protect set` replaces every existing rule for the exact ref pattern. Any
95+
constraint omitted from the command is removed. `protect list` reports malformed
96+
stored rules in `validation_error` so an owner can remove and repair them.
97+
98+
## Commands
9099

91100
| Group | Subcommand | Description |
92101
|-------|-----------|-------------|
@@ -141,6 +150,9 @@ buzz channels list | jq '.[].name'
141150
| `repos` | `create` | Announce a git repository (NIP-34) |
142151
| | `get` | Get a repository announcement |
143152
| | `list` | List repository announcements |
153+
| | `protect list` | List branch and tag protection rules |
154+
| | `protect set` | Create or replace a protection rule |
155+
| | `protect remove` | Remove a protection rule |
144156
| `upload` | `file` | Upload a file to the Blossom store |
145157
| `pack` | `validate` | Validate a persona pack (local, no relay) |
146158
| | `inspect` | Inspect a persona pack (local, no relay) |
@@ -164,5 +176,5 @@ buzz <group> <subcommand> [flags]
164176
165177
stdout: raw relay JSON
166178
stderr: {"error": "category", "message": "detail"}
167-
exit: 0=ok 1=user 2=network 3=auth 4=other
179+
exit: 0=ok 1=user 2=network 3=auth 4=other 5=write conflict
168180
```

‎crates/buzz-cli/TESTING.md‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ via direct DB access. Use this for testing admin operations (archive,
6262
delete-channel, add/remove-channel-member).
6363

6464
```bash
65-
DATABASE_URL=postgres://buzz:buzz_dev@localhost:5432/buzz \
65+
DATABASE_URL="${DATABASE_URL:?set DATABASE_URL for the local Buzz database}" \
6666
cargo run -p buzz-admin -- mint-token \
6767
--name "cli-test" \
6868
--scopes "messages:read,messages:write,channels:read,channels:write,users:read,users:write,files:read,files:write,admin:channels"
@@ -596,10 +596,13 @@ buzz channels delete --channel "$FORUM_ID" | jq .
596596
| 49 | `repos create` | ☐ | |
597597
| 50 | `repos get` | ☐ | |
598598
| 51 | `repos list` | ☐ | |
599-
| 52 | `upload file` | ☐ | |
600-
| 53 | `pack validate` | ☐ | Local, no relay |
601-
| 54 | `pack inspect` | ☐ | Local, no relay |
602-
| 55 | `notes set` | ☐ | First publish, edit/carry, --clear-tags, ambiguity, empty-stdin guard |
603-
| 56 | `notes get` | ☐ | By name, by naddr, --content-only, cross-author, ambiguous → exit 1 |
604-
| 57 | `notes ls` | ☐ | Own, --author all, --tag, --limit |
605-
| 58 | `notes rm` | ☐ | Delete→get 404, double-delete idempotent, missing slug → NotFound |
599+
| 52 | `repos protect list` | ☐ | Empty/populated rules; unknown rules visible; malformed rule reported in validation_error |
600+
| 53 | `repos protect set` | ☐ | Create and replace complete exact-ref rule; verify metadata is preserved |
601+
| 54 | `repos protect remove` | ☐ | Remove exact ref; missing rule → NotFound |
602+
| 55 | `upload file` | ☐ | |
603+
| 56 | `pack validate` | ☐ | Local, no relay |
604+
| 57 | `pack inspect` | ☐ | Local, no relay |
605+
| 58 | `notes set` | ☐ | First publish, edit/carry, --clear-tags, ambiguity, empty-stdin guard |
606+
| 59 | `notes get` | ☐ | By name, by naddr, --content-only, cross-author, ambiguous → exit 1 |
607+
| 60 | `notes ls` | ☐ | Own, --author all, --tag, --limit |
608+
| 61 | `notes rm` | ☐ | Delete→get 404, double-delete idempotent, missing slug → NotFound |

0 commit comments

Comments
 (0)