Skip to content

Commit 6e6b987

Browse files
authored
NIP-34: add PR and PR update events (#1966)
1 parent 3f79b7f commit 6e6b987

File tree

2 files changed

+89
-8
lines changed

2 files changed

+89
-8
lines changed

34.md

Lines changed: 84 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This NIP defines all the ways code collaboration using and adjacent to [`git`](h
1010

1111
## Repository announcements
1212

13-
Git repositories are hosted in Git-enabled servers, but their existence can be announced using Nostr events, as well as their willingness to receive patches, bug reports and comments in general.
13+
Git repositories are hosted in Git-enabled servers, but their existence can be announced using Nostr events. By doing so the author asserts themselves as a maintainer and expresses a willingness to receive patches, bug reports and comments in general, unless `t` tag `personal-fork` is included.
1414

1515
```jsonc
1616
{
@@ -25,6 +25,7 @@ Git repositories are hosted in Git-enabled servers, but their existence can be a
2525
["relays", "<relay-url>", ...], // relays that this repository will monitor for patches and issues
2626
["r", "<earliest-unique-commit-id>", "euc"],
2727
["maintainers", "<other-recognized-maintainer>", ...],
28+
["t","personal-fork"], // optionally indicate author isn't a maintainer
2829
["t", "<arbitrary string>"], // hashtags labelling the repository
2930
]
3031
}
@@ -66,9 +67,13 @@ The `refs` tag can be optionally extended to enable clients to identify how many
6667
}
6768
```
6869

69-
## Patches
70+
## Patches and Pull Requests (PRs)
7071

71-
Patches can be sent by anyone to any repository. Patches to a specific repository SHOULD be sent to the relays specified in that repository's announcement event's `"relays"` tag. Patch events SHOULD include an `a` tag pointing to that repository's announcement address.
72+
Patches and PRs can be sent by anyone to any repository. Patches and PRs to a specific repository SHOULD be sent to the relays specified in that repository's announcement event's `"relays"` tag. Patch and PR events SHOULD include an `a` tag pointing to that repository's announcement address.
73+
74+
Patches SHOULD be used if each event is under 60kb, otherwise PRs SHOULD be used.
75+
76+
### Patches
7277

7378
Patches in a patch set SHOULD include a [NIP-10](10.md) `e` `reply` tag pointing to the previous patch.
7479

@@ -103,9 +108,66 @@ The first patch revision in a patch revision SHOULD include a [NIP-10](10.md) `e
103108

104109
The first patch in a series MAY be a cover letter in the format produced by `git format-patch`.
105110

111+
### Pull Requests
112+
113+
The PR or PR update tip SHOULD be successfully pushed to `refs/nostr/<[PR|PR-Update]-event-id>` in all repositories listed in its `clone` tag before the event is signed.
114+
115+
An attempt SHOULD be made to push this ref to all repositories listed in the repository's announcement event's `"clone"` tag, for which their is reason to believe the user might have write access. This includes each [grasp server](https://njump.me/naddr1qvzqqqrhnypzpgqgmmc409hm4xsdd74sf68a2uyf9pwel4g9mfdg8l5244t6x4jdqy28wumn8ghj7un9d3shjtnwva5hgtnyv4mqqpt8wfshxuqlnvh8x) which can be identified using this method: `clone` tag includes `[http|https]://<grasp-path>/<valid-npub>/<string>.git` and `relays` tag includes `[ws/wss]://<grasp-path>`.
116+
117+
Clients MAY fallback to creating a 'personal-fork' `repository announcement` listing other grasp servers, e.g. from the `User grasp list`, for the purpose of serving the specified commit(s).
118+
119+
```jsonc
120+
{
121+
"kind": 1618,
122+
"content": "<markdown text>",
123+
"tags": [
124+
["a", "30617:<base-repo-owner-pubkey>:<base-repo-id>"],
125+
["r", "<earliest-unique-commit-id-of-repo>"] // so clients can subscribe to all PRs sent to a local git repo
126+
["p", "<repository-owner>"],
127+
["p", "<other-user>"], // optionally send the PR to another user to bring it to their attention
128+
129+
["subject", "<PR-subject>"],
130+
["t", "<PR-label>"], // optional
131+
["t", "<another-PR-label>"], // optional
132+
133+
["c", "<current-commit-id>"], // tip of the PR branch
134+
["clone", "<clone-url>", ...], // at least one git clone url where commit can be downloaded
135+
["branch-name", "<branch-name>"], // optional recommended branch name
136+
137+
["e", "<root-patch-event-id>"], // optionally indicate PR is a revision of an existing patch, which should be closed
138+
["merge-base", "<commit-id>"], // optional: the most recent common ancestor with the target branch
139+
]
140+
}
141+
```
142+
143+
### Pull Request Updates
144+
145+
A PR Update changes the tip of a referenced PR event.
146+
147+
```jsonc
148+
{
149+
"kind": 1619,
150+
"content": "",
151+
"tags": [
152+
["a", "30617:<base-repo-owner-pubkey>:<base-repo-id>"],
153+
["r", "<earliest-unique-commit-id-of-repo>"] // so clients can subscribe to all PRs sent to a local git repo
154+
["p", "<repository-owner>"],
155+
["p", "<other-user>"], // optionally send the PR to another user to bring it to their attention
156+
157+
// NIP-22 tags
158+
["E", "<pull-request-event-id>"],
159+
["P", "<pull-request-author>"],
160+
161+
["c", "<current-commit-id>"], // updated tip of PR
162+
["clone", "<clone-url>", ...], // at least one git clone url where commit can be downloaded
163+
["merge-base", "<commit-id>"], // optional: the most recent common ancestor with the target branch
164+
]
165+
}
166+
```
167+
106168
## Issues
107169

108-
Issues are Markdown text that is just human-readable conversational threads related to the repository: bug reports, feature requests, questions or comments of any kind. Like patches, these SHOULD be sent to the relays specified in that repository's announcement event's `"relays"` tag.
170+
Issues are Markdown text that is just human-readable conversational threads related to the repository: bug reports, feature requests, questions or comments of any kind. Like patches, these SHOULD be sent to the relays specified in that repository's announcement event's `"relays"` tag.
109171

110172
Issues may have a `subject` tag, which clients can utilize to display a header. Additionally, one or more `t` tags may be included to provide labels for the issue.
111173

@@ -125,11 +187,11 @@ Issues may have a `subject` tag, which clients can utilize to display a header.
125187

126188
## Replies
127189

128-
Replies to either a `kind:1621` (_issue_) or a `kind:1617` (_patch_) event should follow [NIP-22 comment](22.md).
190+
Replies to either a `kind:1621` (_issue_), `kind:1617` (_patch_) or `kind:1618` (_pull request_) event should follow [NIP-22 comment](22.md).
129191

130192
## Status
131193

132-
Root Patches and Issues have a Status that defaults to 'Open' and can be set by issuing Status events.
194+
Root Patches, PRs and Issues have a Status that defaults to 'Open' and can be set by issuing Status events.
133195

134196
```jsonc
135197
{
@@ -139,7 +201,7 @@ Root Patches and Issues have a Status that defaults to 'Open' and can be set by
139201
"kind": 1633, // Draft
140202
"content": "<markdown text>",
141203
"tags": [
142-
["e", "<issue-or-original-root-patch-id-hex>", "", "root"],
204+
["e", "<issue-or-PR-or-original-root-patch-id-hex>", "", "root"],
143205
["e", "<accepted-revision-root-id-hex>", "", "reply"], // for when revisions applied
144206
["p", "<repository-owner>"],
145207
["p", "<root-event-author>"],
@@ -165,8 +227,22 @@ The most recent Status event (by `created_at` date) from either the issue/patch
165227

166228
The Status of a patch-revision is to either that of the root-patch, or `1632` (_Closed_) if the root-patch's Status is `1631` (_Applied/Merged_) and the patch-revision isn't tagged in the `1631` (_Applied/Merged_) event.
167229

230+
## User grasp list
231+
232+
List of [grasp servers](https://njump.me/naddr1qvzqqqrhnypzpgqgmmc409hm4xsdd74sf68a2uyf9pwel4g9mfdg8l5244t6x4jdqy28wumn8ghj7un9d3shjtnwva5hgtnyv4mqqpt8wfshxuqlnvh8x) the user generally wishes to use for NIP-34 related activity. It is similar in function to the NIP-65 relay list and NIP-B7 blossom list.
233+
234+
The event SHOULD include a list of `g` tags with grasp service websocket URLs in order of preference.
235+
236+
```jsonc
237+
{
238+
"kind": 10317,
239+
"content": "",
240+
"tags": [
241+
["g", "<grasp-service-websocket-url>"], // zero or more grasp sever urls
242+
]
243+
}
244+
```
168245

169246
## Possible things to be added later
170247

171-
- "branch merge" kind (specifying a URL from where to fetch the branch to be merged)
172248
- inline file comments kind (we probably need one for patches and a different one for merged files)

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ They exist to document what may be implemented by [Nostr](https://github.com/nos
160160
| `1311` | Live Chat Message | [53](53.md) |
161161
| `1337` | Code Snippet | [C0](C0.md) |
162162
| `1617` | Patches | [34](34.md) |
163+
| `1618` | Pull Requests | [34](34.md) |
164+
| `1619` | Pull Request Updates | [34](34.md) |
163165
| `1621` | Issues | [34](34.md) |
164166
| `1622` | Git Replies (deprecated) | [34](34.md) |
165167
| `1630`-`1633` | Status | [34](34.md) |
@@ -317,6 +319,7 @@ They exist to document what may be implemented by [Nostr](https://github.com/nos
317319
| ----------------- | ------------------------------------ | ------------------------------- | -------------------------------------------------- |
318320
| `a` | coordinates to an event | relay URL | [01](01.md) |
319321
| `A` | root address | relay URL | [22](22.md) |
322+
| `c` | commit id | | [34](34.md) |
320323
| `d` | identifier | -- | [01](01.md) |
321324
| `e` | event id (hex) | relay URL, marker, pubkey (hex) | [01](01.md), [10](10.md) |
322325
| `E` | root event id | relay URL | [22](22.md) |
@@ -345,6 +348,7 @@ They exist to document what may be implemented by [Nostr](https://github.com/nos
345348
| `alt` | summary | -- | [31](31.md) |
346349
| `amount` | millisatoshis, stringified | -- | [57](57.md) |
347350
| `bolt11` | `bolt11` invoice | -- | [57](57.md) |
351+
| `branch-name` | branch name suggestion | -- | [34](34.md) |
348352
| `challenge` | challenge string | -- | [42](42.md) |
349353
| `client` | name, address | relay URL | [89](89.md) |
350354
| `clone` | git clone URL | -- | [34](34.md) |
@@ -358,6 +362,7 @@ They exist to document what may be implemented by [Nostr](https://github.com/nos
358362
| `expiration` | unix timestamp (string) | -- | [40](40.md) |
359363
| `file` | full path (string) | -- | [35](35.md) |
360364
| `goal` | event id (hex) | relay URL | [75](75.md) |
365+
| `merge-base` | commit id | | [34](34.md) |
361366
| `HEAD` | `ref: refs/heads/<branch-name>` | | [34](34.md) |
362367
| `image` | image URL | dimensions in pixels | [23](23.md), [52](52.md), [58](58.md) |
363368
| `imeta` | inline metadata | -- | [92](92.md) |

0 commit comments

Comments
 (0)