diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-05-02 12:11:20 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-05-06 11:44:31 +0300 |
commit | d2b85cd7dc10dc00e5255772b083a3559a3a8618 (patch) | |
tree | e5cd1904100345316a74e6920a623cefaec949c6 /tools | |
parent | a62176db357c3b66b02f01a4271ecda5bb2db35c (diff) |
noticegen: Fix skipping of own licenses
In order to generate our `NOTICE` file, we first export all Go sources
referenced by our project into a directory and then walk that directory
to gather any licenses. The result is that the generated `NOTICE` file
contains the licenses of all our dependencies.
Ideally, the `NOTICE` file wouldn't need to contain any licenses that we
have as part of our own sources. These may for example include licenses
of test files, but also licenses of vendored dependencies. But because
we are already bundling their licenses into our sources in the first
place it shouldn't be necessary to also put them into our `NOTICE` file.
In fact, it seems like we already intended to skip soaking up any such
license files in our own tree: we initially determine the module path of
ourselves, and then return early in `filepath.Walk()` when hitting a
directory path that matches. We only return a `nil` pointer though,
which means we only skip that single directory. That doesn't seem to
make a whole lot of sense though, and it feels like the intent was to
instead skip walking that whole directory.
So let's fix this by returning `filepath.SkipDir` instead so that we
never collect licenses part of our own source tree.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/noticegen/noticegen.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/noticegen/noticegen.go b/tools/noticegen/noticegen.go index 3c8db0fb5..9d2a9f21b 100644 --- a/tools/noticegen/noticegen.go +++ b/tools/noticegen/noticegen.go @@ -62,7 +62,7 @@ func main() { } if p == modInfo.Module.Path { - return nil + return filepath.SkipDir } t, err := os.ReadFile(path) |