Skip to content

Commit 1c793f9

Browse files
committed
New upstream version 0.5.0
2 parents a8dc1f2 + 97f4545 commit 1c793f9

17 files changed

+323
-216
lines changed

.github/workflows/ci-test.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: CI Test
2+
3+
on: [push, pull_request, workflow_dispatch]
4+
5+
jobs:
6+
ci-test:
7+
runs-on: ubuntu-latest
8+
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
9+
strategy:
10+
matrix:
11+
go-version: ['1.15.x', '1.16.x', '1.17.x']
12+
env:
13+
GO111MODULE: on # Needed for github.com/google/go-github/v38
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v2
18+
19+
- name: Install Go ${{ matrix.go-version }}
20+
uses: actions/setup-go@v2
21+
with:
22+
go-version: ${{ matrix.go-version }}
23+
24+
- run: diff -u <(echo -n) <(gofmt -d -s .)
25+
26+
- run: go get -t -v ./...
27+
28+
- run: go test -v ./...
29+
30+
- run: go vet ./...
31+
32+
- name: apt install needed Debian packages
33+
run: |
34+
sudo eatmydata apt update
35+
sudo eatmydata apt install git-buildpackage golang-any pristine-tar pandoc
36+
37+
- name: Generate man page from Markdown
38+
run: pandoc -f markdown -t man -s dh-make-golang.md -o dh-make-golang.1
39+
40+
- name: dh-make-golang test run for "gh"
41+
run: |
42+
git config --global user.email "[email protected]"
43+
git config --global user.name "dh-make-golang on GitHub"
44+
mkdir -p _test-run
45+
cd _test-run
46+
~/go/bin/dh-make-golang -type p -pristine-tar -program_package_name gh github.com/cli/cli
47+
48+
- name: Upload dh-make-golang test run as artifact
49+
uses: actions/upload-artifact@v2
50+
with:
51+
name: dh-make-golang_test-run_go${{ matrix.go-version }}
52+
path: _test-run

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
dh-make-golang
22
_build/
3+
*~
4+
*.sw[op]

.travis.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Build Status](https://travis-ci.org/Debian/dh-make-golang.svg?branch=master)](https://travis-ci.org/Debian/dh-make-golang)
1+
![CI Test](https://github.com/anthonyfok/dh-make-golang/actions/workflows/ci-test.yml/badge.svg)
22

33
dh-make-golang is a tool to automatically create Debian packaging for Go
44
packages. Its goal is to automate away as much of the work as possible when

create_salsa_project.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func execCreateSalsaProject(args []string) {
1919
}
2020

2121
if err := fs.Parse(args); err != nil {
22-
log.Fatal(err)
22+
log.Fatalf("parse: %s", err)
2323
}
2424

2525
if fs.NArg() != 1 {
@@ -38,7 +38,7 @@ func execCreateSalsaProject(args []string) {
3838

3939
resp, err := http.Post(u.String(), "", nil)
4040
if err != nil {
41-
log.Fatal(err)
41+
log.Fatalf("http post: %s", err)
4242
}
4343
if got, want := resp.StatusCode, http.StatusOK; got != want {
4444
b, _ := ioutil.ReadAll(resp.Body)

description.go

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

@@ -22,17 +23,17 @@ func reformatForControl(raw string) string {
2223
func getLongDescriptionForGopkg(gopkg string) (string, error) {
2324
owner, repo, err := findGitHubRepo(gopkg)
2425
if err != nil {
25-
return "", err
26+
return "", fmt.Errorf("find github repo: %w", err)
2627
}
2728

2829
rr, _, err := gitHub.Repositories.GetReadme(context.TODO(), owner, repo, nil)
2930
if err != nil {
30-
return "", err
31+
return "", fmt.Errorf("get readme: %w", err)
3132
}
3233

3334
content, err := rr.GetContent()
3435
if err != nil {
35-
return "", err
36+
return "", fmt.Errorf("get content: %w", err)
3637
}
3738

3839
// Supported filename suffixes are from
@@ -55,7 +56,7 @@ func getLongDescriptionForGopkg(gopkg string) (string, error) {
5556
cmd.Stdin = bytes.NewBuffer(output)
5657
out, err := cmd.Output()
5758
if err != nil {
58-
return "", err
59+
return "", fmt.Errorf("fmt: %w", err)
5960
}
6061
return reformatForControl(strings.TrimSpace(string(out))), nil
6162
}

estimate.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ func get(gopath, repo string) error {
3131
cmd := exec.Command("go", "get", "-d", "-t", repo+"/...")
3232
cmd.Stderr = os.Stderr
3333
cmd.Env = append([]string{
34-
fmt.Sprintf("GOPATH=%s", gopath),
34+
"GO111MODULE=off",
35+
"GOPATH=" + gopath,
3536
}, passthroughEnv()...)
3637
return cmd.Run()
3738
}
@@ -49,47 +50,48 @@ func removeVendor(gopath string) (found bool, _ error) {
4950
}
5051
found = true
5152
if err := os.RemoveAll(path); err != nil {
52-
return err
53+
return fmt.Errorf("remove all: %w", err)
5354
}
5455
return filepath.SkipDir
5556
})
56-
return found, err
57+
return found, fmt.Errorf("walk: %w", err)
5758
}
5859

5960
func estimate(importpath string) error {
6061
// construct a separate GOPATH in a temporary directory
6162
gopath, err := ioutil.TempDir("", "dh-make-golang")
6263
if err != nil {
63-
return err
64+
return fmt.Errorf("create temp dir: %w", err)
6465
}
6566
defer os.RemoveAll(gopath)
6667

6768
if err := get(gopath, importpath); err != nil {
68-
return err
69+
return fmt.Errorf("go get: %w", err)
6970
}
7071

7172
found, err := removeVendor(gopath)
7273
if err != nil {
73-
return err
74+
return fmt.Errorf("remove vendor: %w", err)
7475
}
7576

7677
if found {
7778
// Fetch un-vendored dependencies
7879
if err := get(gopath, importpath); err != nil {
79-
return err
80+
return fmt.Errorf("fetch un-vendored: go get: %w", err)
8081
}
8182
}
8283

8384
// Remove standard lib packages
8485
cmd := exec.Command("go", "list", "std")
8586
cmd.Stderr = os.Stderr
8687
cmd.Env = append([]string{
87-
fmt.Sprintf("GOPATH=%s", gopath),
88+
"GO111MODULE=off",
89+
"GOPATH=" + gopath,
8890
}, passthroughEnv()...)
8991

9092
out, err := cmd.Output()
9193
if err != nil {
92-
return fmt.Errorf("%v: %v", cmd.Args, err)
94+
return fmt.Errorf("go list std: args: %v; error: %w", cmd.Args, err)
9395
}
9496
stdlib := make(map[string]bool)
9597
for _, line := range strings.Split(strings.TrimSpace(string(out)), "\n") {
@@ -185,7 +187,7 @@ func execEstimate(args []string) {
185187

186188
err := fs.Parse(args)
187189
if err != nil {
188-
log.Fatal(err)
190+
log.Fatalf("parse args: %s", err)
189191
}
190192

191193
if fs.NArg() != 1 {
@@ -196,6 +198,6 @@ func execEstimate(args []string) {
196198
// TODO: support the -git_revision flag
197199

198200
if err := estimate(fs.Arg(0)); err != nil {
199-
log.Fatal(err)
201+
log.Fatalf("estimate: %s", err)
200202
}
201203
}

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
module github.com/Debian/dh-make-golang
22

3-
go 1.12
3+
go 1.13
44

55
require (
6-
github.com/google/go-github/v32 v32.1.0
6+
github.com/google/go-github/v38 v38.1.0
77
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79
88
github.com/mattn/go-isatty v0.0.10
99
github.com/russross/blackfriday v1.5.2

go.sum

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
2-
github.com/google/go-github/v32 v32.1.0 h1:GWkQOdXqviCPx7Q7Fj+KyPoGm4SwHRh8rheoPhd27II=
3-
github.com/google/go-github/v32 v32.1.0/go.mod h1:rIEpZD9CTDQwDK9GDrtMTycQNA4JU3qBsCizh3q2WCI=
2+
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
3+
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
4+
github.com/google/go-github/v38 v38.1.0 h1:C6h1FkaITcBFK7gAmq4eFzt6gbhEhk7L5z6R3Uva+po=
5+
github.com/google/go-github/v38 v38.1.0/go.mod h1:cStvrz/7nFr0FoENgG6GLbp53WaelXucT+BBz/3VKx4=
46
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
57
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
68
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 h1:+ngKgrYPPJrOjhax5N+uePQ0Fh1Z7PheYoUI/0nzkPA=
@@ -24,4 +26,6 @@ golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7w
2426
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
2527
golang.org/x/tools v0.0.0-20190731163215-a81e99d7481f h1:vwy91pya0J00SsPf35DrwOUOe/76iE4RbegH6XWNn9I=
2628
golang.org/x/tools v0.0.0-20190731163215-a81e99d7481f/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
29+
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
30+
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
2731
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
"os"
66

7-
"github.com/google/go-github/v32/github"
7+
"github.com/google/go-github/v38/github"
88
"github.com/gregjones/httpcache"
99
)
1010

0 commit comments

Comments
 (0)