detached 27e453c

issue.go RawHistoryFolder

1// SPDX-License-Identifier: AGPL-3.0-or-later
2
3package domain
4
5import (
6	"fmt"
7	"time"
8)
9
10// IssuesMode says who may write issues in a repository.
11type IssuesMode string
12
13// Issues modes.
14const (
15	// IssuesOff turns issues off: the default.
16	IssuesOff IssuesMode = "off"
17	// IssuesOwner lets the owner and tokens with ScopeIssueWrite write issues.
18	IssuesOwner IssuesMode = "owner"
19	// IssuesPublic also opens the repository to submissions from anyone.
20	IssuesPublic IssuesMode = "public"
21)
22
23// IssuesModes returns the three modes in their canonical order.
24func IssuesModes() []IssuesMode { return []IssuesMode{IssuesOff, IssuesOwner, IssuesPublic} }
25
26// ParseIssuesMode parses "off", "owner" or "public".
27func ParseIssuesMode(s string) (IssuesMode, error) {
28	for _, m := range IssuesModes() {
29		if string(m) == s {
30			return m, nil
31		}
32	}
33	return "", fmt.Errorf("%w: issues mode %q (want off, owner or public)", ErrInvalid, s)
34}
35
36// String returns the mode as text.
37func (m IssuesMode) String() string { return string(m) }
38
39// OrDefault returns IssuesOff for the empty mode, else m.
40func (m IssuesMode) OrDefault() IssuesMode {
41	if m == "" {
42		return IssuesOff
43	}
44	return m
45}
46
47// IssueState is where an issue is in its life.
48type IssueState string
49
50// Issue states.
51const (
52	// IssueStateOpen is being worked on.
53	IssueStateOpen IssueState = "open"
54	// IssueStateClosed is done with; it can be reopened.
55	IssueStateClosed IssueState = "closed"
56)
57
58// Issue is a problem or a request about a repository. It shares its number
59// sequence with the merge requests of the repository.
60type Issue struct {
61	Repo   RepoName
62	Number int64
63	Title  IssueTitle
64	// Body may be empty.
65	Body  IssueBody
66	State IssueState
67	// Author is the label of the token that opened it, "root" or "owner".
68	Author    string
69	CreatedAt time.Time
70	UpdatedAt time.Time
71	// CommentSeq is the id of the last comment of the issue.
72	CommentSeq int64
73	// External is true for an issue approved from the public form: its text
74	// comes from an anonymous visitor and is rendered as untrusted.
75	External bool
76	// Version is set by the store on read: Update fails with ErrConflict when
77	// the stored issue changed since. Opaque to everyone else.
78	Version uint64
79}
80
81// IsOpen reports whether the issue is open.
82func (i Issue) IsOpen() bool { return i.State == IssueStateOpen }
83
84// IssueComment is a comment on an issue.
85type IssueComment struct {
86	ID        int64
87	Author    string
88	Text      IssueBody
89	CreatedAt time.Time
90	// Version is set by the store on read, like Issue's.
91	Version uint64
92}
93
94// NumberKind says what a number of a repository names. Issues and merge
95// requests share one sequence, so a number names at most one of them.
96type NumberKind int
97
98// Number kinds.
99const (
100	// NumberNone: no issue or merge request has this number.
101	NumberNone NumberKind = iota
102	// NumberIssue: the number names an issue.
103	NumberIssue
104	// NumberMergeRequest: the number names a merge request.
105	NumberMergeRequest
106)

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 4

Tags 45

↑↓ moveenter openesc close