main de06cbd

types.go RawHistoryFolder

1// SPDX-License-Identifier: MIT
2
3package git
4
5import "strconv"
6
7// Type is the type of a Git object. The values are those of pack entries.
8type Type uint8
9
10// Object types.
11const (
12	TypeCommit Type = 1
13	TypeTree   Type = 2
14	TypeBlob   Type = 3
15	TypeTag    Type = 4
16)
17
18// String returns the name Git uses for the type ("commit", "tree", "blob",
19// "tag").
20func (t Type) String() string {
21	switch t {
22	case TypeCommit:
23		return "commit"
24	case TypeTree:
25		return "tree"
26	case TypeBlob:
27		return "blob"
28	case TypeTag:
29		return "tag"
30	}
31	return "type(" + strconv.Itoa(int(t)) + ")"
32}
33
34func parseTypeName(b []byte) (Type, bool) {
35	switch string(b) {
36	case "commit":
37		return TypeCommit, true
38	case "tree":
39		return TypeTree, true
40	case "blob":
41		return TypeBlob, true
42	case "tag":
43		return TypeTag, true
44	}
45	return 0, false
46}
47
48// Mode is the file mode of a tree entry.
49type Mode uint32
50
51// Tree entry modes.
52const (
53	ModeTree    Mode = 0o040000
54	ModeFile    Mode = 0o100644
55	ModeExec    Mode = 0o100755
56	ModeSymlink Mode = 0o120000
57	ModeGitlink Mode = 0o160000 // a submodule
58)
59
60const modeTypeMask Mode = 0o170000
61
62// IsTree reports whether the entry is a directory.
63func (m Mode) IsTree() bool { return m&modeTypeMask == ModeTree }
64
65// IsGitlink reports whether the entry is a submodule commit.
66func (m Mode) IsGitlink() bool { return m&modeTypeMask == ModeGitlink }
67
68// IsSymlink reports whether the entry is a symbolic link.
69func (m Mode) IsSymlink() bool { return m&modeTypeMask == ModeSymlink }
70
71// IsRegular reports whether the entry is a regular file, executable or not.
72func (m Mode) IsRegular() bool { return m&modeTypeMask == 0o100000 }
73
74// Type returns the type of the object the entry designates: a tree for a
75// directory, a commit for a submodule, a blob otherwise.
76func (m Mode) Type() Type {
77	switch m & modeTypeMask {
78	case ModeTree:
79		return TypeTree
80	case ModeGitlink:
81		return TypeCommit
82	}
83	return TypeBlob
84}
85
86// String returns the mode as Git prints it: six octal digits (five for a
87// directory is printed as "040000").
88func (m Mode) String() string {
89	s := strconv.FormatUint(uint64(m), 8)
90	for len(s) < 6 {
91		s = "0" + s
92	}
93	return s
94}

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 1

Tags 2

↑↓ moveenter openesc close