[gh release create/upload] Expand glob patterns for all platforms - #10413
#10413[gh release create/upload] Expand glob patterns for all platforms#10413jtmcg merged 10 commits intocli:trunkcli/cli:trunkfrom iamazeem:5099-gh-release-create-upload-expand-glob-patterns-on-windowsiamazeem/cli:5099-gh-release-create-upload-expand-glob-patterns-on-windowsCopy head branch name to clipboard
Conversation
jtmcg
left a comment
There was a problem hiding this comment.
Coming in with another blast from the past! We appreciate all the work you're putting in, @iamazeem 🙌
I reviewed the old issue and I think there was just a bit more to do from there than is delivered in this PR. I've added Acceptance Criteria to it so we can more easily track what needs doing. Let me know if you have any questions.
tl;dr: We want to expand wildcards for ALL platforms using gh and we want this to happen in gist create and release create in addition to what you've done here for release upload. I suspect its not too much more effort for those, given the solution you've outlined here 🙂
Also, if you haven't already come to expect it from me by now, I'm going to ask for some tests 😅
As mentioned in the PR description, it's only needed for Windows.
Sure, I'll add its support for
Actually, I thought about how to approach these tests and then decided not to. |
|
|
@jtmcg: Please review. Thanks! |
…atterns-on-windows
Totally. There may be a good reason to also handle other os's explicitly in the CLI, though... Not sure what they are at the moment, but I'll think on this and get back to you on it 👍 If you can think of any reasons for or against it, I'm all ears, too
Sure thing! I'll take a look and add a PR into your feature branch for it if I can find a solution |
On nix shells, the expansions happen when args are in double quotes e.g. |
There was a problem hiding this comment.
Great, so here's where we're at:
- We want to handle all globbing ourselves, regardless of shell
- We want to error if a glob pattern doesn't find any matches. This error should contain ALL patterns that don't have matches and not just the first that didn't match. Perhaps this suggests a new bespoke error type?
Does this make sense?
jtmcg
left a comment
There was a problem hiding this comment.
Looking good. I like how clean this reads, now! Have a couple of questions, though
…atterns-on-windows
…mers (#3) * Separate partitioning from globbing in cmdutil/args package and consumers In the previous commit, GlobPaths was overloaded, containing logic specific to command use-cases. This commit removes that functionality from GlobPaths and back into the commands that have the special use-cases. To do this, I've introduced a new Partition util in cmdutil/args.go that will separate a slice into two slices given a predicate. This functionality is leveraged by both the special use-cases described above to separate the command-specific syntax from the globable filepaths. * Add test to validate that the order of '-' in gh gist create args doesn't matter
This comment was marked as spam.
This comment was marked as spam.
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [cli/cli](https://github.com/cli/cli) | minor | `v2.68.1` -> `v2.69.0` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>cli/cli (cli/cli)</summary> ### [`v2.69.0`](https://github.com/cli/cli/releases/tag/v2.69.0): GitHub CLI 2.69.0 [Compare Source](cli/cli@v2.68.1...v2.69.0) #### What's Changed ##### Features - Commands that accept filepath arguments will do glob expansion for `*` characters, by [@​iamazeem](https://github.com/iamazeem) in cli/cli#10413 ##### Bug Fixes - `gh issue/pr comment --edit-last` no longer creates a comment in non-interactive mode if there weren't one. A new flag `--create-if-none` provides this behaviour, by [@​andyfeller](https://github.com/andyfeller) in cli/cli#10625 - `gh repo sync` provides a more informative error for missing workflow permissions when the token is provided by a GitHub app, by [@​wata727](https://github.com/wata727) in cli/cli#10574 - `gh api` no longer tries to encode URLs incorrectly, by [@​williammartin](https://github.com/williammartin) in cli/cli#10630 ##### Other - Add cli-discuss-automation environment to triage.md by [@​jtmcg](https://github.com/jtmcg) in cli/cli#10552 - chore: remove redundant word in comment by [@​kevincatty](https://github.com/kevincatty) in cli/cli#10586 - Bump golang.org/x/net from 0.34.0 to 0.36.0 by [@​dependabot](https://github.com/dependabot) in cli/cli#10593 #### New Contributors - [@​kevincatty](https://github.com/kevincatty) made their first contribution in cli/cli#10586 - [@​wata727](https://github.com/wata727) made their first contribution in cli/cli#10574 **Full Changelog**: cli/cli@v2.68.1...v2.69.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4yMTMuNSIsInVwZGF0ZWRJblZlciI6IjM5LjIxMy41IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
Fixes #5099.
Verified that this issue is only applicable to Windows Command Prompt and Powershell.
See this relevant SO thread for more details.
GitBash behaves same as a Linux shell.
This issue affects
gh release createandgh release uploadcommands.In this PR, the glob patterns are expanded internally for Windows.
Tests (same for Windows Command Prompt and Powershell)
Invalid patterns
Notes
gh.'test.*'is passed as-is and cannot be expanded.Error on Command Prompt
UPDATE
After discussions, the support for glob patterns has been added for all the platforms.