Skip to content

Commit

Permalink
chore: fix lint warnings and snapshot third_party/licenses.csv
Browse files Browse the repository at this point in the history
  • Loading branch information
Bobgy committed Jan 5, 2022
1 parent d7080ac commit d5b7edc
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 34 deletions.
27 changes: 27 additions & 0 deletions v2/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2021 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

precommit: FORCE tidy lint csv

csv: FORCE
go run . csv github.com/google/go-licenses/v2 | tee third_party/licenses.csv

lint: FORCE
# There's no need to lint third_party packages, so we explicitly list other packages here.
golint --set_exit_status . gocli/... tests/... licenses/...

tidy: FORCE
go mod tidy

FORCE: ;
21 changes: 6 additions & 15 deletions v2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,12 @@ module github.com/google/go-licenses/v2
go 1.15

require (
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6 // indirect
github.com/coreos/etcd v3.3.10+incompatible // indirect
github.com/coreos/go-etcd v2.0.0+incompatible // indirect
github.com/cpuguy83/go-md2man v1.0.10 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/golang/glog v1.0.0 // indirect
github.com/google/licenseclassifier v0.0.0-20210722185704-3043a050f148 // indirect
github.com/hashicorp/go-multierror v1.1.1
github.com/otiai10/copy v1.7.0 // indirect
github.com/spf13/cobra v1.3.0 // indirect
github.com/golang/glog v1.0.0
github.com/google/go-cmp v0.5.6
github.com/google/licenseclassifier v0.0.0-20210722185704-3043a050f148
github.com/otiai10/copy v1.7.0
github.com/spf13/cobra v1.3.0
github.com/stretchr/testify v1.7.0
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8 // indirect
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77 // indirect
golang.org/x/tools v0.1.5
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/src-d/go-git.v4 v4.13.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/src-d/go-git.v4 v4.13.1
)
31 changes: 15 additions & 16 deletions v2/go.sum

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions v2/gocli/go_binary.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"github.com/google/go-licenses/v2/third_party/go/runtime/debug"
)

// Module metadata extracted from binary and local go module workspace.
// BinaryMetadata is module metadata extracted from binary and local go module workspace.
type BinaryMetadata struct {
// The main module used to build the binary.
// e.g. github.com//google/go-licenses/v2/tests/modules/cli02
Expand All @@ -30,7 +30,7 @@ type BinaryMetadata struct {
Deps []Module
}

// List dependencies from module metadata in a go binary.
// ExtractBinaryMetadata lists dependencies from module metadata in a go binary.
// Modules with replace directives are returned as the replaced module instead.
//
// Prerequisites:
Expand Down
2 changes: 1 addition & 1 deletion v2/gocli/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"golang.org/x/tools/go/packages"
)

// List go modules with metadata in workdir using go CLI list command.
// ListModules lists go modules with metadata in workdir using go CLI list command.
// Modules with replace directive are returned as the replaced module instead.
func ListModules() (map[string]Module, error) {
out, err := exec.Command("go", "list", "-m", "-json", "all").Output()
Expand Down
4 changes: 4 additions & 0 deletions v2/licenses/library.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ func Libraries(ctx context.Context, classifier Classifier, importPaths ...string
}
libraries = append(libraries, lib)
}
// Sort libraries to produce a stable result for snapshot diffing.
sort.Slice(libraries, func(i, j int) bool {
return libraries[i].Name() < libraries[j].Name()
})
return libraries, nil
}

Expand Down
23 changes: 23 additions & 0 deletions v2/third_party/licenses.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
github.com/emirpasic/gods,https://github.com/emirpasic/gods/blob/master/LICENSE,BSD-2-Clause
github.com/golang/glog,https://github.com/golang/glog/blob/master/LICENSE,Apache-2.0
github.com/google/go-licenses/v2,Unknown,Apache-2.0
github.com/google/licenseclassifier,https://github.com/google/licenseclassifier/blob/master/LICENSE,Apache-2.0
github.com/google/licenseclassifier/stringclassifier,https://github.com/google/licenseclassifier/blob/master/stringclassifier/LICENSE,Apache-2.0
github.com/jbenet/go-context/io,https://github.com/jbenet/go-context/blob/master/io/LICENSE,MIT
github.com/kevinburke/ssh_config,https://github.com/kevinburke/ssh_config/blob/master/LICENSE,MIT
github.com/mitchellh/go-homedir,https://github.com/mitchellh/go-homedir/blob/master/LICENSE,MIT
github.com/otiai10/copy,https://github.com/otiai10/copy/blob/master/LICENSE,MIT
github.com/sergi/go-diff/diffmatchpatch,https://github.com/sergi/go-diff/blob/master/diffmatchpatch/LICENSE,MIT
github.com/spf13/cobra,https://github.com/spf13/cobra/blob/master/LICENSE.txt,Apache-2.0
github.com/spf13/pflag,https://github.com/spf13/pflag/blob/master/LICENSE,BSD-3-Clause
github.com/src-d/gcfg,https://github.com/src-d/gcfg/blob/master/LICENSE,BSD-3-Clause
github.com/xanzy/ssh-agent,https://github.com/xanzy/ssh-agent/blob/master/LICENSE,Apache-2.0
golang.org/x/crypto,Unknown,BSD-3-Clause
golang.org/x/mod/semver,Unknown,BSD-3-Clause
golang.org/x/net,Unknown,BSD-3-Clause
golang.org/x/sys,Unknown,BSD-3-Clause
golang.org/x/tools,Unknown,BSD-3-Clause
golang.org/x/xerrors,Unknown,BSD-3-Clause
gopkg.in/src-d/go-billy.v4,Unknown,Apache-2.0
gopkg.in/src-d/go-git.v4,Unknown,Apache-2.0
gopkg.in/warnings.v0,Unknown,BSD-2-Clause

0 comments on commit d5b7edc

Please sign in to comment.