Skip to content

fix: make number arg, commit arg, and flags mutually exclusive#7268

Merged
samcoe merged 2 commits intocli:trunkfrom
kkocha:fix/browse-commit-branch
Apr 4, 2023
Merged

fix: make number arg, commit arg, and flags mutually exclusive#7268
samcoe merged 2 commits intocli:trunkfrom
kkocha:fix/browse-commit-branch

Conversation

@kkocha
Copy link
Contributor

@kkocha kkocha commented Apr 3, 2023

Fixes #7266

@kkocha kkocha requested a review from a team as a code owner April 3, 2023 13:54
@kkocha kkocha requested review from vilmibm and removed request for a team April 3, 2023 13:54
@cliAutomation cliAutomation added the external pull request originating outside of the CLI core team label Apr 3, 2023
Comment on lines +116 to +118
"specify only one of `number arg`, `commit SHA arg`, `--branch`, `--commit`, `--projects`, `--releases`, `--settings`, or `--wiki`",
isNumber(opts.SelectorArg),
isCommit(opts.SelectorArg),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this error message and error condition is getting quiet long and convoluted. I would rather see this new error condition broken out into its own check with a nicer error message for the user. Something like:

      if (isNumber(opts.SelectorArg) || isCommit(opts.SelectorArg)) && (opts.Branch != "" || opts.Commit != "") {
        return cmdutil.FlagErrorf("%q is an invalid argument when using `--branch` or `--commit`", opts.SelectorArg)
      }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would make for a nicer experience and i hastily reviewed before seeing sam's comment; I'm +1 on this change before merging.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for review.
Indeed, I broke the condition into the args own.

@samcoe samcoe self-assigned this Apr 4, 2023
Copy link

@moama11 moama11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[](get free configuration )

Copy link
Contributor

@samcoe samcoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kkocha Thanks for making the requested changes! This looks ready to 🚢

@samcoe samcoe merged commit 1263412 into cli:trunk Apr 4, 2023
@kkocha kkocha deleted the fix/browse-commit-branch branch April 4, 2023 06:40
jtpetty pushed a commit that referenced this pull request May 22, 2023
* make number, commit, and flags mutually exclusive

* break condition into arg own check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external pull request originating outside of the CLI core team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gh browse <commit SHA or number> with --branch flag generates invalid URLs

5 participants