In same repository, I'm getting multiple PRs having same merge_hash field is it possible? I want to map PRs with commits but here I'm facing issue as I can't map PRs and Commits one to one.
like
"merge_commit": {
"hash": "c444b08cb3cc",
"type": "commit"
},
Hi @Arjun Singh
Yes, it is possible and expected in certain scenarios:
When you have multiple PRs that are based on the same commit history (for example, one branch is created from another, and both have open PRs targeting the same destination branch), merging one PR can cause Bitbucket to automatically merge the other(s) if their changes are already included.
Example scenario:
You create branch1 from main and open PR1 (branch1 → main).
You create branch2 from branch1 and open PR2 (branch2 → main).
PR2 contains all the commits from PR1 plus additional ones.
When you merge PR2, Bitbucket sees that all the changes from PR1 are now in main, so it automatically marks PR1 as merged.
Both PR1 and PR2 will have the same merge_commit.hash (the commit created by merging PR2).
If a branch is rebased or force-pushed such that its changes are already present in the target branch (e.g., via another PR), Bitbucket will mark the PR as merged, and the merge commit may be the same as another PR.
Depending on the merge strategy (merge commit, squash, fast-forward), the resulting commit history can cause multiple PRs to reference the same merge commit if their changes are identical or already present.'
Hope this helps.
Cheers!
- Ben (Bitbucket Cloud Support)
I assume that the JSON snippet you pasted is part of a pull request's full JSON returned by the Bitbucket Cloud REST API.
Unfortunately, the meaning of the "merge_commit" field is not documented. But I assume that it identifies the commit created by merging the pull request. You can verify it by viewing this field on pending pull requests (where it should be missing or empty).
If my assumption is correct, then I would think that every pull request will create is own merge commit, and as commit hash is unique, the merge commit hash should be unique!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.