Stash: Open PR for a feature branch which was previously reverted

151 Views Asked by At

Others in the Stash community have requested the ability to revert and re-open a merged Pull Request: https://jira.atlassian.com/browse/BSERV-3218

I am facing a similar issue, however I don't care that Stash doesn't provide a way to revert the PR. The issue that I have is that Stash won't allow me to open a new PR for a feature branch which was previously merged then subsequently reverted.

Scenario:

  1. Create branch feature/US-123 based on develop (at commit 0100)
  2. Create some commits on the feature branch (commits 0201 and 0202)
  3. Merge some other feature branches into develop (now at commit 0105)
  4. Open PR for feature/US-123 -> develop
  5. Accept/merge the PR, creating a new merge commit on develop (commit 0106)
  6. Decide to revert the merged feature (git revert -m1 0106)
  7. Either:
    • push the revert directly to develop
    • or preferably, push the revert commit to a new branch (feature/US-123-revert) and open/merge a PR to develop
  8. Decide to reintroduce feature/US-123 (perhaps with additional changes)
  9. Try to open a new PR for feature/US-123 -> develop; note that Stash doesn't show the original commits in the new PR, even though those commits are no longer in the develop branch

What's wrong here?
Is it a misunderstanding on my part?
Is this an issue that my scenario introduces?
Or is this actually just an annoying Stash deficiency?

What are some ways to mitigate this? So far I have:

  • Rebase feature/US-123 on develop so the revert commit is included in the feature branch's history. Prefer not to do this because our current git workflow prohibits us from rebasing feature branches in some scenarios.
  • Create a new branch feature/US-123-rebase for the previous scenario.
  • Revert the revert commit to reintroduce the original merge commit, then add additional commits to the feature branch as needed.
  • Others?
1

There are 1 best solutions below

0
On

If I understand correctly, this is Git working as expected. I'm assuming that your original feature branch hasn't moved since the first time you merged it so it's rightfully picking up that there are no commits from that branch that aren't already in the tree for develop.

To get around this, I'd suggest creating a new branch from develop, cherry-picking the commits from the previous branch, then creating a pull request.