Skip to content

Commit 36d205d

Browse files
committed
Fix missing long description for non-GitHub import path
when "go-source" meta tag actually resolves to GitHub.
1 parent 8c30050 commit 36d205d

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

description.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package main
33
import (
44
"bytes"
55
"context"
6-
"fmt"
76
"os/exec"
87
"strings"
98

@@ -18,15 +17,13 @@ func reformatForControl(raw string) string {
1817
return strings.Replace(raw, "\n", "\n ", -1)
1918
}
2019

20+
// getDescriptionForGopkg reads from README.md (or equivalent) from GitHub,
21+
// intended for the extended description in debian/control.
2122
func getLongDescriptionForGopkg(gopkg string) (string, error) {
22-
if !strings.HasPrefix(gopkg, "github.com/") {
23-
return "", nil
24-
}
25-
parts := strings.Split(strings.TrimPrefix(gopkg, "github.com/"), "/")
26-
if got, want := len(parts), 2; got != want {
27-
return "", fmt.Errorf("invalid GitHub repo: %q does not follow github.com/owner/repo", gopkg)
23+
owner, repo, err := findGitHubRepo(gopkg)
24+
if err != nil {
25+
return "", err
2826
}
29-
owner, repo := parts[0], parts[1]
3027

3128
rr, _, err := gitHub.Repositories.GetReadme(context.TODO(), owner, repo, nil)
3229
if err != nil {

metadata.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ func getAuthorAndCopyrightForGopkg(gopkg string) (string, string, error) {
173173
return ur.GetName(), copyright, nil
174174
}
175175

176+
// getDescriptionForGopkg gets the package description from GitHub,
177+
// intended for the synopsis or the short description in debian/control.
176178
func getDescriptionForGopkg(gopkg string) (string, error) {
177179
owner, repo, err := findGitHubRepo(gopkg)
178180
if err != nil {

template.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ func addDescription(f *os.File, gopkg, comment string) {
9090
description = "TODO: short description"
9191
}
9292
fmt.Fprintf(f, "Description: %s %s\n", description, comment)
93+
9394
longdescription, err := getLongDescriptionForGopkg(gopkg)
9495
if err != nil {
9596
log.Printf("Could not determine long description for %q: %v\n", gopkg, err)

0 commit comments

Comments
 (0)