Fix regexp for AddedExtractor (#284)

Co-authored-by: mariom <11mariom@gmail.com>
This commit is contained in:
Mariusz Kozakowski 2023-01-18 22:39:12 +01:00 committed by GitHub
parent 046331748c
commit 1512db5b55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,9 +14,9 @@ func (e addedExtractor) Matches(line string) bool {
} }
func (e addedExtractor) Extract(metadata *BackupLogMetadata, line string) { func (e addedExtractor) Extract(metadata *BackupLogMetadata, line string) {
// Sample line: "Added to the repo: 0 B" // Sample line: "Added to the repo: 0 B"
metadata.AddedSize = strings.TrimSpace(e.re.ReplaceAllString(line, "")) metadata.AddedSize = strings.TrimSpace(e.re.ReplaceAllString(line, "$2"))
} }
func NewAddedExtractor() MetadatExtractor { func NewAddedExtractor() MetadatExtractor {
return addedExtractor{regexp.MustCompile(`(?i)^Added to the repo:`)} return addedExtractor{regexp.MustCompile(`(?i)^Added to the repo(sitory)?: ([\d\.]+ \w+)( \([\d\.]+[\w\s]+\))?`)}
} }