-
Notifications
You must be signed in to change notification settings - Fork 494
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add
gitHubReleases
and gitHubTags
Adds a feature requested in discussion #3161. - This reworks `gitHubLatestTag` to use `gitHubTags` and share the caching between the two functions. - Pagination for both (both size and page number) is not configurable. This will always return the first page of items, where the size of the page is the default specified by GitHub. That is currently thirty items, but is subject to change.
- Loading branch information
1 parent
a51179e
commit a513d19
Showing
10 changed files
with
194 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
assets/chezmoi.io/docs/reference/templates/github-functions/gitHubReleases.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# `gitHubReleases` *owner-repo* | ||
|
||
`gitHubReleases` calls the GitHub API to retrieve the first page of releases for | ||
the given *owner-repo*, returning structured data as defined by the [GitHub Go | ||
API | ||
bindings](https://pkg.go.dev/github.com/google/go-github/v53/github#RepositoryRelease). | ||
|
||
Calls to `gitHubReleases` are cached so calling `gitHubReleases` with the same | ||
*owner-repo* will only result in one call to the GitHub API. | ||
|
||
!!! example | ||
|
||
``` | ||
{{ (index (gitHubReleases "docker/compose") 0).TagName } | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
``` | ||
|
||
!!! note | ||
|
||
The maximum number of items returned by `gitHubReleases` is determined by | ||
default page size for the GitHub API. | ||
|
||
!!! warning | ||
|
||
The values returned by `gitHubReleases` are not directly queryable via the | ||
[`jq`](/reference/templates/functions/jq.md) function and must instead be | ||
converted through JSON: | ||
|
||
``` | ||
{{ gitHubReleases "docker/compose" | toJson | fromJson | jq ".[0].tag_name" }} | ||
``` |
30 changes: 30 additions & 0 deletions
30
assets/chezmoi.io/docs/reference/templates/github-functions/gitHubTags.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# `gitHubTags` *owner-repo* | ||
|
||
`gitHubTags` calls the GitHub API to retrieve the first page of tags for | ||
the given *owner-repo*, returning structured data as defined by the [GitHub Go | ||
API | ||
bindings](https://pkg.go.dev/github.com/google/go-github/v53/github#RepositoryTag). | ||
|
||
Calls to `gitHubTags` are cached so calling `gitHubTags` with the | ||
same *owner-repo* will only result in one call to the GitHub API. | ||
|
||
!!! example | ||
|
||
``` | ||
{{ (index (gitHubTags "docker/compose") 0).Name }} | ||
``` | ||
|
||
!!! note | ||
|
||
The maximum number of items returned by `gitHubReleases` is determined by | ||
default page size for the GitHub API. | ||
|
||
!!! warning | ||
|
||
The values returned by `gitHubTags` are not directly queryable via the | ||
[`jq`](/reference/templates/functions/jq.md) function and must instead be | ||
converted through JSON: | ||
|
||
``` | ||
{{ gitHubTags "docker/compose" | toJson | fromJson | jq ".[0].name" }} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Isn't second closing
}
missing?