azure-devops-cli-extension
azure-devops-cli-extension copied to clipboard
Pull Request command should support creating PR from forked repo
[Edit] Converting the issue to a enhancement PR create command should support creating a new PR from a forked repo into the source repo.
Original reported issue:
I use the following command: az repos pr create -r <id_of_main_repo> -s master -t master
I get the return message The source branch, "refs/heads/master", can not be the same as the target branch.
To set the context: On devops on Azure I have a main repo of the project, and I have a forked repo of the main, which I work on.
I want to do a pull request from forked repo's master branch to the main repo's master branch. I am running the command in the folder of the GIT repo on my local machine, so I am assuming the az tool will pick up source repo's ID.
I need some guidance on my command please.
@tcheyns Sorry for the trouble you went through but creating PRs to source repo from forked repo is not supported in the PR command. I am editing this issue to track the work that needs to be done. Please follow the issue for updates.
Thanks so much for your reply.
We are also waiting for this functionality.
I tried to use az devops invoke
but cannot seem to pick the right area/resource/version to POST the request to the desired URL. As a workaround we use the REST API.
omg, are you kidding me? this is not supported .... apparently still?
@LasseNisted can you please share your workaround?
for anyone else fumbling around in the dark on this, you can do it manually w/ the API, this seems to work
Get a PAT token for your user:
curl --location --request POST 'https://dev.azure.com/TARGET_ORG/TARGET_PROJECT/_apis/git/repositories/GIT_REPO_NAME/pullrequests?supportsIterations=true&api-version=5.1' \
--header 'Authorization: Basic [BASE64 encoded <yourusername>:<yourPATtoken>]' \
--header 'Content-Type: application/json' \
--data-raw '{
"sourceRefName": "refs/heads/BRANCH_NAME_IN_THE FORK",
"targetRefName": "refs/heads/TARGET_BRANCH_NAME",
"title": "WHATEVER",
"description": "WHATEVER",
"forkSource": {
"name": "NAME_OF_FORK_REPO",
"repository": {
"id": "ID_OF_FORK_REPO"
}
}
}'
Any updates on this? An equivalent solution to the hub or gb pr create command would be highly appreciated. Thanks!