Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove usage of Maven SCM API #404

Merged
merged 5 commits into from
Jan 26, 2023
Merged

Remove usage of Maven SCM API #404

merged 5 commits into from
Jan 26, 2023

Conversation

basil
Copy link
Member

@basil basil commented Jan 14, 2023

Problem

We currently rely on an old version of the Maven SCM API, which is not only inefficient but which also is a maintenance liability as can be seen in #393 (review).

Solution

Switch to running Git commands directly. Simpler and easier to maintain, and more efficient to boot.

Implementation

Extracted and cleaned up from #382 by @olamy (credited as Co-authored-by in the commit message), but without two portions of that PR:

Testing done

Tested in context in jenkinsci/bom. I also manually corrupted the Git URL to make sure the error handling code path was exercised and worked as expected.

Co-authored-by: Olivier Lamy <olamy@apache.org>
basil added a commit to basil/bom that referenced this pull request Jan 14, 2023
@basil basil marked this pull request as ready for review January 14, 2023 20:56
@basil basil requested a review from a team as a code owner January 14, 2023 20:56
@basil basil requested a review from jtnord January 14, 2023 20:56
.start();
try {
int exitStatus = p.waitFor();
String output = new String(p.getInputStream().readAllBytes(), Charset.defaultCharset()).trim();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: once my other PR is merged, I'll update this to use the gobbler introduced there

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I did it in c20578d; some slight duplication with my other PR, but that will collapse based on which PR is merged first

Comment on lines +698 to +699
if (StringUtils.startsWith(connectionURL, "scm:git:")) {
gitUrl = StringUtils.substringAfter(connectionURL, "scm:git:");
Copy link
Member

@jtnord jtnord Jan 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in https://github.com/jenkinsci/plugin-compat-tester/pull/399/files#r1069741815 you where trying to remove the dependency on commons-lang? can connectionUrl be null? (wont we just die horribly later)?

in which case

Suggested change
if (StringUtils.startsWith(connectionURL, "scm:git:")) {
gitUrl = StringUtils.substringAfter(connectionURL, "scm:git:");
if (connectionURL.startsWith("scm:git:")) {
gitUrl = connectionUrl.substring("scm:git:".length());

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it can be null or not. At the time of this writing the suggestion does not compile and is therefore a non-suggestion

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed the typo above.

@jtnord
Copy link
Member

jtnord commented Jan 18, 2023

note: needs local adaptions, I am working on updating.

@basil
Copy link
Member Author

basil commented Jan 23, 2023

How's this looking this week James?

@jtnord
Copy link
Member

jtnord commented Jan 26, 2023

How's this looking this week James?

the prerequisite for testing this was just merged, just updating the PR to check now.

Copy link
Member

@jtnord jtnord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested, all ok.

@basil
Copy link
Member Author

basil commented Jan 26, 2023

Awesome, thank you!

@basil basil merged commit bcf2fd8 into master Jan 26, 2023
@basil basil deleted the checkout branch January 26, 2023 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants