Skip to content

Commit

Permalink
🐛 fix deps parsing
Browse files Browse the repository at this point in the history
Signed-off-by: Pranav Gaikwad <pgaikwad@redhat.com>
  • Loading branch information
pranavgaikwad committed Nov 8, 2023
1 parent 429de30 commit bcd1b44
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
9 changes: 8 additions & 1 deletion provider/internal/java/dependency.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,14 @@ func extractSubmoduleTrees(lines []string) [][]string {
continue
}

line = strings.TrimLeft(line, "[INFO] ")
line = strings.TrimPrefix(line, "[INFO] ")
line = strings.Trim(line, " ")

// output contains progress report lines that are not deps, skip those
if !(strings.HasPrefix(line, "+") || strings.HasPrefix(line, "|") || strings.HasPrefix(line, "\\")) {
continue
}

submoduleTrees[submod] = append(submoduleTrees[submod], line)
}
}
Expand Down
8 changes: 7 additions & 1 deletion provider/internal/java/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,8 @@ func parseUnresolvedSources(output io.Reader) ([]javaArtifact, error) {
unresolvedRegex := regexp.MustCompile(`The following files have NOT been resolved`)
for scanner.Scan() {
line := scanner.Text()
line = strings.TrimLeft(line, "[INFO] ")
line = strings.TrimPrefix(line, "[INFO] ")
line = strings.Trim(line, " ")

if sourcesPluginRegex.Find([]byte(line)) != nil {
sourcesPluginSeparatorSeen = true
Expand All @@ -445,6 +446,11 @@ func parseUnresolvedSources(output io.Reader) ([]javaArtifact, error) {
} else if sourcesPluginSeparatorSeen && (unresolvedSeparatorSeen || resolvedSeparatorSeen) {
line, _, _ = strings.Cut(line, " --") // ie: "org.apache.derby:derby:jar:10.14.2.0:test -- module derby (auto)"

// this is the last line which coincidently has 5 parts separated by :
if strings.Contains(line, "Finished") {
continue
}

parts := strings.Split(line, ":")
if len(parts) != 5 {
continue
Expand Down

0 comments on commit bcd1b44

Please sign in to comment.