Skip to content

Commit

Permalink
Codetf output for pom files now consider target lines instead of sour…
Browse files Browse the repository at this point in the history
…ce (#454)

\close #work
  • Loading branch information
andrecsilva authored Oct 4, 2024
1 parent 6b7e74c commit d444088
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ public int find(final List<AbstractDelta<String>> deltas, final String artifactI
if (hasArtifactId && hasVersion) {
// if it has the artifact and version, it could be the <dependencyManagement> section, which
// is 2nd preference
backupPosition = 1 + delta.getSource().getPosition();
backupPosition = 1 + delta.getTarget().getPosition();
} else if (hasArtifactId) {
// if it has the artifact but not the version, it could be the <dependencies> section, which
// is preferred
return 1 + delta.getSource().getPosition();
return 1 + delta.getTarget().getPosition();
}
}
if (backupPosition != null) {
return backupPosition;
}
// the fallback is to just use the first change to the file
return 1 + deltas.get(0).getSource().getPosition();
return 1 + deltas.get(0).getTarget().getPosition();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,11 @@ private static Stream<Arguments> expectedChangeDescriptionLocations() {
Arguments.of(simplePom, 7), // injects all new text in one delta
Arguments.of(
simplePomWithExistingSections,
16), // already has both sections, record at dependencies section
17), // already has both sections, record at dependencies section
Arguments.of(
webgoatPomThatJustNeedsUpgrades,
151), // just updating the version number here in the properties
Arguments.of(webgoatPom, 413) // add to the end of the dependencies section
Arguments.of(webgoatPom, 419) // add to the end of the dependencies section
);
}

Expand Down

0 comments on commit d444088

Please sign in to comment.