v0.1.0 28f9d6e

skip.go RawHistoryFolder

1// SPDX-License-Identifier: MIT
2
3package workflow
4
5import "strings"
6
7var skipMarkers = []string{"[skip ci]", "[ci skip]", "[no ci]", "[skip actions]", "[actions skip]"}
8
9// SkipCI reports whether the message of the head commit of a push (or of the
10// commit a tag points at) tells GitHub not to run workflows for it. As
11// recorded on github.com (scenarios skip-directives, skip-directives-placement,
12// skip-checks-trailer and skip-directive-tag):
13//
14//   - the markers [skip ci], [ci skip], [no ci], [skip actions] and
15//     [actions skip] skip anywhere in the subject or the body, and are
16//     case-sensitive: [SKIP CI] and [Skip Ci] do not skip. Near misses do
17//     not skip either: [skip-ci], "skip ci" without brackets, [skip ci please]
18//     and the markers ***NO_CI*** and ***SKIP_CI***;
19//   - the trailer "skip-checks: true" skips only as the end of the message,
20//     preceded by two blank lines ("x\n\n\nskip-checks: true"). The space
21//     after the colon is optional and trailing white space is ignored. It does
22//     not skip with one blank line or none, with text after it, after another
23//     trailer, with another value ("false", "yes"), or with any change of case
24//     in the key or the value.
25//
26// Not recorded, so assumed: only the head commit of a push is looked at (the
27// scenarios push one commit at a time); more than two blank lines before the
28// trailer count like two; a line holding only spaces or tabs is not blank
29// (the two lines before the trailer must be empty); trailing blank lines and
30// CRLF line ends are ignored; more than one space after the colon is not
31// accepted; and a message made of the trailer alone does not skip.
32func SkipCI(headCommitMessage string) bool {
33	for _, m := range skipMarkers {
34		if strings.Contains(headCommitMessage, m) {
35			return true
36		}
37	}
38	return hasSkipChecksTrailer(headCommitMessage)
39}
40
41// hasSkipChecksTrailer reports whether the message ends with a
42// "skip-checks: true" line preceded by two empty lines and some text.
43func hasSkipChecksTrailer(msg string) bool {
44	msg = strings.ReplaceAll(msg, "\r\n", "\n")
45	msg = strings.TrimRight(msg, " \t\n")
46	lines := strings.Split(msg, "\n")
47	n := len(lines)
48	if n < 4 {
49		return false
50	}
51	val, ok := strings.CutPrefix(lines[n-1], "skip-checks:")
52	if !ok || strings.TrimPrefix(val, " ") != "true" {
53		return false
54	}
55	return lines[n-2] == "" && lines[n-3] == "" && strings.TrimSpace(strings.Join(lines[:n-3], "")) != ""
56}

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 3

↑↓ moveenter openesc close