Skip to content

Conversation

@kwin
Copy link
Member

@kwin kwin commented Jul 30, 2025

Add tests for all Git providers for failing push operations This closes #1253

Following this checklist to help us incorporate your
contribution quickly and easily:

  • Your pull request should address just one issue, without pulling in other changes.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body.
    Note that commits might be squashed by a maintainer on merge.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied.
    This may not always be possible but is a best-practice.
  • Run mvn verify to make sure basic checks pass.
    A more thorough check will be performed on your pull request automatically.
  • You have run the integration tests successfully (mvn -Prun-its verify).

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

@kwin kwin requested a review from michael-o July 30, 2025 14:53
@kwin kwin force-pushed the feature/improve-jgit-push-result-handling branch from 91becec to fcc8bd3 Compare July 30, 2025 14:55
Add tests for all Git providers for failing push operations
This closes #1253
@kwin kwin force-pushed the feature/improve-jgit-push-result-handling branch from fcc8bd3 to dc9ee71 Compare July 30, 2025 17:25

/**
* Exception thrown when a push operation fails in JGit.
* This is a custom exception that extends GitAPIException to provide more context
Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't extend GitAPIException

Copy link
Member Author

Choose a reason for hiding this comment

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

Will fix it, used to extend it, but it does no longer because it was not necessary/useful.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in 369981b.


} catch (PushException e) {
return new BranchScmResult("JGit branch", "Failed to push changes: " + e.getMessage(), "", false);
} catch (Exception e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

can this be a more specific exception?

Copy link
Member Author

Choose a reason for hiding this comment

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

For me this is already as specific as it can get. What do you suggest here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Is something in the try block throwing a raw java.lang.Exception? It shouldn't be, but it isn't unheard of for APIs to make that mistake

Copy link
Member Author

Choose a reason for hiding this comment

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

line 136 was not touched in this PR and is not related. This can be done in some other PR!

Copy link
Contributor

Choose a reason for hiding this comment

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

Line 136 is related. You've changed the exceptions thrown in the try block. That suggests it's worth looking at the catch blocks to make sure they're still needed.

Copy link
Member Author

Choose a reason for hiding this comment

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

I changed only one potential cause of exceptions. The try block involves lots of other JGit commands, therefore I don't want to change this in this context.

return new CheckInScmResult("JGit checkin", checkedInFiles);
} catch (PushException e) {
return new CheckInScmResult("JGit checkin", "Failed to push changes: " + e.getMessage(), "", false);
} catch (Exception e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

can this now be more specific?

Copy link
Member Author

Choose a reason for hiding this comment

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

See above

@kwin kwin force-pushed the feature/improve-jgit-push-result-handling branch from 369981b to 32c5eb9 Compare July 31, 2025 16:48
@kwin kwin merged commit 3e6a34e into master Aug 1, 2025
36 checks passed
@kwin kwin deleted the feature/improve-jgit-push-result-handling branch August 1, 2025 09:52
@github-actions
Copy link

github-actions bot commented Aug 1, 2025

@kwin Please assign appropriate label to PR according to the type of change.

@github-actions github-actions bot added this to the 2.1.1 milestone Aug 1, 2025
@kwin kwin added the bug Something isn't working label Aug 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SCM-1030] Prepare goal does fail to push tag using SCM URL over SSH

2 participants