Home > Software engineering >  Why is the behavior of PR base branch deletion different between GitHub and AWS CodeCommit
Why is the behavior of PR base branch deletion different between GitHub and AWS CodeCommit

Time:09-02

Hello consider the following scenario, There is a "Dev" branch and two feature branches "A" and "B", "B" will merge into "A" and finally "A" will merge into "Dev" branch this flow can be easily understood by following diagram. Note that after merging the merged branch will be deleted immediately.

enter image description here

Now though, I want to setup 2 Pull Requests, one for "B" into "A", and another for "A" into "Dev", and then test what happens if I merge "A" into "Dev" first.

When I merge "A" branch into "Dev" branch then simply "A" branch is removed instantly and what happens next is a bit interesting:

GitHub

The GitHub changes the base of the branch "B" to the "Dev" branch as, which obviously make sense because "Dev" now contains all the code which was present in "A", so when "B" is merged technically "Dev" contains the work of both "A" and "B", this totally makes sense and its the desired behavior.

AWS Code Commit

The problem rise here, when the same operation is performed in AWS code commit, the "A" is merged into "Dev" but now due to the deletion of "A" the "B" branch cannot be merged into "A" anymore, so "B" branch is closed automatically by AWS code commit, which leads to the partial work in "Dev" branch.

The Main Question

How do i achieve the behavior of GitHub in AWS code commit ?

CodePudding user response:

Why is the behavior of PR base branch deletion different between GitHub and AWS CodeCommit?

That's just the way it is.

Note that Pull Requests aren't actually a part of Git itself, but instead are a common feature that many tools implement. Some tools don't even call them "Pull Requests"! (GitLab, for example, calls them "Merge Requests, which IMHO is a slightly better name.) In most workflows, the base branch, also know as a target branch of a Pull Request, is typically a long-lived branch, so it wouldn't commonly be deleted while other Pull Requests are pointing to it. It's not surprising then that each tool implements this case a little differently. You're observations of the differences are documented:

GitHub's implementation of automatically changing the PR base branch is documented here:

If you delete a head branch after its pull request has been merged, GitHub checks for any open pull requests in the same repository that specify the deleted branch as their base branch. GitHub automatically updates any such pull requests, changing their base branch to the merged pull request's base branch.

AWS CodeCommit's implementation of automatically closing a PR when the base branch is deleted is documented here:

CodeCommit closes a pull request automatically if either the source or destination branch of the pull request is deleted.

Unfortunately, I can't find documentation that either implementation is configurable, so it seems you won't be able to change it. If you like how GitHub does it, in AWS CodeCommit I think you'll either have to re-open the PR and change the base branch yourself, or create a new PR.

  • Related