aboutsummaryrefslogtreecommitdiff
path: root/report.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2026-01-15 14:39:39 +0700
committerShulhan <ms@kilabit.info>2026-01-15 14:39:39 +0700
commit9be132113a261309f73aaddbb83af898a88db385 (patch)
tree6b59878c46a3d5ee106b7aaba8b9bea5c2eae032 /report.go
parente662e3bc3c4aadf15a360495deaa86939ce84980 (diff)
downloadspdxconv-9be132113a261309f73aaddbb83af898a88db385.tar.xz
all: move checking REUSE annotation after all files listed
Use case: on the first scan, the file result in group unknown. User then modify the spdxconv.cfg to add or update the match-file-pattern. The next scan should check again the files in unknown group, in case its match with updated config.
Diffstat (limited to 'report.go')
-rw-r--r--report.go36
1 files changed, 24 insertions, 12 deletions
diff --git a/report.go b/report.go
index 64720b3..6a38f8d 100644
--- a/report.go
+++ b/report.go
@@ -109,8 +109,10 @@ func loadReport() (rep *report, err error) {
f.group = groupBinary
rep.listBinary[f.path] = f
case reportGroupUnknown:
- f.group = groupUnknown
- rep.listUnknown[f.path] = f
+ // Don't store it, we may need to rescan it later.
+ // Use case: the first scan result in unknown, user
+ // then modify the match-file-pattern and re-scan
+ // again.
case reportGroupDone:
rep.listDone[f.path] = f
}
@@ -124,21 +126,28 @@ func loadReport() (rep *report, err error) {
func (rep *report) scan(conv *SPDXConv, listFile []string) (err error) {
var logp = `report.scan`
- var ok bool
- for _, file := range listFile {
- if rep.hasScanned(file) {
+ for _, path := range listFile {
+ if rep.hasScanned(path) {
continue
}
- _, ok = rep.listDone[file]
- if ok {
+ // User may update the REUSE.toml on next scan.
+ if conv.reuse != nil && conv.reuse.isAnnotated(path) {
+ rep.listDone[path] = &file{
+ path: path,
+ }
continue
}
-
- f, err := newFile(file, conv.cfg.MaxLineMatch)
+ f, err := newFile(path, conv.cfg.MaxLineMatch)
if err != nil {
return fmt.Errorf(`%s: %w`, logp, err)
}
if f.group == groupBinary {
+ f.licenseID = valDefault
+ f.copyrightText = valDefault
+ f.getYearFromSCM(conv)
+ if f.copyrightYear == `` {
+ f.copyrightYear = conv.cfg.CopyrightYear
+ }
rep.listBinary[f.path] = f
continue
}
@@ -166,8 +175,8 @@ func (rep *report) scan(conv *SPDXConv, listFile []string) (err error) {
return nil
}
-// hasScanned return true if the file is already reported in regular or
-// binary group before.
+// hasScanned return true if the file is already reported in regular, binary,
+// or done group before.
func (rep *report) hasScanned(path string) bool {
var ok bool
_, ok = rep.listBinary[path]
@@ -178,7 +187,10 @@ func (rep *report) hasScanned(path string) bool {
if ok {
return true
}
- delete(rep.listUnknown, path)
+ _, ok = rep.listDone[path]
+ if ok {
+ return true
+ }
return false
}