5func TestInspect(t *testing.T) {
14 name: "git unified diff",
15 content: `diff --git a/main.go b/main.go
22 want: Signal{HasHunk: true, HasFileHeader: true, HasGitHeader: true},
25 name: "non-git unified diff",
32 want: Signal{HasHunk: true, HasFileHeader: true, HasGitHeader: false},
36 content: "hello world",
41 content: "@@ -1 +1 @@\n-old\n+new\n",
42 want: Signal{HasHunk: true},
46 content: "--- a/file\n+++ b/file\n",
47 want: Signal{HasFileHeader: true},
51 for _, tt := range tests {
52 t.Run(tt.name, func(t *testing.T) {
54 got := Inspect(tt.content)
56 t.Errorf("Inspect() = %+v, want %+v", got, tt.want)
62func TestIsUnifiedDiff(t *testing.T) {
71 name: "github-style multi-file diff",
72 content: `diff --git a/one.txt b/one.txt
78diff --git a/two.txt b/two.txt
88 name: "non-git unified patch",
94+int main(int argc, char **argv) {
101 name: "new file from dev null",
102 content: `--- /dev/null
111 name: "markdown false positive candidate",
120 name: "headers without hunk",
121 content: `--- a/somefile.txt
123Just some content here
124No hunk markers at all
129 name: "hunk without headers",
130 content: `@@ -1,3 +1,4 @@
144 for _, tt := range tests {
145 t.Run(tt.name, func(t *testing.T) {
147 if got := IsUnifiedDiff(tt.content); got != tt.want {
148 t.Errorf("IsUnifiedDiff() = %v, want %v", got, tt.want)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list