v0.34.0 7c1886f

revision.go RawHistoryFolder

1// SPDX-License-Identifier: AGPL-3.0-or-later
2
3package domain
4
5import "strings"
6
7// RevisionCandidateKind identifies the lookup needed to resolve a revision.
8type RevisionCandidateKind uint8
9
10const (
11	RevisionCandidateHead RevisionCandidateKind = iota
12	RevisionCandidateObject
13	RevisionCandidateRef
14	RevisionCandidateAbbrevID
15)
16
17// RevisionCandidate is one lookup to try when resolving a revision.
18// Name is HEAD, an object id, a full ref name, or an abbreviated object id.
19type RevisionCandidate struct {
20	Kind RevisionCandidateKind
21	Name string
22}
23
24// Candidates returns the resolution order. HEAD is special; full object ids
25// are objects before refs, so a ref cannot redirect an existing object link.
26// Otherwise branches beat tags. Full ref names and abbreviated ids are tried
27// as written only after the branch and tag forms.
28func (r Revision) Candidates() []RevisionCandidate {
29	s := r.String()
30	if r.IsHead() || s == "HEAD" {
31		return []RevisionCandidate{{Kind: RevisionCandidateHead, Name: "HEAD"}}
32	}
33	refs := []RevisionCandidate{
34		{Kind: RevisionCandidateRef, Name: "refs/heads/" + s},
35		{Kind: RevisionCandidateRef, Name: "refs/tags/" + s},
36	}
37	switch {
38	case r.IsObjectID():
39		return append([]RevisionCandidate{{Kind: RevisionCandidateObject, Name: s}}, refs...)
40	case strings.HasPrefix(s, "refs/"):
41		return append(refs, RevisionCandidate{Kind: RevisionCandidateRef, Name: s})
42	case r.IsAbbrevID():
43		return append(refs, RevisionCandidate{Kind: RevisionCandidateAbbrevID, Name: s})
44	}
45	return refs
46}
47
48// ResolvedRef returns the full ref name for a ref candidate, or empty otherwise.
49func (c RevisionCandidate) ResolvedRef() string {
50	if c.Kind == RevisionCandidateRef {
51		return c.Name
52	}
53	return ""
54}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 3

Tags 43

↑↓ moveenter openesc close