Azure-devops-cli-extension: [Feature Request]: Create draft PR in Azure Repos

Created on 18 Feb 2019  路  8Comments  路  Source: Azure/azure-devops-cli-extension

Is your feature request related to a problem? Please describe.
I want to create a PR in draft.

Describe the solution you'd like
A clear and concise description of what you want to happen.
e.g. If you want a new command to be added, what would it do?

Additional context
Add any other context or screenshots about the feature request here.

planned Feature

Most helpful comment

This is dependent on an API version step up and will be halted till then.

All 8 comments

This is dependent on an API version step up and will be halted till then.

@geverghe For approach sign off:

Command to create a PR in draft mode: az repos pr create --is-draft + other params as is
--is-draft : Use this flag to create the pull request in draft/work in progress
mode.

Command to update a PR:
az repos pr update --id 123 --is-draft true
az repos pr update --id 123 --is-draft false

--is_draft: Publish the PR or convert to draft mode.

Change in table output:
image

seems a bit odd that in output we are translating something like
isdraft==false ==> published
isdraft==true ==> isDraft

also looking at json response I think we only have isDraft in the body. So then why not have only --is-draft as an option and user can pass True/ False for update?

cc: @geverghe @atbagga

Updated the proposal comment as per Gaurav's Suggestion above.

@geverghe
The concern here is that --is-draft is a flag in create PR like --open and other flags in create whose presence/absence signifies true or false instead of explicit value.
In update command it is string which can be true or false.

Reasoning: Create Pr has multiple other boolean flags so --is-draft being a bool is consistent in the command scope.
Why can't we have same in update PR command? Because then --is-draft will have a default value and it will become compulsory for user to provide it during every update so we do not override the current state of PR with the default value. e.g. A PR is published and I want to update the title. In the command --is-draft is true by default.
The command az repos pr update --title "abc" should have sufficed but this will change my PR to draft mode.

Apologies for not responding earlier. Think I am hitting some rule exception in my email and this didn't come into my attention.

This issue was brought up earlier as well and the guidance provided by Azure CLI is - https://github.com/Azure/azure-cli/blob/dev/doc/authoring_command_modules/authoring_commands.md#registering-flags

This means that non mandatory boolean attributes have three states - true, false and not set. When this model was first proposed, the feedback was that the implementation was presence indicated true and non-presence false. This is not the case. There are three states and we should be following this guideline. Therefore, for this scenario, it should ideally be:

  1. az repos pr --draft - Indicates PR should be set as draft
  2. az repos pr --draft true - Indicates PR should set as draft
  3. az repos pr - Indicates that there is no mention of draft and therefore this attribute is never set.
  4. az repos pr --draft false - There is explicit intent to set as false.

Now in case of mandatory boolean attributes, then presence and non presence equates to true /false. However, this does not mean users cannot provide the explicit intent via value as well. Consider draft was a mandatory variable - even then we need to support all of the following:

  1. az repos pr --draft - Indicates PR should be set as draft
  2. az repos pr --draft true - Indicates PR should set as draft
  3. az repos pr - Indicates PR should not be set as draft
  4. az repos pr --draft false - Indicates PR should not be set as draft.

Let me know your thoughts on this. We should agree on a standard and move forward. Otherwise, commands within our own extension will be inconsistent.

Sounds Good. Fixed in PR #542

This will be available in the next release. 0.5.0

Was this page helpful?
0 / 5 - 0 ratings