Skip to content

Fix incorrect divergence cache after switching default branch #34370

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

Merged
merged 5 commits into from
May 8, 2025

Conversation

GWDx
Copy link
Contributor

@GWDx GWDx commented May 5, 2025

Issue: After switching the default branch, other branches are still compared against the old default branch due to outdated divergence cache.

Change: Clear the divergence cache in SetRepoDefaultBranch to ensure correct comparisons against the new default branch.

Fixes #34369

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label May 5, 2025
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label May 5, 2025
Issue: After switching the default branch, other branches are still compared against the old default branch due to outdated divergence cache.

Change: Clear the divergence cache in SetRepoDefaultBranch to ensure correct comparisons against the new default branch.

Fixes go-gitea#34369
@GWDx GWDx force-pushed the fix-branch-divergence branch from aec8d9b to 9902c62 Compare May 5, 2025 03:43
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels May 5, 2025
@lunny lunny added type/bug backport/v1.24 This PR should be backported to Gitea 1.24 labels May 5, 2025
@lunny
Copy link
Member

lunny commented May 5, 2025

It's better to have a test.

@lunny lunny added this to the 1.25.0 milestone May 5, 2025
Verify that branch divergence counts are correctly recalculated after changing the default branch.
@GWDx
Copy link
Contributor Author

GWDx commented May 7, 2025

I’ve added an integration test to verify that branch divergence counts are correctly recalculated after switching the default branch.


htmlDoc := NewHTMLParser(t, resp.Body)

branchNodes := htmlDoc.doc.Find(".gt-ellipsis").Nodes
Copy link
Member

@silverwind silverwind May 7, 2025

Choose a reason for hiding this comment

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

This class selector is too unspecific. Can you maybe add a new unique class to the elements in question and select on that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a new .branch-name class to branch name elements in the branch list template, and updated integration test accordingly.

Copy link
Contributor

Choose a reason for hiding this comment

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

I added a new .branch-name class to branch name elements in the branch list template, and updated integration test accordingly.

I suggest left a comment like something that branch-name is used for tests, do not remove.

Copy link
Member

Choose a reason for hiding this comment

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

I suggest left a comment like something that branch-name is used for tests, do not remove.

Not strictly needed imho, but nice to have because one will notice anyways when the test starts to fail.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels May 8, 2025
@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label May 8, 2025
@lunny lunny enabled auto-merge (squash) May 8, 2025 17:35
@lunny lunny merged commit 71a1187 into go-gitea:main May 8, 2025
26 checks passed
GiteaBot pushed a commit to GiteaBot/gitea that referenced this pull request May 8, 2025
…ea#34370)

Issue: After switching the default branch, other branches are still
compared against the old default branch due to outdated divergence
cache.

Change: Clear the divergence cache in SetRepoDefaultBranch to ensure
correct comparisons against the new default branch.

Fixes go-gitea#34369
@GiteaBot GiteaBot added backport/done All backports for this PR have been created and removed reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. labels May 8, 2025
silverwind pushed a commit that referenced this pull request May 8, 2025
#34406)

Backport #34370 by @GWDx

Issue: After switching the default branch, other branches are still
compared against the old default branch due to outdated divergence
cache.

Change: Clear the divergence cache in SetRepoDefaultBranch to ensure
correct comparisons against the new default branch.

Fixes #34369

Co-authored-by: GWDx <[email protected]>
zjjhot added a commit to zjjhot/gitea that referenced this pull request May 9, 2025
* giteaofficial/main:
  [skip ci] Updated translations via Crowdin
  Fix autofocus behavior (go-gitea#34397)
  Fix incorrect divergence cache after switching default branch (go-gitea#34370)
  Add a button editing action secret (go-gitea#34348)
  Fix LFS file not stored in LFS when uploaded/edited via API or web UI (go-gitea#34367)
  [skip ci] Updated translations via Crowdin
  Fix "The sidebar of the repository file list does not have a fixed height go-gitea#34298" (go-gitea#34321)
  feat: add label 'state' to metric 'gitea_users' (go-gitea#34326)
  Update JS and PY dependencies (go-gitea#34391)
  Upgrade go-github v61 -> v71 (go-gitea#34385)
  Bump `@github/relative-time-element` to v4.4.7 (go-gitea#34384)
  gitignore: Visual Studio settings folder (go-gitea#34375)
  Grey out expired artifact on Artifacts list (go-gitea#34314)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/done All backports for this PR have been created backport/v1.24 This PR should be backported to Gitea 1.24 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Branches still compare against previous default branch after switch
6 participants