If the context is GitHub (https://github.com/user/myapp-repo.git#pull/<PR_ID>/head), acb download works fine to fetch and check out PR #. However, if the context is AzureDevOps (https://dev.azure.com/user/myproject/_git/myapp-repo#pull/<PR_ID>/head), acb download checks out the wrong codebase.
Root Cause
Briefly explaining how acb download works: it initially establishes a connection to the remote repository
If the preceding command fails, it subsequently executes
git fetch origin
Finally, it checks out the fetched latest commit
git checkout FETCH_HEAD
If the remote repository is an AzureDevOps repository, executing git fetch origin pull/<PR_ID>/head will result in the error message fatal: couldn't find remote ref pull/<PR_ID>/head. Therefore, acb download mistakenly checks out the most recent commit in the repository instead of the desired pull request.
Fix
For GitHub, the pull request reference is pull/<PR_ID>/head, but for AzureDevOps, the pull request reference is actually pull/<PR_ID>/merge. (I learned about it from ChatGPT, and later I found this StackOverflow post discussing it; however, there is no official documentation available.) The pull request reference differs from providers. FYI, for GitLab, it should be merge-requests/<PR_ID>/head.
Describe the bug
If the context is GitHub (. However, if the context is AzureDevOps (
https://github.com/user/myapp-repo.git#pull/<PR_ID>/head
),acb download
works fine to fetch and check out PR #https://dev.azure.com/user/myproject/_git/myapp-repo#pull/<PR_ID>/head
),acb download
checks out the wrong codebase.Root Cause
Briefly explaining how
acb download
works: it initially establishes a connection to the remote repositoryThen, it tries
If the preceding command fails, it subsequently executes
Finally, it checks out the fetched latest commit
If the remote repository is an AzureDevOps repository, executing
git fetch origin pull/<PR_ID>/head
will result in the error messagefatal: couldn't find remote ref pull/<PR_ID>/head
. Therefore,acb download
mistakenly checks out the most recent commit in the repository instead of the desired pull request.Fix
For GitHub, the pull request reference is
pull/<PR_ID>/head
, but for AzureDevOps, the pull request reference is actuallypull/<PR_ID>/merge
. (I learned about it from ChatGPT, and later I found this StackOverflow post discussing it; however, there is no official documentation available.) The pull request reference differs from providers. FYI, for GitLab, it should bemerge-requests/<PR_ID>/head
.