diff options
Diffstat (limited to 'report.go')
| -rw-r--r-- | report.go | 36 |
1 files changed, 24 insertions, 12 deletions
@@ -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 } |
