X Tutup
Skip to content

Commit 8e86129

Browse files
committed
remove gist description from single file raw view (cli#2886)
1 parent 7e8348a commit 8e86129

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

pkg/cmd/gist/view/view.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,6 @@ func viewRun(opts *ViewOptions) error {
8989
return err
9090
}
9191

92-
cs := opts.IO.ColorScheme()
93-
if gist.Description != "" {
94-
fmt.Fprintf(opts.IO.Out, "%s\n", cs.Bold(gist.Description))
95-
}
96-
9792
if opts.Filename != "" {
9893
gistFile, ok := gist.Files[opts.Filename]
9994
if !ok {
@@ -107,6 +102,11 @@ func viewRun(opts *ViewOptions) error {
107102

108103
showFilenames := len(gist.Files) > 1
109104

105+
cs := opts.IO.ColorScheme()
106+
if gist.Description != "" && showFilenames {
107+
fmt.Fprintf(opts.IO.Out, "%s\n", cs.Bold(gist.Description))
108+
}
109+
110110
outs := []string{} // to ensure consistent ordering
111111

112112
for filename, gistFile := range gist.Files {

pkg/cmd/gist/view/view_test.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,27 @@ func Test_viewRun(t *testing.T) {
131131
},
132132
wantOut: "bwhiizzzbwhuiiizzzz\n\n",
133133
},
134+
{
135+
name: "filename selected, raw",
136+
opts: &ViewOptions{
137+
Selector: "1234",
138+
Filename: "cicada.txt",
139+
Raw: true,
140+
},
141+
gist: &shared.Gist{
142+
Files: map[string]*shared.GistFile{
143+
"cicada.txt": {
144+
Content: "bwhiizzzbwhuiiizzzz",
145+
Type: "text/plain",
146+
},
147+
"foo.md": {
148+
Content: "# foo",
149+
Type: "application/markdown",
150+
},
151+
},
152+
},
153+
wantOut: "bwhiizzzbwhuiiizzzz\n\n",
154+
},
134155
{
135156
name: "multiple files, no description",
136157
opts: &ViewOptions{
@@ -171,7 +192,7 @@ func Test_viewRun(t *testing.T) {
171192
wantOut: "some files\ncicada.txt\n\nbwhiizzzbwhuiiizzzz\n\nfoo.md\n\n\n \n • foo \n\n\n\n",
172193
},
173194
{
174-
name: "raw",
195+
name: "multiple files, raw",
175196
opts: &ViewOptions{
176197
Selector: "1234",
177198
Raw: true,

0 commit comments

Comments
 (0)
X Tutup