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

branch: Close all the associated PRs when a branch is deleted. #5646

Closed
wants to merge 3 commits into from

Conversation

HarshitOnGitHub
Copy link
Contributor

Fixes: #2466.

@codecov-io
Copy link

codecov-io commented Jan 5, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@91c2c23). Click here to learn what that means.
The diff coverage is 54.54%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #5646   +/-   ##
=========================================
  Coverage          ?   41.35%           
=========================================
  Files             ?      432           
  Lines             ?    59576           
  Branches          ?        0           
=========================================
  Hits              ?    24639           
  Misses            ?    31694           
  Partials          ?     3243
Impacted Files Coverage Δ
models/issue.go 48.84% <100%> (ø)
models/action.go 59.2% <100%> (ø)
models/pull.go 51.2% <41.17%> (ø)

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 91c2c23...70c1e28. Read the comment docs.

@bkcsoft bkcsoft added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jan 5, 2019
models/pull.go Outdated Show resolved Hide resolved
@lunny lunny added the type/bug label Jan 6, 2019
@lunny lunny added this to the 1.8.0 milestone Jan 6, 2019
models/pull.go Outdated Show resolved Hide resolved
models/pull.go Outdated Show resolved Hide resolved
return
}
prs := append(baseprs, headprs...)
for statusChanged := true; statusChanged; {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not what I meant by sort the issues.

You have a list of pull-requests, prs. Consider two pull-requests p and q, say p<q if q has a dependency on p.

Assuming there are no cyclic dependencies, this < forms a partial order on the set of PRs in prs. You can then sort the list prs by this partial order. (There will be multiple valid sortations of the list but who cares.)

You should not have to ask the database potentially n^2 times whether an issue still has dependencies.

Further, this whole section should be done in a transaction - you're at risk of data changing under your feet here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I had understood what you meant in your comment but after looking at our code for issue dependency I found that it is indeed possible to create a cycle involving three or more issues like A->B->C->A, in this case sorting can't be done without first detecting and removing the issues involved in the cycle, right? If you are concerned about the database query I can remove that by the replacing the code with some less straightforward code, but shouldn't that database query be cheap since we are performing only a count operation and not actually loading the data?
I think we should fix the issue dependency code anyway to avoid having circular dependency, right?

Further, this whole section should be done in a transaction - you're at risk of data changing under your feet here.

Yeah sorry missed that, will change it. :)
Thanks for taking time to review! :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Eurgh. I hadn't realised we weren't enforcing non-cyclicity - which I guess is hard without always forcing the transitive closure on dependency additional - and is itself prone to exponential blow up.

Ok. Let's think about this slightly differently - does it ever make sense to have an open pull request from a deleted branch? Probably not, even if that request has dependencies that it should prevent its closure - the fact that the code isn't there means it must be closed despite this.

So, if it doesn't break the database and the app layer to force it closed we should force it closed in spite of its dependencies. (I'm not sure for definite if this is the case - but I'd be surprised if it was the case.)

I guess therefore either issue.ChangeStatus should have additional optional argument to force or, there needs to be a ForceClose function. I could imagine a possible use for a ForceClose for cases where there has been a rogue user - although it might make sense in such situations to just delete everything they've done.

(I appreciate that I'm nitpicking over what will be usually one PR but people have a tendency to deliberately break stuff.)

@techknowlogick techknowlogick modified the milestones: 1.8.0, 1.9.0 Mar 8, 2019
@stale
Copy link

stale bot commented May 7, 2019

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 months. Thank you for your contributions.

@techknowlogick techknowlogick modified the milestones: 1.9.0, 1.10.0 Jun 4, 2019
@stale
Copy link

stale bot commented Aug 3, 2019

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 months. Thank you for your contributions.

@stale stale bot added the issue/stale label Aug 3, 2019
@lunny lunny added the issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented label Aug 4, 2019
@stale stale bot removed the issue/stale label Aug 4, 2019
@techknowlogick techknowlogick modified the milestones: 1.10.0, 1.11.0 Sep 3, 2019
@lunny
Copy link
Member

lunny commented Dec 14, 2019

Please resolve the conflicts.

@lunny lunny modified the milestones: 1.11.0, 1.12.0 Dec 27, 2019
@lunny
Copy link
Member

lunny commented Mar 25, 2020

replaced by #9927

@lunny lunny closed this Mar 25, 2020
@lunny lunny removed this from the 1.12.0 milestone Mar 25, 2020
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When a pull request branch deleted, the opened pull request should be closed automatically
8 participants