Skip to content

Commit

Permalink
Fix wolfictl bump suggestion to not include package itself
Browse files Browse the repository at this point in the history
Signed-off-by: Krish Jain <[email protected]>
  • Loading branch information
krishjainx committed Jul 15, 2024
1 parent f10bd62 commit 75dc174
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/checks/so_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,13 @@ func generateVersions(soname, input string) []string {
return sonames
}

func (o *SoNameOptions) checkSonamesMatch(existingSonameFiles, newSonameFiles []string) error {
func (o *SoNameOptions) checkSonamesMatch(existingSonameFiles, newSonameFiles []string, currentPackage string) error {
if len(existingSonameFiles) == 0 {
o.Logger.Printf("no existing soname files, skipping")
return nil
}

// regex to match version and optional qualifier
// \d+(\.\d+)* captures version numbers that may have multiple parts separated by dots
// ([a-zA-Z0-9-_]*) captures optional alphanumeric (including hyphens and underscores) qualifiers
r := regexp.MustCompile(`(\d+(\.\d+)*)([a-zA-Z0-9-_]*)`)

// first turn the existing soname files into a map so it is easier to match with
Expand Down Expand Up @@ -255,6 +253,9 @@ func (o *SoNameOptions) checkSonamesMatch(existingSonameFiles, newSonameFiles []
if newVersionMajor > existingVersionMajor {
sonames := generateVersions(name, existingVersionStr)
for _, pkg := range o.ExistingPackages {
if pkg.Origin == currentPackage {
continue
}
for _, soname := range sonames {
if slices.Contains(pkg.Dependencies, soname) {
toBump[pkg.Origin] = struct{}{}
Expand All @@ -271,4 +272,4 @@ func (o *SoNameOptions) checkSonamesMatch(existingSonameFiles, newSonameFiles []
}

return errors.Join(errs...)
}
}

0 comments on commit 75dc174

Please sign in to comment.