Is it possible to delete a pull-request on BitBucket? - bitbucket

I cannot find an option to delete a PR on BitBucket.
Am I overlooking something or it's really not possible?

You can decline a pull request which has the same result -- stopping / removing the PR.

As per the link jonrsharpe mentioned, to the right of the merge button there are 3 dots. Under that menu you should have a delete option if you have permission to delete.
This is available only for BitBucket Server, not on BitBucket.org.
In BitBucket.org there is no option to delete the PR.

For Bitbucket Cloud, there are no way to do this. One way of getting by is to have a 'dev/junk' branch, used for declined or useless pull requests.
Then just edit the existing request to go into this branch and merge.
Data is still there, in case you need it some day, or if it's sensitive info you can remove the whole branch. If its already declined before, well, nothing can be done then other than recreating that repo
See https://jira.atlassian.com/browse/BCLOUD-8089 for the update on this feature request and vote on it!

I wanted to delete a pull request of a branch that had already been merged and deleted. Even though I am an admin of my project, I cannot see any "delete" options. For me what worked was to recreate the deleted branch from the main branch and push it. E.g.
git checkout master
git checkout -b [deleted branch name]
git push -u origin [deleted branch name]
Then I opened Bitbucket and the branch showed up as "merged" and disappeared from the PRs list.

You cannot delete the PR in bitbucket.org .
Using Decline option will do exactly what you want - the PR won't be visible in the tab Pull requests (you need to sort PR by Decline to see it) but on tab Branches you will see that in column Pull request you have removed your problematic PR.
PS you cannot undo Decline of PR, so take care

Related

Gerrit move patchset to merged branch

There are two (remote)branches in our project: dev and master. dev diverged from master some time ago and was used for development. I have some patchsets which are pending on dev (pushed to refs/for/dev and have review comments etc), but now dev has been merged into master and the patchset needs to be submitted to master instead of dev.
I would like to move the patchset from dev to master now since dev is no longer being used.
When I try cherry-picking the change onto master I get an error:
Cherry Pick Conflict! Cherry Pick failed! (merge conflicts) Please
select "Continue" to continue with conflicts or select "cancel" to
close the dialog.
and if I continue anyway I get this error:
An error occurred Could not perform action: Cannot create new patch
set of change 562407 because it is abandoned
If I try moving the change to master (suggested here: Rebasing current patchset in Gerrit onto another branch) I get this error:
An error occurred Could not perform action: Destination master has a
different change with same change key
Ie63692606xxx5841xxxxca2687ebxxxaa8f84d2
How can I get the change with all the comments etc. onto the master branch now? If not, how do I create a new change on the master branch for the same patch set?
If I checkout the patch and try git push origin HEAD:refs/for/master, I still get an error.
I had another patchset with the same changeId on the master which I had abandoned earlier, which is why the move patchset didn't work. After I deleted the abandoned patchset, I was able to move the change to the master branch (with conflicts that I now need to resolve.).

Block direct pushes to branch

My team uses both gerrit and gitlab and this sometimes causes issues when people are working on both gerrit and gitlab at same time.
While working on gerrit instead of
git push origin HEAD:refs/for/master we wrongly issue git push.
So instead of creating a changeset, the code gets automatically pushed to Remote branch.
How can we block all direct pushes to a branch in gerrit?
Go to:
Gerrit > All-Projects project > Access
Look at the "Push" permission at the "refs/heads/*" category. Probably your team has an "ALLOW" in this permission. Edit the project permissions to remove it or to add a "BLOCK" specific for your team.
there is an access category - push
so this can be disabled for a group under the project admin site. more info can be found here

Branch permissions bypassed on Bitbucket: Pull request requires approval, but merges anyways?

We plan to have only admins able to make changes to our repo’s master branch. Developers can clone the repo and then create their own dev branch off of master to work on. When developers feel ready, they can merge their development branch onto the master branch using a pull request. However, they will not be able to merge their dev branch into master until the admins have approved the changes.
On Bitbucket, I set branch permissions as:
+ Write Access: Rachel and Jamie.
+ Merge via pull request: Rachel, Jamie, and team:developers.
+ Merge checks: check for at least 2 approvals.
Next, we had a developer (not Rachel or Jamie) make changes on their own dev branch. They then committed and pushed the changes to their remote dev branch--worked as expected.
Last, they initiated a pull request to merge the remote dev branch into master. A warning that two approvals was needed popped up, but the developer was still able to just click "Merge" and the dev branch merged into the master branch, despite 0 approvals.
I expected that the developer would not be able to merge with 0 approvals. How do I set permissions so that this is the case?
Two things:
You explicitly granted "merge via pull request" access to the developers. They're therefore able to merge pull requests. If you never want them to merge PRs to that branch, then revoke that. (They'll still be able to create PRs, just not merge them.)
You didn't mention whether you've enabled "Prevent a merge with unresolved merge checks", under the premium features.
We've created a plugin to prevent this situation. You can inspect it on marketplace:
https://marketplace.atlassian.com/apps/1219882/prevent-merge-when-needs-work

Bitbucket: Merge pull request without clicking Approve

I already merged a pull request in bitbucket. Can you all explain what is the difference between click Approve and don't click it?
Because I see that the merge commit still appears in git history/log even that I don't click Approve.
If your team has a Premium plan, repository admins can prevent pull requests that don't have a certain number of approvals from merging.
Other than that, it is a visual check only that the merge request was reviewed and approved prior to merging.
See: https://confluence.atlassian.com/bitbucket/pull-requests-and-code-review-223220593.html

How to get previous patch in gerrit

I am Sajid, I like to know Is it possible that I can go back to my previous patch in my commit. I can explain:
I commit something. On the way to delivery, i fixed and update things and pushed into gerrit with commit --amend. But what I am experiencing now my last patch is a faulty so I like to go back to previous patch. and I don't know how can i point to my previous patch. And I also like to know will it be the same procedure even If I go to any previous patch.
thanks in advance.
As this answer said, patchsets can not be reverted. so first you have to checkout one of the previous patchset. you can get the command from Gerrit review board at each patchset download panel. For example:
git fetch https://android.googlesource.com/kernel/tegra refs/changes/43/69243/2 && git checkout FETCH_HEAD
After checking it out amend it to generate new commit hash then pushed again as a new patchset.

Resources