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

Adapt remote branch listing test to CLI git 2.48.0 #1242

Merged

Conversation

MarkEWaite
Copy link
Contributor

@MarkEWaite MarkEWaite commented Jan 14, 2025

Adapt remote branch listing test to CLI git 2.48.0

This test was unintentionally testing the behavior of CLI git before 2.48.0. Other tests in GitClientFetchTest were testing that origin/HEAD was reported as a branch.

The GitHub blog post for git 2.48.0 says:

With Git 2.48, if the remote has a default branch but refs/remotes/origin/HEAD is missing locally, then a fetch will update it.

Testing done

  • Confirmed that command line git 2.48.0 fails testListRemoteBranches without this change and passes with this change
  • Confirmed that command line git 2.43.0 passes testListRemoteBranches without this change and passes with this change

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 demonstrates feature works or fixes the issue

When the assertion fails, show the details of the set of branches so
that the test failure has more information about the failure conditions.

Preparation for a future time when a failure like this recurs:

* jenkinsci/bom#4193

Thanks to @darinpope for the question that prompted the improvement
@MarkEWaite MarkEWaite requested a review from a team as a code owner January 14, 2025 18:28
@MarkEWaite MarkEWaite added the test Automated test addition or improvement label Jan 14, 2025
@github-actions github-actions bot added the tests Automated test addition or improvement label Jan 14, 2025
Command line git 2.48.0 and later are now able to update the HEAD ref
that is kept locally to represent the condition of the default branch on
the remote repository.  That update was read by the getRemoteBranches()
method as though it were a distinct remote branch rather than a symbolic
reference to the default branch.

Adapt the getRemoteBranches() method to not return a remote branch "HEAD"
if that remote branch is also a symbolic reference.

https://github.blog/open-source/git/highlights-from-git-2-48/ says:

With Git 2.48, if the remote has a default branch but
refs/remotes/origin/HEAD is missing locally, then a fetch will update it.

Testing done:

* Confirmed that command line git 2.48.0 fails testListRemoteBranches
  without this change and passes with this change

* Confirmed that command line git 2.43.0 passes testListRemoteBranches
  without this change and passes with this change
@MarkEWaite MarkEWaite changed the title Show name and sha1 of detected branches on failure Adapt git client remote branch listing to CLI git 2.48.0 Jan 14, 2025
@MarkEWaite MarkEWaite changed the title Adapt git client remote branch listing to CLI git 2.48.0 Adapt remote branch listing to CLI git 2.48.0 Jan 14, 2025
@MarkEWaite MarkEWaite added bug Incorrect or flawed behavior and removed test Automated test addition or improvement tests Automated test addition or improvement labels Jan 14, 2025
Fetch from CLI git 2.48.0 and later return origin/HEAD

https://github.blog/open-source/git/highlights-from-git-2-48/ says:

With Git 2.48, if the remote has a default branch but refs/remotes/origin/HEAD
is missing locally, then a fetch will update it.

This test was unintentionally testing the behavior of CLI git before
2.48.0.  Other tests in GitClientFetchTest were testing that origin/HEAD
was reported as a branch.
@github-actions github-actions bot added the tests Automated test addition or improvement label Jan 14, 2025
@MarkEWaite MarkEWaite changed the title Adapt remote branch listing to CLI git 2.48.0 Adapt remote branch listing test to CLI git 2.48.0 Jan 14, 2025
@MarkEWaite MarkEWaite removed the bug Incorrect or flawed behavior label Jan 14, 2025
@MarkEWaite MarkEWaite merged commit 8d5f9c3 into jenkinsci:master Jan 15, 2025
18 checks passed
@MarkEWaite MarkEWaite deleted the better-assertion-failure-message branch January 15, 2025 03:25
MarkEWaite added a commit that referenced this pull request Jan 15, 2025
* Adapt GitAPITest for CLI git 2.48.0

Fetch from CLI git 2.48.0 and later return origin/HEAD

https://github.blog/open-source/git/highlights-from-git-2-48/ says:

> With Git 2.48, if the remote has a default branch but refs/remotes/origin/HEAD
> is missing locally, then a fetch will update it.

This test was unintentionally testing the behavior of CLI git before
2.48.0.  Other tests in GitClientFetchTest were testing that origin/HEAD
was reported as a branch.

* Show names/sha1 of detected branches on failure

When the assertion fails, show the details of the set of branches so
that the test failure has more information about the failure conditions.

Thanks to @darinpope for the question that prompted the improvement

* Remove unused cliGitCommand from GitAPITest
MarkEWaite added a commit that referenced this pull request Jan 15, 2025
* Adapt GitAPITest for CLI git 2.48.0

Fetch from CLI git 2.48.0 and later return origin/HEAD

https://github.blog/open-source/git/highlights-from-git-2-48/ says:

> With Git 2.48, if the remote has a default branch but refs/remotes/origin/HEAD
> is missing locally, then a fetch will update it.

This test was unintentionally testing the behavior of CLI git before
2.48.0.  Other tests in GitClientFetchTest were testing that origin/HEAD
was reported as a branch.

* Show names/sha1 of detected branches on failure

When the assertion fails, show the details of the set of branches so
that the test failure has more information about the failure conditions.

Thanks to @darinpope for the question that prompted the improvement

* Remove unused cliGitCommand from GitAPITest
MarkEWaite added a commit to MarkEWaite/bom that referenced this pull request Jan 17, 2025
Add more comments that explain the reason for the test exclusion.

* jenkinsci/git-client-plugin#1242
MarkEWaite added a commit to jenkinsci/bom that referenced this pull request Jan 17, 2025
Add more comments that explain the reason for the test exclusion.

* jenkinsci/git-client-plugin#1242
MarkEWaite added a commit that referenced this pull request Jan 17, 2025
* Adapt GitAPITest for CLI git 2.48.0

Fetch from CLI git 2.48.0 and later return origin/HEAD

https://github.blog/open-source/git/highlights-from-git-2-48/ says:

> With Git 2.48, if the remote has a default branch but refs/remotes/origin/HEAD
> is missing locally, then a fetch will update it.

This test was unintentionally testing the behavior of CLI git before
2.48.0.  Other tests in GitClientFetchTest were testing that origin/HEAD
was reported as a branch.

* Show names/sha1 of detected branches on failure

When the assertion fails, show the details of the set of branches so
that the test failure has more information about the failure conditions.

Thanks to @darinpope for the question that prompted the improvement

* Remove unused cliGitCommand from GitAPITest

(cherry picked from commit 8d5f9c3)
MarkEWaite added a commit to MarkEWaite/bom that referenced this pull request Jan 18, 2025
The git client 5.0.0 automated tests unintentionally tested a command
line git behavior that changed in command line git 2.48.0.  The test is
fixed in git client plugin 5.0.2 and git client plugin 6.1.1.

More details are available in:

* jenkinsci/git-client-plugin#1242

Resolves the test failure in the plugin BOM that required the addition of a test exclusion in:

* jenkinsci#4232
* jenkinsci#4233

Testing done:

* Confirmed that the test fails before this change with:

  PLUGINS=git-client LINE=2.462.x TEST=GitAPITest bash ./local-test.sh

* Confirmed that the test passes after this change with:

  PLUGINS=git-client LINE=2.462.x TEST=GitAPITest bash ./local-test.sh
darinpope pushed a commit to jenkinsci/bom that referenced this pull request Jan 18, 2025
The git client 5.0.0 automated tests unintentionally tested a command
line git behavior that changed in command line git 2.48.0.  The test is
fixed in git client plugin 5.0.2 and git client plugin 6.1.1.

More details are available in:

* jenkinsci/git-client-plugin#1242

Resolves the test failure in the plugin BOM that required the addition of a test exclusion in:

* #4232
* #4233

Testing done:

* Confirmed that the test fails before this change with:

  PLUGINS=git-client LINE=2.462.x TEST=GitAPITest bash ./local-test.sh

* Confirmed that the test passes after this change with:

  PLUGINS=git-client LINE=2.462.x TEST=GitAPITest bash ./local-test.sh
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.

1 participant