v0.7.2 71ebe61

image_test.go RawHistoryFolder

1package image
2
3import (
4	"bytes"
5	"encoding/binary"
6	"hash/crc32"
7	"image"
8	"image/jpeg"
9	"image/png"
10	"testing"
11)
12
13func TestDecode(t *testing.T) {
14	src := image.NewRGBA(image.Rect(3, 4, 5, 7))
15	for _, encode := range []func(*bytes.Buffer) error{
16		func(b *bytes.Buffer) error { return png.Encode(b, src) },
17		func(b *bytes.Buffer) error { return jpeg.Encode(b, src, nil) },
18	} {
19		var b bytes.Buffer
20		if err := encode(&b); err != nil {
21			t.Fatal(err)
22		}
23		out, err := Decode(b.Bytes())
24		if err != nil {
25			t.Fatal(err)
26		}
27		w, h, err := Size(out)
28		if err != nil || w != 2 || h != 3 {
29			t.Fatalf("%d %d %v", w, h, err)
30		}
31	}
32	if _, err := Decode([]byte("bad")); err == nil {
33		t.Fatal("invalid accepted")
34	}
35	var b bytes.Buffer
36	if err := png.Encode(&b, image.NewRGBA(image.Rect(0, 0, 1, 1))); err != nil {
37		t.Fatal(err)
38	}
39	data := b.Bytes()
40	binary.BigEndian.PutUint32(data[16:], 100000)
41	binary.BigEndian.PutUint32(data[20:], 100000)
42	binary.BigEndian.PutUint32(data[29:], crc32.ChecksumIEEE(data[12:29]))
43	if _, err := Decode(data); err != ErrSize {
44		t.Fatalf("size: %v", err)
45	}
46}

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 12

↑↓ moveenter openesc close