Skip to content

JGit checkout fails if refspec has leading spaces - #1788

Open
akash-manna-sky wants to merge 1 commit into
jenkinsci:masterfrom
akash-manna-sky:JENKINS-70303
Open

JGit checkout fails if refspec has leading spaces#1788
akash-manna-sky wants to merge 1 commit into
jenkinsci:masterfrom
akash-manna-sky:JENKINS-70303

Conversation

@akash-manna-sky

Copy link
Copy Markdown
Contributor

JGit checkout fails if refspec has leading spaces

Fixes #1663

Testing done

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

@github-actions github-actions Bot added the tests Automated test addition or improvement label Aug 13, 2026
@akash-manna-sky
akash-manna-sky marked this pull request as ready for review August 13, 2026 19:18
@akash-manna-sky
akash-manna-sky requested a review from a team as a code owner August 13, 2026 19:18
@akash-manna-sky

Copy link
Copy Markdown
Contributor Author

Hi @MarkEWaite, could you please review this PR?

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes JGit checkout/fetch/clone behavior when refspec strings include leading/trailing whitespace (e.g., a leading space before +), by trimming whitespace in refspec handling so JGit behaves more like CLI git. It adds shared trimming helpers and extends coverage with focused unit and integration-style tests for fetch/clone with whitespace-surrounded refspecs.

Changes:

  • Add trimRefSpec / trimRefSpecs helpers to normalize whitespace around refspec source/destination.
  • Apply trimming in JGit and CLI implementations when consuming refspecs (fetch/clone/push).
  • Add new tests validating trimming behavior and verifying fetch/clone succeed with whitespace-surrounded refspecs.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/main/java/org/jenkinsci/plugins/gitclient/LegacyCompatibleGitAPIImpl.java Adds shared refspec whitespace-trimming helpers (String/RefSpec/list).
src/main/java/org/jenkinsci/plugins/gitclient/JGitAPIImpl.java Trims provided refspecs before JGit fetch/clone operations consume them.
src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java Trims refspecs before constructing CLI git arguments for fetch/clone/push.
src/test/java/org/jenkinsci/plugins/gitclient/RefSpecTrimTest.java Adds unit tests for trimming behavior and JGit misparse regression.
src/test/java/org/jenkinsci/plugins/gitclient/GitClientFetchTest.java Adds regression test to ensure fetch works with whitespace-surrounded refspecs.
src/test/java/org/jenkinsci/plugins/gitclient/GitClientCloneTest.java Adds regression test to ensure clone stores trimmed refspecs and fetches expected branches.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Automated test addition or improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[JENKINS-70303] JGit checkout fails if refspec has leading spaces

2 participants