aboutsummaryrefslogtreecommitdiff
path: root/spdxconv.go
diff options
context:
space:
mode:
Diffstat (limited to 'spdxconv.go')
-rw-r--r--spdxconv.go27
1 files changed, 24 insertions, 3 deletions
diff --git a/spdxconv.go b/spdxconv.go
index 7222eb4..b303070 100644
--- a/spdxconv.go
+++ b/spdxconv.go
@@ -7,6 +7,7 @@ import (
"fmt"
"os"
"path/filepath"
+ "slices"
"strings"
"git.sr.ht/~shulhan/pakakeh.go/lib/git"
@@ -70,6 +71,7 @@ func New(path string) (conv *SPDXConv, err error) {
}
conv = &SPDXConv{}
+
conv.curDir, err = os.Getwd()
if err != nil {
return nil, fmt.Errorf(`%s: %w`, logp, err)
@@ -179,6 +181,8 @@ func (conv *SPDXConv) scanFiles(listDir []string) (listFile []string, err error)
`node_modules`: struct{}{},
`vendor`: struct{}{},
}
+ var suffixLicense = `.license`
+
var dir string
var listde []os.DirEntry
var de os.DirEntry
@@ -191,8 +195,17 @@ func (conv *SPDXConv) scanFiles(listDir []string) (listFile []string, err error)
if err != nil {
return listFile, err
}
+
+ var listFileLicense = make(map[string]struct{})
+ var listName []string
for _, de = range listde {
var name = de.Name()
+ // File end with ".license" is SPDX specific file that
+ // contains only identifiers.
+ if strings.HasSuffix(name, suffixLicense) {
+ listFileLicense[name] = struct{}{}
+ continue
+ }
if conv.scm.IsIgnored(name) {
continue
}
@@ -200,12 +213,20 @@ func (conv *SPDXConv) scanFiles(listDir []string) (listFile []string, err error)
if ok {
continue
}
- var pathName = filepath.Join(dir, name)
+ listName = append(listName, name)
+ name = filepath.Join(dir, name)
if de.IsDir() {
- listDir = append(listDir, pathName)
+ listDir = append(listDir, name)
continue
}
- listFile = append(listFile, pathName)
+ listFile = append(listFile, name)
+ }
+ // Remove the file that have the spdx .license file.
+ for x, name := range listName {
+ _, ok = listFileLicense[name+suffixLicense]
+ if ok {
+ listFile = slices.Delete(listFile, x, x+1)
+ }
}
}
return listFile, nil