git / README.mdmain at 517348b
# git
The mind's repos at `git.<domain>`: a git remote, and pages to read a repo and to propose a
change to it in a browser. `config/worker.ts` mounts it and says which repos anyone may read.
```
git clone https://git.<domain>/repos/<name>
/ the repos
/repos/<name> the repo's files and its README
/repos/<name>/tree/main/<path> a folder, or a file
/repos/<name>/edit/main/<path> a file in a box, for a member to change and commit
/repos/<name>/commits the newest commits
/repos/<name>/commit/<oid> one commit: what it changed
/repos/<name>/branches the branches, each with its pull or a compare link
/repos/<name>/releases the releases: each a tag of git, with its notes
/repos/<name>/compare/<branch> a branch against main, and "Open a pull"
/repos/<name>/pulls the pulls
/repos/<name>/pull/<number> one pull: its conversation and what it changes
```
## Git on your computer
A public repo is cloned with no sign-in. Any other repo, and every push, is for a member of the
mind. Set git up once on a computer (it needs Node 22 or newer):
```sh
npx iterate git setup git.<domain>
```
It signs you in to the mind if this computer is not signed in (in a browser here, or with a link
and a code for a browser on another device), and sets git's credential helper for this one host.
After that, plain `git clone`, `git pull` and `git push` work, and nothing asks for a password.
- A git that was never set up gets "there is no repo here that you can read" with that command,
for a repo that is not public and for a repo that does not exist alike.
- When the sign-in has ended (it ends after seven days without use, or when a member ends it on
the mind's `/sessions` page), git says so and names the same command. With a person at the
terminal, git signs in again by itself and then goes on.
- Git gets a token that is for this host alone and lasts an hour at most. No Artifacts token
leaves the mind: the app adds its own on the way to Artifacts.
- In a sandbox of the mind the same command signs nobody in: git's helper there asks the mind
for a token for the one repo, through the sandbox's own session, and this app passes it on.
So does an agent that sends an Artifacts token of its own (`itx.cfArtifacts`).
- Who pushed which refs is on the repo's log: `git/pushed { by, refs }`.
## Propose a change
```sh
git checkout -b my-fix
git commit ...
git push origin my-fix
```
Then find the branch under Branches, compare it with main, and press "Open a pull". A push to a branch that is not
`main` changes nothing that runs.
A pull is squashed into main as one commit, named `<title> (#7)` with the pull's body under it.
The button is there while the branch has main's newest commit. When main has moved:
```sh
git merge origin/main
git push origin my-fix
```
## Edit a file in the browser
A member's page of a file has a pencil. It opens `/repos/<name>/edit/main/<path>`: the file's
text in a box, a commit message to change, and the choice of where the commit goes.
- **Commit directly to main**: one call of the member's own `itx`
(`repos.get(repo).commitFiles`), pinned to the commit that the page read. Main is what the mind
runs a few seconds later.
- **Create a new branch and open a pull**: the page itself makes the commit and pushes the branch
as git does (`public/branch-commit.js`: the mind's repo API commits to main alone), then opens
the pull.
The server has no write path for either: the first is the platform's, the second is the same
push that a member's git makes, and the repo's log says who pushed. A push from a page is taken
from this app's own page alone.
A repo's pulls are events on the repo's own context: `pulls.ts` says which. An agent opens a pull
or comments by appending the same events, and merges with `itx.config.pullMerge(repo, number)`.
## Releases
A release is an annotated tag of git on a commit of main, named `v1.2.7`. Take a version, and not
every commit:
```sh
git ls-remote --tags https://git.<domain>/repos/<name>
git clone --branch v1.2.7 https://git.<domain>/repos/<name>
```
An agent cuts one with `itx.config.releaseCut(repo)`: the next version raises the patch, the notes
are main's commits since the release before, and nothing is cut when main has nothing new.
`releases.ts` says the rest. A tag is never moved.
## The files
- `app.ts`: who may do what, and the git remote
- `pages.ts`: each page, as plain HTML
- `pulls.ts`: what a pull is, and the merge
- `releases.ts`: what a release is, and the cut
- `public/`: what the browser runs. There is no build.
- `public/branch-commit.js`: the commit on a new branch that a member's page makes of an edit
## Try a change
```sh
node tests/serve.mjs # the app over copies of the repos cloned beside this one
node --test "tests/*.test.mjs"
```
A push to `main` is live a few seconds later.