remove gist description from single file raw view (#2886)

This commit is contained in:
Ruslan Gilyazetdinov 2021-02-01 18:49:26 +03:00
parent 7e8348a68f
commit 8e86129e2e
2 changed files with 27 additions and 6 deletions

View file

@ -89,11 +89,6 @@ func viewRun(opts *ViewOptions) error {
return err
}
cs := opts.IO.ColorScheme()
if gist.Description != "" {
fmt.Fprintf(opts.IO.Out, "%s\n", cs.Bold(gist.Description))
}
if opts.Filename != "" {
gistFile, ok := gist.Files[opts.Filename]
if !ok {
@ -107,6 +102,11 @@ func viewRun(opts *ViewOptions) error {
showFilenames := len(gist.Files) > 1
cs := opts.IO.ColorScheme()
if gist.Description != "" && showFilenames {
fmt.Fprintf(opts.IO.Out, "%s\n", cs.Bold(gist.Description))
}
outs := []string{} // to ensure consistent ordering
for filename, gistFile := range gist.Files {

View file

@ -131,6 +131,27 @@ func Test_viewRun(t *testing.T) {
},
wantOut: "bwhiizzzbwhuiiizzzz\n\n",
},
{
name: "filename selected, raw",
opts: &ViewOptions{
Selector: "1234",
Filename: "cicada.txt",
Raw: true,
},
gist: &shared.Gist{
Files: map[string]*shared.GistFile{
"cicada.txt": {
Content: "bwhiizzzbwhuiiizzzz",
Type: "text/plain",
},
"foo.md": {
Content: "# foo",
Type: "application/markdown",
},
},
},
wantOut: "bwhiizzzbwhuiiizzzz\n\n",
},
{
name: "multiple files, no description",
opts: &ViewOptions{
@ -171,7 +192,7 @@ func Test_viewRun(t *testing.T) {
wantOut: "some files\ncicada.txt\n\nbwhiizzzbwhuiiizzzz\n\nfoo.md\n\n\n \n • foo \n\n\n\n",
},
{
name: "raw",
name: "multiple files, raw",
opts: &ViewOptions{
Selector: "1234",
Raw: true,