Skip to content

Fix wrong display of recently pushed notification#25812

Merged
lunny merged 122 commits into
go-gitea:mainfrom
yp05327:fix-incorrect-recently-pushed-new-branches-check
May 21, 2024
Merged

Fix wrong display of recently pushed notification#25812
lunny merged 122 commits into
go-gitea:mainfrom
yp05327:fix-incorrect-recently-pushed-new-branches-check

Conversation

@yp05327
Copy link
Copy Markdown
Contributor

@yp05327 yp05327 commented Jul 10, 2023

There's a bug in #25715:
If user pushed a commit into another repo with same branch name, the no-related repo will display the recently pushed notification incorrectly.
It is simple to fix this, we should match the repo id in the sql query.

image
The latest commit is 2 weeks ago.
image

The notification comes from another repo with same branch name:
image

After:
In forked repo:
image
New PR Link will redirect to the original repo:
image
In the original repo:
image
New PR Link:
image

In the same repo:
image
New PR Link:
image

08/15 Update:
Follow #26257, added permission check and logic fix mentioned in #26257 (comment)

2024/04/25 Update:
Fix #30611

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jul 10, 2023
@yp05327 yp05327 requested a review from lunny July 10, 2023 08:36
@lunny
Copy link
Copy Markdown
Member

lunny commented Jul 10, 2023

duplicated with #25795

@silverwind
Copy link
Copy Markdown
Member

It does sound like it solves a different issue.

@yp05327
Copy link
Copy Markdown
Contributor Author

yp05327 commented Jul 10, 2023

Have no enough time to test this PR, I will test it later.

@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 Jul 10, 2023
Comment thread models/git/branch.go Outdated
})
err := db.GetEngine(ctx).
Where("pusher_id=? AND is_deleted=?", userID, false).
Where("repo_id=? AND pusher_id=? AND is_deleted=?", repoID, userID, false).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The problem I see with this is the following:
Now, you won't be able to see this message in forks.
I've thought about the logic in the previous PR and thought it seems sensible.
While I can also see your problem, the question is now which of the two is better?
Or is there a third approach to still include forks, i.e. additionally storing a ForkedFromID or something like that?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it's difficult to get all forked repositories. Maybe only the first level forked?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I meant the other way round as it is a one-to-n relation: Each fork only has a single parent, so we can check for repoID = fork or parent.

@yp05327 yp05327 marked this pull request as draft July 10, 2023 23:48
@yp05327
Copy link
Copy Markdown
Contributor Author

yp05327 commented Jul 11, 2023

#25795 not looks good to me. It is not good to detect branch by name, as we may have same branch names in different repos.
Instead, I used latest commit id, then you can also avoid display notification from both no-change branch in forked repo and the original repo.

Added some screenshots to the pr description.

@yp05327 yp05327 marked this pull request as ready for review July 11, 2023 01:52
@pull-request-size pull-request-size Bot added size/L and removed size/M labels Jul 11, 2023
@yp05327 yp05327 requested a review from lunny July 11, 2023 05:26
@GiteaBot GiteaBot added lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jul 11, 2023
@yp05327
Copy link
Copy Markdown
Contributor Author

yp05327 commented Jul 11, 2023

We can add a test for this new feature later.
Maybe not in this PR, it is not easy to do this, as we need to make many changes in db and git data.

DennisRasey pushed a commit to DennisRasey/forgejo that referenced this pull request May 14, 2024
go-gitea/gitea#25812 (comment)
Follow #30573

(cherry picked from commit f7d2f695a4c57b245830a526e77fa62e99e00254)

Conflicts:
	services/pull/check.go
	trivial conflict because
	  9b2536b78fdcd3cf444a2f54857d9871e153858f Update misspell to 0.5.1 and add `misspellings.csv` (#30573)
	was not cherry-picked
@yp05327
Copy link
Copy Markdown
Contributor Author

yp05327 commented May 20, 2024

@wxiaoguang
Tests has been fixed.
We allow displaying notifications if the branch is created by doer, no matter doer really has the permission to create PR.
It will be checked when creating PR.

@wxiaoguang
Copy link
Copy Markdown
Contributor

Still unrelated changes?

image

@yp05327
Copy link
Copy Markdown
Contributor Author

yp05327 commented May 20, 2024

user13 is added as a collaborator to repo10, so access table changed.

@wxiaoguang
Copy link
Copy Markdown
Contributor

user13 is added as a collaborator to repo10, so access table changed.

Why not just "append" one, and keep the old "id" as-is?

@yp05327
Copy link
Copy Markdown
Contributor Author

yp05327 commented May 21, 2024

user13 is added as a collaborator to repo10, so access table changed.

Why not just "append" one, and keep the old "id" as-is?

@wxiaoguang
Done in b1346d5 and 0d589f4

@yp05327
Copy link
Copy Markdown
Contributor Author

yp05327 commented May 21, 2024

So strange. I only saw 126 lines in compare_test.go, but the CI failed in L143.
But after I updated the branch, I saw it. 😕

@wxiaoguang
Copy link
Copy Markdown
Contributor

Still unrelated changes? 🤔

image

Comment thread models/git/branch_list.go
Comment thread models/git/branch_list.go Outdated
@yp05327 yp05327 force-pushed the fix-incorrect-recently-pushed-new-branches-check branch from 59b9311 to 8cea058 Compare May 21, 2024 04:14
Comment thread models/git/branch_list.go Outdated
@GiteaBot
Copy link
Copy Markdown
Collaborator

I was unable to create a backport for 1.22. @yp05327, please send one manually. 🍵

go run ./contrib/backport 25812
...  // fix git conflicts if any
go run ./contrib/backport --continue

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

Labels

backport/done All backports for this PR have been created backport/manual No power to the bots! Create your backport yourself! lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. type/bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proposal: cancel the reminder of this merge request on the page

7 participants