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

Mark PR reviews as stale at push and allow to dismiss stale approvals #9532

Merged
merged 20 commits into from
Jan 9, 2020

Conversation

davidsvantesson
Copy link
Contributor

@davidsvantesson davidsvantesson commented Dec 28, 2019

Fix #5997.

  • If a push causes the patch/diff of a PR towards target branch to change, all existing reviews for the PR will be set and shown as stale.
  • New branch protection option to dismiss stale approvals are added.

To show that a review is not based on the latest PR changes, an hourglass is shown:
image

I think there is a point in indicating reviews as being old/stale even if the branch protection does not have the setting to discard stale approvals.
Clean merges should not cause reviews to become stale, as they will not change the diff content of the PR. I have not found any smarter way than generate the diff before and after the push and compare (ignoring some lines). I tested it a bit (and compared to when GitHub marks stale reviews) and it seems to work.

New branch protection option:
image

@codecov-io
Copy link

codecov-io commented Dec 28, 2019

Codecov Report

Merging #9532 into master will decrease coverage by 0.07%.
The diff coverage is 4.92%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #9532      +/-   ##
=========================================
- Coverage   42.17%   42.1%   -0.08%     
=========================================
  Files         583     584       +1     
  Lines       77360   77485     +125     
=========================================
- Hits        32627   32623       -4     
- Misses      40721   40850     +129     
  Partials     4012    4012
Impacted Files Coverage Δ
models/migrations/migrations.go 1.3% <ø> (ø) ⬆️
modules/auth/repo_form.go 43.47% <ø> (ø) ⬆️
modules/git/repo_compare.go 69.56% <0%> (-3.17%) ⬇️
services/pull/review.go 0% <0%> (ø) ⬆️
models/branches.go 45.5% <0%> (-0.39%) ⬇️
models/migrations/v118.go 0% <0%> (ø)
routers/repo/pull_review.go 0% <0%> (ø) ⬆️
routers/repo/pull.go 30.75% <0%> (ø) ⬆️
services/pull/pull.go 21.67% <1.36%> (-8.02%) ⬇️
modules/repofiles/update.go 41.28% <100%> (ø) ⬆️
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5b2d933...3d11d3a. Read the comment docs.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Dec 28, 2019
@lafriks
Copy link
Member

lafriks commented Dec 28, 2019

We should save also commit sha on what PR was made so if old commit is reverted back we could remove stale flag

@davidsvantesson
Copy link
Contributor Author

So the stale flag should be removed if there is a force-push to old commit, or if the old commit is reverted in a new commit, or maybe both? I tested on Github and I don't think they handle that. When a new commit is made Github adds an event:

userA dismissed userB’s stale review via 0123abc 2 minutes ago
and after that a new review is always required. But of course we could try to do better than GH.

Would this mean at every new push all old reviews (latest of each reviewer) has to be checked again if they are valid?

@lafriks
Copy link
Member

lafriks commented Dec 29, 2019

That could be improved in other PRS, more important and quite easy to impelemt that we would set to stale or not based if review commit sha equals currently latest (pushed)

@lafriks
Copy link
Member

lafriks commented Dec 29, 2019

Later we could improve so that we could check to set stale only if diff actually has changed etc but would be faster to merge this in smaller steps

@lafriks lafriks added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Dec 29, 2019
@davidsvantesson davidsvantesson changed the title WIP: Mark PR reviews as stale at push Mark PR reviews as stale at push Dec 29, 2019
@lunny lunny added this to the 1.12.0 milestone Dec 30, 2019
@davidsvantesson davidsvantesson changed the title Mark PR reviews as stale at push Mark PR reviews as stale at push and allow to dismiss stale approvals Jan 2, 2020
@davidsvantesson
Copy link
Contributor Author

The additional code needed to add dismiss stale approvals to branch protection options was small, so I decided to add it in this PR as well.

@lafriks lafriks added the type/changelog Adds the changelog for a new Gitea version label Jan 2, 2020
@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 Jan 3, 2020
# Conflicts:
#	models/branches.go
#	models/migrations/migrations.go
#	models/migrations/v117.go
#	modules/auth/repo_form.go
#	routers/repo/setting_protected_branch.go
#	templates/repo/settings/protected_branch.tmpl
routers/repo/setting_protected_branch.go Show resolved Hide resolved
services/pull/pull.go Outdated Show resolved Hide resolved
services/pull/pull.go Outdated Show resolved Hide resolved
@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 Jan 5, 2020
@6543
Copy link
Member

6543 commented Jan 8, 2020

ping lgtm bot

@zeripath zeripath merged commit 25531c7 into go-gitea:master Jan 9, 2020
@davidsvantesson davidsvantesson deleted the push-is-pr-changed branch January 18, 2020 09:47
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
@delvh delvh removed the type/changelog Adds the changelog for a new Gitea version label Oct 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feature] - Clear approvals if new commit is pushed