v0.2.27 9b298e6

gitignore_test.go RawHistoryFolder

1package ignore
2
3import "testing"
4
5func TestParseAndMatch(t *testing.T) {
6	g := Parse(lines("# comment", "", ".terraform/", ".terragrunt-cache/", "node_modules/", "*.log", "/build", "!keep.log"))
7
8	cases := []struct {
9		rel   string
10		isDir bool
11		want  bool
12	}{
13		{".terraform", true, true},
14		// A dirOnly rule matches the directory itself; the walk prunes
15		// descent on that match, so children are never tested. A file
16		// path under it is therefore not matched directly by the rule.
17		{".terraform/providers/x", false, false},
18		{".terragrunt-cache", true, true},
19		{"modules/.terragrunt-cache", true, true},
20		{"node_modules", true, true},
21		{"src/node_modules/pkg", true, true},
22		{"debug.log", false, true},
23		{"keep.log", false, false}, // re-included by negation
24		{"build", true, true},      // anchored
25		{"sub/build", true, false}, // anchored: only at root
26		{"main.tf", false, false},
27		{"src/app.go", false, false},
28	}
29	for _, c := range cases {
30		if got := g.Match(c.rel, c.isDir); got != c.want {
31			t.Errorf("Match(%q, dir=%v) = %v, want %v", c.rel, c.isDir, got, c.want)
32		}
33	}
34}
35
36func TestEmptyIgnoresNothing(t *testing.T) {
37	g := Parse("")
38	if g.Match("anything", false) || g.Match("dir", true) {
39		t.Fatal("empty matcher should ignore nothing")
40	}
41}
42
43// lines joins fixture lines with newlines for readable .gitignore
44// fixtures.
45func lines(ls ...string) string {
46	out := ""
47	for i, l := range ls {
48		if i > 0 {
49			out += "\n"
50		}
51		out += l
52	}
53	return out
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 1

Tags 476

↑↓ moveenter openesc close