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
Allow for deleting and restoring branch associated with PR #1784
base: main
Are you sure you want to change the base?
Allow for deleting and restoring branch associated with PR #1784
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking like a great start, I have some concerns I have outlined.
Codecov Report
@@ Coverage Diff @@
## master #1784 +/- ##
=======================================
Coverage 98.76% 98.76%
=======================================
Files 51 51
Lines 2677 2677
=======================================
Hits 2644 2644
Misses 33 33 Continue to review full report at Codecov.
|
a254363
to
fee99a2
Compare
fee99a2
to
f299699
Compare
@s-t-e-v-e-n-k I am trying to figure out why code coverage decreased on a file that I did not interface with or modify any tests that interacted with it. Any ideas? Update: It appears the changes in #1797 will bring the code coverage back to up to the place it should be. I believe the latest pyJWT being released yesterday is causing codecov to not reach that line in MainClass.py -- as long as that PR (1797) is merged before this one, I think that codecoverage wont be affected. Apologies for any spam that I caused by troubleshooting that. |
* Fixes PyGithub#580 -- adding logic for deleting/restoring branches associated with a PR, as well as forcing a delete. Automated tests added too * Adding black formatting and cleansing PII to the best of my ability * CI failure fix - isort formatting, import moved up in the file * fixing additional requests and adding docstrings * Accounting for CI test for pyupgrade
dd0718d
to
16b2544
Compare
As believed, now that the other PR has been merged (and upon me pulling latest master into my branch) this one is ready to be merged as well with no issues :) Thanks |
@s-t-e-v-e-n-k @sfdye Is there anything else in this PR needing changes? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking like a good start, I have some concerns inline.
@s-t-e-v-e-n-k 👍 applied your recommendations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your changes, you're making good progress, some more changes required, though.
@s-t-e-v-e-n-k removing |
Hi ! any news on this ? I'd love to implement it on https://github.com/AFPy/PyDocTeur :) |
@sfdye anything we can do here? |
@s-t-e-v-e-n-k @sfdye who maintains this project currently, if anyone? |
@s-t-e-v-e-n-k @sfdye hoping to make one last ditch effort to follow up |
@JLLeitschuh @EnricoMi Thanks |
@@ -835,12 +835,35 @@ def is_merged(self): | |||
status, headers, data = self._requester.requestJson("GET", self.url + "/merge") | |||
return status == 204 | |||
|
|||
def restore_branch(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing .pyi
file API addition
def merge( | ||
self, | ||
commit_message=github.GithubObject.NotSet, | ||
commit_title=github.GithubObject.NotSet, | ||
merge_method=github.GithubObject.NotSet, | ||
sha=github.GithubObject.NotSet, | ||
deletebranch=False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing .pyi
file API modification
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deletebranch=False, | |
delete_branch=False, |
f"refs/heads/{self.head.ref}", sha=self.head.sha | ||
) | ||
|
||
def delete_branch(self, force=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing .pyi
file API addition
if deletebranch: | ||
self.delete_branch() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, I don't like adding this side-effect here. Given we have delete_branch
, it is very easy for users to delete the branch with a single line after merge
returned. When more pull requests remain, delete_branch
raises an error and call site does not get the successful PullRequestMergeStatus
response.
raise AttributeError( | ||
"PRs referencing this branch remain. Not deleting the branch" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not call this AttributeError
, because the values of the attributes are right, This is more a RuntimeError
, as delete_branch(force=False)
should not be called as long as there exist pull requests.
raise AttributeError( | |
"PRs referencing this branch remain. Not deleting the branch" | |
) | |
raise RuntimeError( | |
"This branch is referenced by open pull requests, set force=True to delete this branch." | |
) |
def delete_branch(self, force=False): | ||
""" | ||
Convenience function that calls :meth:`GitRef.delete` | ||
:rtype: bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add some notes on the semantics of force
.
self.assertTrue( | ||
self.delete_restore_repo.get_branch(self.delete_restore_pull.head.ref) | ||
) | ||
self.assertIs(self.delete_restore_pull.delete_branch(force=False), None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this assertion?
self.assertIs(self.delete_restore_pull.delete_branch(force=False), None) | |
self.delete_restore_pull.delete_branch(force=False) |
@austinsasko seams you have to integrate the latest changes from main into your branch. Also some review comments are waiting to be integrated. Would be nice to see further progress here 🔢 |
Adding logic for deleting/restoring branches associated with a PR, as well as forcing a delete.
Fixes #580