.gitbay/wiki/Users.org

3e75710732680bc79357080d72a716a869571646
gitbay/.gitbay/wiki/Users.org rendered · source · history · blame · raw

497 lines · 21538 bytes

  1#+title: gitbay user guide
  2
  3Everything here works from stock OpenSSH — replace =gitbay= with
  4=ssh git@<host>= in any command and it behaves identically. The CLI adds
  5convenience (instance profiles, repo inference, =$EDITOR=), nothing more.
  6=ssh git@<host> help= lists every command the server knows.
  7
  8* Installing the CLI
  9
 10#+begin_src sh
 11go install gitbay.org/gitbay/cmd/gitbay@latest   # any platform with Go
 12
 13brew tap krz/tap https://gitbay.org/krz/homebrew-tap.git
 14brew install krz/tap/gitbay                      # Homebrew (macOS/Linux)
 15#+end_src
 16
 17Or build from source: =go build ./cmd/gitbay= in a clone of
 18=https://gitbay.org/krz/gitbay.git=.
 19
 20* Getting an account
 21
 22How you join depends on the instance's registration mode. On instances
 23with web accounts enabled, =/register= offers the same signup as a
 24browser form (paste your SSH public key); everything below works from
 25the terminal alone:
 26
 27- closed :: an admin creates your account on the host and registers your
 28  first SSH key. Nothing for you to do but hand over your public key.
 29- invite :: you receive a single-use code by email. With the SSH key you
 30  want to use:
 31  #+begin_src sh
 32  ssh git@<host> register --username you --invite <code>
 33  #+end_src
 34  Your account is active immediately; the invited address is your
 35  verified email.
 36- open ::
 37  #+begin_src sh
 38  ssh git@<host> register --username you --email you@example.org
 39  #+end_src
 40  A verification code arrives by mail. Until you run
 41  =ssh git@<host> email verify <code>=, the account is pending: you can
 42  run =whoami= and the email commands, and nothing else — no git, no
 43  repos.
 44
 45* SSH keys
 46
 47Your key is your identity; there are no passwords anywhere. The SSH
 48username is always =git= — the key alone determines who you are.
 49
 50#+begin_src sh
 51gitbay auth keys list
 52gitbay auth keys add --scope git < ~/.ssh/ci_key.pub   # key on stdin
 53gitbay auth keys remove SHA256:...
 54#+end_src
 55
 56Scopes: =full= (default; git plus every control command), =git= (git
 57transport only — right for automation keys, which then cannot touch
 58issues, settings, or your account), or =runner= (the CI runner's
 59protocol plus read-only git, for the key a =gitbay-runner= host holds;
 60see [[Admin]]).
 61
 62A key belongs to exactly one account instance-wide. Registering a key
 63someone else already holds is refused without telling you whose it is.
 64
 65* Verified commits
 66
 67The commit badge is driven by the *author* email and the signing key:
 68=verified= means the signature is valid, the key is registered to an
 69account, and the author email is a verified address on that account.
 70
 71For OpenPGP signing (git's default):
 72#+begin_src sh
 73gpg --armor --export you@example.org | gitbay auth pgp add
 74#+end_src
 75
 76For SSH signing (=git config gpg.format ssh=): sign with any key
 77registered on your account; your verified addresses act as the principal
 78set. No separate registration step.
 79
 80Add and verify additional addresses with =email add <address>= /
 81=email verify <code>= (requires the instance to have SMTP; otherwise an
 82admin can assert an address for you).
 83
 84The states you will see, in decreasing order of trust: =verified=,
 85=signed_unknown_key= (valid signature, key not registered here — register
 86it and history upgrades retroactively), =signed_email_mismatch= (real
 87key, author line claims someone else), =signed_key_expired= /
 88=signed_key_revoked=, =bad_signature=, =unsigned=. Server-created commits
 89(web edits, merge commits) are always =unsigned= — the server holds no
 90signing key on principle.
 91
 92=repo bookmark <owner/name>= saves a repository to come back to and
 93=repo unbookmark= drops it; =repo bookmarks= lists yours, each with how
 94many people have bookmarked it. The web has the control on the
 95repository header, the count in the facts bar, and the list at
 96=/bookmarks=. Bookmarks are public and counted; pins are private and
 97drive the rail. Read access is all a bookmark needs.
 98
 99* Profiles
100
101A profile is what =/{owner}= shows: a one-line description, a website, a
102set of links, long-form about text, the repositories you can see, org
103membership, and a year of activity. Users and orgs have the same fields.
104Repository rows carry the listing metadata too — topics, license,
105default branch, last commit — so a client renders a profile listing the
106way =/{owner}= does. The web dispatches this command rather than
107assembling the page itself.
108
109#+begin_src sh
110gitbay profile show               # your own
111gitbay profile show alice
112gitbay profile set --description "builds small tools" --website https://alice.example
113#+end_src
114
115About text is markdown by default, or org-mode. It takes inline text or
116stdin, so it can live in a file you keep:
117
118#+begin_src sh
119gitbay profile set --about "I maintain a few small tools."
120gitbay profile set --file - --about-format org < about.org
121#+end_src
122
123Up to five links, each =label|url= or a bare url, http(s) only. Passing
124=--link= replaces the whole set; a single empty one clears it:
125
126#+begin_src sh
127gitbay profile set --link "Mastodon|https://fosstodon.example/@alice" \
128                   --link https://alice.example/now
129gitbay profile set --link ""      # clear
130#+end_src
131
132Every field follows the same rule as the rest of the CLI: a flag you
133leave out is untouched, and ='' clears the one you name. Org profiles
134work the same way and need org admin:
135
136#+begin_src sh
137gitbay org profile krz --description "software and experiments" --about-format org --file - < krz.org
138gitbay org profile krz            # no flags shows it
139#+end_src
140
141The web renders profiles but has no form for editing one, so the CLI is
142the only interface today. =profile set= is not =SSHOnly=, so the JSON API
143runs it like any other write command.
144
145* Repositories
146
147#+begin_src sh
148gitbay repo create you/project [--private]
149gitbay repo clone you/project
150gitbay repo list
151gitbay repo show you/project
152gitbay repo log you/project --limit 20      # commits with signature states
153gitbay repo fork other/project [--name mine]
154gitbay repo delete you/project --yes
155#+end_src
156
157=repo show= also reports your own state on the repository — =watch=
158(=watching= or =muted=) and =bookmarked= — and =fork_of= when it is a
159fork whose parent you can read, so a client draws a toggle rather than
160two blind buttons. Absent means none.
161
162Pushing is SSH-only. Public repositories are anonymously readable over
163HTTPS (and =git://= where enabled); private repositories exist only over
164SSH and answer "not found" to everyone without access.
165
166Access and settings (owner or =admin= grant):
167#+begin_src sh
168gitbay repo access grant you/project alice write    # read | write | admin
169gitbay repo access revoke you/project alice
170gitbay repo settings protect you/project main       # no force-push, no delete
171gitbay repo settings require-signed you/project on  # every commit must verify
172gitbay repo settings git-daemon you/project on      # expose over git://
173gitbay repo topics add you/project cli forge        # free-form tags, shown on the web
174gitbay repo search forge                            # find repos by name/description/topic
175gitbay repo grep you/project "some string"          # literal git grep over the default branch
176gitbay repo pin you/project                         # pin to your web dashboard
177gitbay repo unpin you/project
178gitbay repo archive you/project                     # read-only: pushes and issue/MR
179gitbay repo unarchive you/project                   #   writes refused, browsing intact
180#+end_src
181
182Import from another forge — git data first, then optionally the GitHub
183issue and PR history (issues keep state/labels/comments; PRs land as
184closed or merged MRs with their discussion; originals are attributed
185inline since foreign authors have no local account; re-running resumes
186where it stopped):
187#+begin_src sh
188gitbay repo import you/mirror --from https://github.com/you/repo.git \
189    [--private] [--token-stdin]        # token on stdin, never in the URL
190gitbay repo import-issues you/mirror --from you/repo --token-stdin
191#+end_src
192
193Moving between gitbay instances (no lock-in): run on the TARGET, with
194your key registered on both sides. Profile, repos with settings,
195issues, MRs, and comments replay with attribution; git data mirrors
196client-side through your own key. Keys never transfer and emails
197arrive unverified — trust is per-instance. Re-running resumes.
198Push-blocking policies (require-signed, protected branches) are
199deferred and printed for you to re-apply after the data lands.
200=gitbay auth export= alone doubles as a user-level backup.
201
202#+begin_src sh
203gitbay migrate --from old-instance.example [--from-port 22]
204#+end_src
205
206Mirroring keeps a foreign remote in sync during a gradual migration
207(repo admin; https remotes; the token is stored server-side for the
208recurring sync and never echoed back):
209
210#+begin_src sh
211gitbay repo mirror add you/project https://github.com/you/project.git \
212    --direction push --token-stdin    # propagate after every local push
213gitbay repo mirror add you/copy https://github.com/them/theirs.git \
214    --direction pull                  # follow upstream; local pushes refused
215gitbay repo mirror list               # sync status and last error, per mirror
216gitbay repo mirror sync / remove <id>
217#+end_src
218
219Markdown and org files render on the web when opened, the way a README
220does on the repository page, with relative links resolved against the
221file's directory; =source= in the file's action bar (or =?view=source=)
222shows the text instead. Other files show the text with highlighting.
223
224* Organizations
225
226Orgs share the owner namespace with users and own repositories at
227=org/repo=. By default members get write on all org repos; org admins
228get repo admin, create repos under the org, and manage membership.
229
230#+begin_src sh
231gitbay org create krz
232gitbay org members add krz alice [--role admin]
233gitbay org show krz
234gitbay org rename krz newname     # clone URLs change
235gitbay org delete krz --yes       # only when it owns no repositories
236#+end_src
237
238Large orgs scope access with teams: set what plain membership implies,
239then grant per-repo roles through named teams (org admins always keep
240admin; the default =write= keeps the simple model):
241
242#+begin_src sh
243gitbay org settings members-role krz none   # write | read | none
244gitbay org team create krz core-devs
245gitbay org team add krz core-devs alice bob # org members only
246gitbay org team grant krz core-devs krz/gitbay write
247gitbay org team show krz core-devs          # members + grants
248gitbay org team revoke / remove / delete ...
249#+end_src
250
251* Issues
252
253Anyone who can read a repository can file and comment. Closing/reopening
254is for the author or anyone with write; labels and assignees need write.
255
256#+begin_src sh
257gitbay issue create --title "it breaks" [--body "..." | --file -]
258gitbay issue list [--state open|closed|all]
259gitbay issue show 4
260gitbay issue comment 4 --message "same here"
261gitbay issue edit 4 --title "better title" [--body|--file -]  # author or write
262gitbay issue close 4 / reopen 4
263gitbay issue label 4 --add bug --remove wontfix
264gitbay issue assign 4 --add alice
265gitbay issue milestone 4 v1.0                 # or "none" to clear
266#+end_src
267
268Inside a clone, the repository is inferred from the =origin= remote —
269that is why no =owner/name= appears above. Anywhere else, pass it as the
270first argument. Long text: =--body= inline, =--file -= from stdin, or
271neither on a terminal and =$EDITOR= opens.
272
273Wikis are companion repositories edited by push — no separate storage,
274no web editor, the same rendering pipeline as READMEs (markdown and
275org). Access mirrors the parent repo (read to view, write to push);
276the companion is created on your first push and follows the repo
277through transfer and delete:
278
279#+begin_src sh
280git clone ssh://git@<host>/you/project.wiki.git
281# add Home.md (or .org), more pages, images; relative links between
282# pages just work on the web at /you/project/wiki
283git push
284#+end_src
285
286Releases anchor notes and binary assets to a pushed tag (write access;
287assets stream over SSH, capped by the instance's =max_asset_bytes=):
288
289#+begin_src sh
290gitbay release create v1.0 --title "First light" [--notes|--file -|$EDITOR]
291gitbay release asset add v1.0 tool-linux-amd64 < dist/tool-linux-amd64
292gitbay release asset get v1.0 tool-linux-amd64 > tool   # or the web download link
293gitbay release list / show v1.0 / delete v1.0 --yes
294#+end_src
295
296The web shows them under the repository's =releases= tab with rendered
297notes, sha256 sums, and download links.
298
299Commit messages act on issues when the commits land on the default
300branch (direct push or MR merge): =closes/fixes/resolves #4= closes the
301issue with a linking comment, and a bare =#4= leaves a reference
302comment. Each issue/commit pair acts once, ever. Same repository only.
303
304Milestones group issues and MRs toward a release (write access to
305manage, attach with =issue milestone= / =mr milestone=; progress shows
306on the web at =/owner/name/milestones=):
307
308#+begin_src sh
309gitbay milestone create v1.0 --description "first release" --due 2027-01-01
310gitbay milestone list [--state open|closed|all]
311gitbay milestone close v1.0 / reopen v1.0
312#+end_src
313
314Issue templates: commit =.gitbay/issue-template.md= (and optional
315=issue-template-<name>.md= variants) to the default branch. =gitbay
316issue create= prefills =$EDITOR= with the default template, the web
317form prefills its textarea, and =gitbay issue templates= lists them.
318
319Lists narrow the same way on every surface: =issue list --label bug
320--assignee bob --author alice --milestone v1= (or =--milestone none=),
321=mr list --author bob --milestone v1=; the web's issue and merge request
322lists take the same names as query parameters, and each active filter
323shows with a link that drops it.
324
325Labels take a colour: =gitbay label set bug --color cf222e=; =label
326list= shows each with its colour and how many issues carry it, and
327=label remove= takes one off every issue. =issue label --add= still
328creates a colourless label on the fly.
329
330* Merge requests
331
332#+begin_src sh
333gitbay mr create --source feature --target main --title "add thing"
334gitbay mr create other/upstream --source you/fork:feature --target main --title "..."
335gitbay mr list / show 4 / diff 4
336gitbay mr checkout 4              # local branch mr/4 from the MR head
337gitbay mr review 4 --approve      # or --request-changes / --comment
338gitbay mr merge 4 [--strategy ff|merge|squash|rebase]
339gitbay mr close 4
340#+end_src
341
342Semantics worth knowing:
343
344- the MR head lives in the *target* repository as
345  =refs/merge-requests/N/head= (fetchable by any reader), so an MR
346  survives deletion of its source branch or fork.
347- force-pushing the source updates the MR and marks existing reviews
348  stale.
349- default strategy: fast-forward when possible, else a merge commit.
350  Squash makes one commit authored by the MR author, committed by the
351  merger. Rebase replays a linear range preserving authors; it refuses
352  ranges containing merge commits, and when fast-forward is possible it
353  *is* one (original commits and signatures land untouched).
354- on =require_signed_commits= branches only fast-forwards of fully
355  verified commits merge; everything server-created is refused with
356  instructions to rebase locally. =gitbay mr rebase <n>= is those
357  instructions: in a clone of the target it replays the source branch
358  onto the target and force-pushes it, then =mr merge <n>= fast-forwards.
359  The replay is local, so the commits carry your signature and not the
360  server's — it holds no key. A branch living in a fork is refused, with
361  the repository to run it in; rebase it there.
362
363Repo admins can gate merges (=repo settings ...=): =require-approvals
364<n>= (fresh, non-author approvals; each reviewer's latest review is
365their stance, and a fresh request-changes blocks), =require-resolved=
366(no open review threads), =require-checks= (all statuses green), and
367=require-codeowners= (an approval from an owner of every owned changed
368file). Owners come from a =CODEOWNERS= file on the target branch, root
369or =.gitbay/=, gitignore-style patterns, last match wins. The toggle is
370the opt-in, so a repository can carry the file as documentation of who
371to ask without it gating merges; with it on and no file on the target
372branch, the merge is refused and says so. It does not wait on
373=require-approvals=.
374
375A merge request whose target is another open merge request's source
376branch is stacked on it: =mr create= says so, =mr show= carries
377=stacked_on= and =stacked=, and merging the lower one retargets the
378upper onto =main= with its reviews kept. See [[Stacked-MRs][Stacked
379merge requests]].
380
381Review threads anchor to diff lines:
382
383#+begin_src sh
384gitbay mr diff-comment 4 --path main.go --line 12 --message "use log here"
385gitbay mr diff-comment 4 --reply 7 --message "done"     # join thread 7
386gitbay mr threads 4                                     # threads with staleness
387gitbay mr resolve 4 7 / unresolve 4 7
388#+end_src
389
390Threads render inline on the MR page. A force-push marks them stale
391(shown under "threads on earlier revisions") rather than guessing new
392anchors; =mr show= reports the unresolved count. Resolving is for the
393thread author, the MR author, or anyone with write.
394
395* CI builds
396
397A =.gitbay/ci.yml= in the repo runs jobs on every branch push:
398
399#+begin_src yaml
400jobs:
401  test:
402    steps:
403      - go test ./...
404#+end_src
405
406Each job becomes a build (=build list=, =build log=, the builds tab on
407the web) and a =ci/<job>= commit status, which =repo settings
408require-checks= can gate merges on. Steps run with =sh -c= on the
409instance's runner, stopping at the first failure; a broken config
410surfaces as a failed =ci/config= status. Environment: =GITBAY_REPO=,
411=GITBAY_SHA=, =GITBAY_REF=, =GITBAY_JOB=, =CI=true=.
412
413Secrets: =repo secret set <owner/name> <NAME>= reads the value from
414stdin (never argv) and injects it into the repo's builds as =$NAME=;
415=repo secret list= shows names only, and the value is never echoed
416back. Anyone with write access can read a secret from inside a build,
417so scope them accordingly.
418
419Schedules: a job with =schedule: "17 11,23 * * *"= (five-field cron,
420server-local time; lists, ranges, and steps supported) runs on its cron
421against the default branch instead of on push. A default-branch push
422registers or updates the schedule. A job with =tags: "v*"= runs when a
423matching tag is pushed — and only then; =schedule= and =tags= are
424mutually exclusive. =build trigger <owner/name> <job>= queues any job
425immediately, and =build cancel <owner/name> <n>= withdraws one, queued
426or running: a running build stops at the runner within seconds and the
427log says who cancelled it. Both need write access.
428
429* Large files (LFS)
430
431Standard Git LFS works over both transports with no setup beyond the
432usual =git lfs track=. SSH remotes authenticate through
433=git-lfs-authenticate= (deploy keys included: ro keys can download, rw
434keys upload); anonymous HTTPS clones of public repositories can fetch
435LFS objects with no credentials. Objects are verified against their
436sha256 on upload and capped at 512MB by default.
437
438* Pages
439
440On instances with =[pages] domain= set, a =pages= branch in any public
441repo is served as a static site: the repo named =pages= at
442=https://<you>.<domain>/=, every other repo at
443=https://<you>.<domain>/<repo>/=. Push HTML to publish; a CI job can
444build and push the branch for automatic deploys. Sites run on a
445separate origin — your scripts work, and the forge's cookies are out of
446reach.
447
448A repo can also serve its pages branch on a domain you own.
449=repo domain add <owner/name> <domain>= claims it and prints a DNS TXT
450challenge (=_gitbay-challenge.<domain>=); create the record, run
451=repo domain verify=, then point the domain's A/AAAA records at the
452instance (DNS-only if the domain sits behind a proxying provider — the
453instance issues its own certificates). Claims are exclusive per
454instance; unverified claims serve nothing and expire after 7 days.
455=repo domain list= reports pending/verified/expired.
456
457* Browser sessions
458
459=gitbay web login= mints a one-time URL; the session it opens lasts
460seven days. =gitbay web sessions list= shows each of yours by a short
461id with its creation and expiry, and =gitbay web sessions revoke <id>=
462or =--all= ends them from the terminal, which is where a lost laptop is
463handled.
464
465* Notifications
466
467When the instance has SMTP configured, activity mails you: someone
468opens an issue or MR on your repository, comments where you are a
469participant (author, commenter, reviewer), reviews, closes, or merges.
470You are never mailed about your own actions, and only verified primary
471addresses receive anything. Delivery retries on relay failure.
472
473* Scripting
474
475Every read command takes =--json= and emits one envelope:
476={"protocol_version": 1, "data": ...}=. stdout is data, stderr is
477messages. Exit codes are stable: 0 ok, 1 failure, 2 usage, 3 not found,
4784 denied, 5 server/protocol error. Nothing ever prompts; destructive
479commands take =--yes=.
480
481For HTTP automation see [[API]].
482
483* CLI setup
484
485#+begin_src sh
486gitbay remote add myforge forge.example.org [--port n] [--user u] --default
487gitbay remote list
488gitbay init [name] [--private]   # git init + repo create + origin, in one step
489#+end_src
490
491Configuration lives at =~/.config/gitbay/config.toml=. The CLI shells
492out to your real =ssh=, so =~/.ssh/config=, the agent, and hardware keys
493all apply. It shares one connection per instance through a control
494socket under =~/.ssh=: the first command in five minutes pays the
495handshake and the rest ride it. =no_multiplex = true= on an instance in
496the config turns that off. Man pages: =gitbay man --dir <dir>=; completions:
497=gitbay completion bash|zsh|fish=.