Commit graph

212 commits

Author SHA1 Message Date
Andy Feller
41e99b9eab
Merge pull request #9934 from cli/andyfeller/cli-cli-8183-timeout-pt2
Ensure extension update notices only notify once within 24 hours, provide ability to disable all extension update notices
2025-01-13 09:12:32 -05:00
Andy Feller
3ada5af872 Enhance help docs on ext upgrade notices
- update `gh help environment` to include that upgrade notices only happen when gh or extensions are executed
- update `gh ext --help` to include reference to upgrade notices and points to `gh help environment` for info on disabling
2025-01-13 08:41:10 -05:00
Andy Feller
0a1c9be656 Expand docs on cleaning extension update dir
This summarizes a conversation within cli/cli#9934 PR regarding how the new extension update directory metadata would affect gh if not cleaned up.
2025-01-10 14:57:10 -05:00
Andy Feller
97eb8a194e Simplifying cleanExtensionUpdateDir logic
This function was doing some unnecessary heavy lifting detecting if the directory being deleted actually existed when `os.RemoveAll()` would handle directories that exist or not.
2025-01-10 14:29:55 -05:00
nobe4
69b17272d6
fix: add back colon that I removed 2025-01-10 17:17:14 +01:00
nobe4
69ab0c9c85
fix: actually read how MaxFunc work and simplify the code 2025-01-10 16:31:13 +01:00
nobe4
1899b83509
fix: padded display
Apply code suggestion from @andyfeller from:
- https://github.com/cli/cli/pull/10194#discussion_r1909761552
- https://github.com/cli/cli/pull/10194#discussion_r1909764278
2025-01-10 16:28:50 +01:00
William Martin
889c4c75f3 Collapse dryrun checks in ext bin upgrade 2025-01-10 16:06:01 +01:00
nobe4
442be87acb
Merge branch 'trunk' into fancier-extention-upgrade 2025-01-07 12:04:35 +01:00
nobe4
3b69ea6fbc
feat: make the extension upgrade fancier
This left-pad the extension names during upgrade so they all align
nicely. It makes easier to see what is happening.
2025-01-07 12:01:02 +01:00
Josh Soref
dd32a9cc94 Upgrade generated workflows
Use `cli/gh-extension-precompile@v2`

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2025-01-05 23:18:28 -05:00
Andy Feller
edc0351c85 Fix failig local extension tests
Extensions have to be gh- prefixed and these newer tests were failing because of expectation.
2024-12-13 23:20:42 -05:00
Andy Feller
bfc63a14cc Implement remaining PR feedback
After merging in upstream changes regarding local extensions, this commit addresses remaining PR feedback while also bringing the newly merged tests into alignment with other changes.
2024-12-13 23:09:18 -05:00
Andy Feller
5ad6ccf73a Merge branch 'trunk' into andyfeller/cli-cli-8183-timeout-pt2 2024-12-13 22:53:13 -05:00
Andy Feller
c12e3694e8 Implement partial feedback before trunk update 2024-12-13 22:52:03 -05:00
William Martin
46862f96d9 Reformat ext install long 2024-12-12 14:57:34 +01:00
Kynan Ware
32abca8c38 Mention Windows quirk in ext install help text 2024-12-12 06:42:34 -07:00
Kynan Ware
3b93e28910 Fix error mishandling in local ext install 2024-12-12 06:40:37 -07:00
Kynan Ware
ec4b2dfe1b Assert on err msg directly in ext install tests 2024-12-12 06:38:04 -07:00
Kynan Ware
b9b60637b9 Clarify hosts in ext install help text 2024-12-12 06:35:13 -07:00
Andy Feller
c8501d82f2
Add build constraint for non-Windows systems 2024-12-11 22:27:59 -05:00
Andy Feller
56841d9cee
Add build constraint for non-Windows systems 2024-12-11 22:25:08 -05:00
Andy Feller
52b845bcad Refactor local installation manager test by OS
- Local extensions on Windows are not symlinks but files whose contents is the path to the local extension directory
- Local extensions elsewhere are symlinks
2024-12-10 22:13:48 -05:00
Andy Feller
a6b8bec70d Remove unnecessary Extension.FullName() 2024-12-08 21:17:26 -05:00
Andrew Feller
a55f50b115 Remove Extension.FullName() from interface
- this was something I did in the original implementation of this improved extension update notification logic
- discovering other parts of the extension manager code that were working with non-prefixed extension names motivated a different approach
- the extension manager code that requires the extension be prefixed has been enhanced to use the centralized ensurePrefixed() logic, making the need for this on the extension unnecessary
2024-12-08 20:01:26 -05:00
Andrew Feller
97630fe73c Enhance extension manager and tests
- extension manager has been made responsible for extension update directory information
- extension manager has been enhanced to ensure that previously left extension update metadata is deleted before installing an extension
- extension manager has been enhanced to ensure that extension update metadata is deleted when extension is being removed
- refactored extension command tests for manager change, ensuring previous and expected states along with returned release info
- refactored extension manager tests for ensuring previous extension update entries are removed before installing extension
- created extension manager test for installing local extension
- centralized logic for checking and ensuring extension name is "gh-" prefixed
2024-12-08 19:40:24 -05:00
Kynan Ware
b2ab7b84f8 Refactor extension executable error handling 2024-12-08 15:55:09 -07:00
Andrew Feller
6bd01d52dd Initial extension update check testing
First pass at implementing basic test around extension state checking behavior, wanting to discus with team about level of testing to perform and whether this is really the right place.
2024-12-01 18:20:55 -05:00
bagtoad
b5f3463b75 Improve error handling for missing executable
Check for executable file existence using os.IsNotExist for clearer error handling
2024-11-20 16:03:03 -07:00
bagtoad
e5eedefd09 Assert stderr is empty in manager_test.go 2024-11-19 16:42:16 -07:00
bagtoad
83c5bf3589 Update error message wording 2024-11-19 16:42:15 -07:00
bagtoad
4b73e55fd2 Change: exit zero, still print warning to stderr
Instead of returning `ErrExtensionExecutableNotFound` error which causes `gh` to have a non-zero exit code, catch it and print the message to stderr, returning nil. Only print the warning to stderr when there is a TTY.
2024-11-19 16:42:15 -07:00
Kynan Ware
1bc2bb8059
Improve docs on installing extensions
Better clarify the two extension types in the `extension install` docs.

Co-authored-by: Tyler McGoffin <jtmcg@github.com>
2024-11-18 16:45:57 -07:00
Kynan Ware
bb3b64ad06
Update language for missing extension executable
Co-authored-by: Tyler McGoffin <jtmcg@github.com>
2024-11-18 16:25:07 -07:00
Kynan Ware
2ec27ff9fe
Update test comments about Windows behavior
Co-authored-by: Tyler McGoffin <jtmcg@github.com>
2024-11-18 16:21:14 -07:00
bagtoad
c5497b4d28 Document requirements for local extensions 2024-11-17 21:01:49 -07:00
bagtoad
b575fe8ebc Warn when installing local ext with no executable 2024-11-17 21:01:49 -07:00
Andy Feller
0d3f7cae4e Bring extension update check in line with gh check
This commit is a bit of refactoring to bring the extension update checking logic up to par with what is done with `gh` including creation of state file per extension and listening to env vars for disabling version checking.

This work is not complete as it does not address necessary test changes.
2024-11-17 16:10:58 -05:00
bagtoad
daec7a0e0e Check extOwner for no value instead 2024-10-21 13:28:37 -06:00
bagtoad
35aa8521c4 Fix tests for invalid extension name 2024-10-21 12:47:14 -06:00
bagtoad
cc32f33583 Refactor to remove code duplication 2024-10-21 12:37:27 -06:00
bagtoad
6923fb5cc8 add validation for local ext install 2024-10-20 16:37:40 -06:00
Tim Rogers
1eda1b41a7
Emit a log message when extension installation falls back to a darwin-amd64 binary on an Apple Silicon macOS machine 2024-09-21 14:56:43 -05:00
Tim Rogers
665e41566f
Fix test 2024-09-18 19:07:32 +01:00
Tim Rogers
195188cee8
Update pkg/cmd/extension/manager.go
Co-authored-by: Tyler McGoffin <jtmcg@github.com>
2024-09-18 18:55:20 +01:00
Tim Rogers
81d57a0643 Improve error presentation 2024-09-18 14:00:36 +01:00
Tim Rogers
dded039125 Improve the suggested command for creating an issue when an extension doesn't have a binary for your platform
When installing an extension, the CLI must to select the correct
binary to download for the machine (see the
[`installBin` function](78c1d00ecc/pkg/cmd/extension/manager.go (L240))).

By default, the CLI will download a binary matching the current
machine's architecture.

If a suitable binary isn't available, the CLI
[outputs an error](78c1d00ecc/pkg/cmd/extension/manager.go (L278)),
directing the user to create an issue on the extension's
repository:

```go
if asset == nil {
	return fmt.Errorf(
		"%[1]s unsupported for %[2]s. Open an issue: `gh issue create -R %[3]s/%[1]s -t'Support %[2]s'`",
		repo.RepoName(), platform, repo.RepoOwner())
}
```

The issue this creates isn't very clear or helpful. It isn't
obvious where it is coming from, or what you need to do.

This improves the suggested command, adding a better title
to the issue and an explanatory body.

To test this, try installing my
`timrogers/gh-extension-without-binary` extension, which only has
an esoteric `linux-ppc64` binary 😸:

```bash
gh extension install timrogers/gh-extension-without-binary
```

You'll get a nice output like this:

```
gh-extension-without-binary unsupported for darwin-arm64. Open an issue: `gh issue create -R timrogers/gh-extension-without-binary --title "Add support for the darwin-arm64 architecture" --body "This extension does not support the darwin-arm64 architecture. I tried to install it on a darwin-arm64 machine, and it failed due to the lack of an available binary. Would you be able to update the extension's build and release process to include the relevant binary? For more details, see <https://docs.github.com/en/github-cli/github-cli/creating-github-cli-extensions>."`
```

...which produces an issue like
https://github.com/timrogers/gh-extension-without-binary/issues/4.

I have tested the resulting command on macOS and Windows, so
I am confident that it has *at least reasonable* cross-platform
support.

Fixes https://github.com/cli/cli/issues/9600.
2024-09-18 14:00:36 +01:00
William Martin
99b789e745 Add test for extension install fallback to amd64 on darwin 2024-09-13 11:59:54 +02:00
William Martin
e0fb793b44 Stub hasRosetta for tests 2024-09-12 13:56:19 -06:00
Tim Rogers
5296d60832
Refactor conditions
Co-authored-by: Andy Feller <andyfeller@github.com>
2024-09-12 18:53:24 +01:00