Search code examples
gitazure-devopspull-requestgit-commitgit-push

Azure DevOps, pull requests, additional commits


Odd scenario. I created a pull request but the approver, who's on vacation, doesn't have access to approve it. I'm getting emails of new commits to the PR. It's my understanding that the post PR commits are being added to the PR, however, they are also pushed to the branch the PR is for. Is this correct in thinking that this behavior is meant to keep the PR ahead of the branch, or are does that PR prevent any new commits from pushing to the branch?

The scenario came up because I wanted to prevent anyone from accidentally pushing to our master/release branches. We have some people not paying attention to what branch they are in. It's taken up some of my time keeping our main development branch in sync/ahead of master because of it. Our solution was to require a PR if anyone tries to push to the master branch as a deterrent and alert them that they are in the wrong branch.

So the PR was one I created to test the new restriction. Not for code review. That's when the emails created confusion for some people.


Solution

  • this behavior is meant to keep the PR ahead of the branch

    A Pull Request is neither ahead of nor behind a branch. It's associated with a branch, whatever the current state of that branch may be. It's not associated with a specific commit in that branch.

    commits are being added to the PR, however, they are also pushed to the branch the PR is for

    It's the other way around. Commits are being made to the branch. The open PR will reflect those commits because those commits now exist in that branch.

    The system is simply notifying you that your PR has changed due to new commits in the branch. Which could potentially have any number of effects, including but not limited to:

    • Breaking the build in that branch, which depending on policies would either disallow completing the PR or allow it but subsequently break the build in the target of the PR.
    • Resetting any existing approvals on the PR.
    • Modifying the feature being developed in that branch (for which you may be considered responsible within the team).

    If you're making the commits and are surprised by the emails, it could just be that your understanding of Pull Requests was incorrect. If you're not making the commits and are surprised by the emails, it sounds like another team member is making changes to the same branch and you may want to communicate with that team member.