2024-03-05 11:57:59 +00:00
NIP-34
======
`git` stuff
-----------
`draft` `optional`
This NIP defines all the ways code collaboration using and adjacent to [`git` ](https://git-scm.com/ ) can be done using Nostr.
## Repository announcements
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.
```jsonc
{
"kind": 30617,
"content": "",
"tags": [
2024-03-07 08:03:48 +00:00
["d", "< repo-id > "], // usually kebab-case short name
2024-03-05 11:57:59 +00:00
["name", "< human-readable project name > "],
["description", "brief human-readable project description>"],
["web", "< url for browsing > ", ...], // a webpage url, if the git server being used provides such a thing
["clone", "< url for git-cloning > ", ...], // a url to be given to `git clone` so anyone can clone it
["relays", "< relay-url > ", ...] // relays that this repository will monitor for patches and issues
2024-03-07 09:01:19 +00:00
["earliest-unique-commit", "< commit-id > "] // usually root commit but a recent commit for forks
["r", "< earliest-unique-commit-id > "] // so clients can subscribe to all events related to a local git repo
2024-03-07 08:25:49 +00:00
["maintainers", "< other-recognized-maintainer > ", ...]
2024-03-05 11:57:59 +00:00
]
}
```
2024-03-07 08:25:49 +00:00
The tags `web` , `clone` , `relays` , `maintainers` can have multiple values.
2024-03-05 11:57:59 +00:00
Except `d` , all tags are optional.
## Patches
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.
2024-03-07 07:59:16 +00:00
Patches in a patch set SHOULD include a NIP-10 `e` `reply` tag pointing to the previous patch.
The first patch revision in a patch revision SHOULD include a NIP-10 `e` `reply` to the original root patch.
2024-03-05 11:57:59 +00:00
```jsonc
{
"kind": 1617,
"content": "< patch > ", // contents of < git format-patch >
"tags": [
["a", "30617:< base-repo-owner-pubkey > :< base-repo-id > "],
2024-03-07 09:01:19 +00:00
["r", "< earliest-unique-commit-id-of-repo > "] // so clients can subscribe to all patches sent to a local git repo
2024-03-05 11:57:59 +00:00
["p", "< repository-owner > "],
["p", "< other-user > "], // optionally send the patch to another user to bring it to their attention
2024-03-07 09:01:19 +00:00
["t", "root"], // ommited for additional patches in a series
// for the first patch in a revision
["t", "root-revision"],
2024-03-05 11:57:59 +00:00
// optional tags for when it is desirable that the merged patch has a stable commit id
// these fields are necessary for ensuring that the commit resulting from applying a patch
// has the same id as it had in the proposer's machine -- all these tags can be omitted
// if the maintainer doesn't care about these things
["commit", "< current-commit-id > "],
2024-03-07 09:01:19 +00:00
["r", "< current-commit-id > "] // so clients can find existing patches for a specific commit
2024-03-05 11:57:59 +00:00
["parent-commit", "< parent-commit-id > "],
["commit-pgp-sig", "-----BEGIN PGP SIGNATURE-----..."], // empty string for unsigned commit
["committer", "< name > ", "< email > ", "< timestamp > ", "< timezone offset in minutes > "],
]
}
```
2024-03-07 09:20:25 +00:00
The first patch in a series MAY be a cover letter in the format produced by `git format-patch` .
2024-03-05 11:57:59 +00:00
## Issues
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.
```jsonc
{
"kind": 1621,
"content": "< markdown text > ",
"tags": [
["a", "30617:< base-repo-owner-pubkey > :< base-repo-id > "],
["p", "< repository-owner > "]
]
}
```
## Replies
Replies are also Markdown text. The difference is that they MUST be issued as replies to either a `kind:1621` _issue_ or a `kind:1617` _patch_ event. The threading of replies and patches should follow NIP-10 rules.
```jsonc
{
"kind": 1622,
"content": "< markdown text > ",
"tags": [
["a", "30617:< base-repo-owner-pubkey > :< base-repo-id > ", "< relay-url > "],
["e", "< issue-or-patch-id-hex > ", "", "root"],
// other "e" and "p" tags should be applied here when necessary, following the threading rules of NIP-10
["p", "< patch-author-pubkey-hex > ", "", "mention"],
["e", "< previous-reply-id-hex > ", "", "reply"],
// ...
]
}
```
2024-03-07 10:21:06 +00:00
## Status
Root Patches and Issues have a Status that defaults to 'Open' and can be set by issuing Status events.
```jsonc
{
"kind": 1630, // Open
"kind": 1631, // Applied / Merged for Patches; Resolved for Issues
"kind": 1632, // Closed
"kind": 1633, // Draft
"content": "< markdown text > ",
"tags": [
["e", "< issue-or-original-root-patch-id-hex > ", "", "root"],
["e", "< accepted-revision-root-id-hex > ", "", "reply"], // for when revisions applied
["p", "< repository-owner > "],
["p", "< root-event-author > "],
["p", "< revision-author > "],
// optional for improved subscription filter efficency
["a", "30617:< base-repo-owner-pubkey > :< base-repo-id > ", "< relay-url > "],
["r", "< earliest-unique-commit-id-of-repo > "]
// optional for `1631` status
["e", "< applied-or-merged-patch-event-id > ", "", "mention"], // for each
// when merged
["merge-commit", "< merge-commit-id > "]
["r", "< merge-commit-id > "]
// when applied
["applied-as-commits", "< commit-id-in-master-branch > ", ...]
["r", "< applied-commit-id > "] // for each
]
}
```
The Status event with the largest created_at date is valid.
The Status of a patch-revision defaults to either that of the root-patch, or `1632` (Closed) if the root-patch's Status is `1631` and the patch-revision isn't tagged in the `1631` event.
2024-03-05 11:57:59 +00:00
## Possible things to be added later
- "branch merge" kind (specifying a URL from where to fetch the branch to be merged)
- inline file comments kind (we probably need one for patches and a different one for merged files)