Conversation
Commands reach the issue artifacts REST API through the ArtifactClient interface, so their tests can use the generated moq mock, as gh discussion does. List asks for pages of up to 100 artifacts until one comes back short. Every request uses the same page size, so page numbers stay aligned when the limit is above 100.
gh issue artifact is a new command group, in preview, for the Markdown documents and links attached to an issue. It starts with list. gh treats generic and plan artifacts alike as documents, so --type generic and --type plan list both, merged in number order. Without a total count from the API, the header counts the artifacts shown.
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of the pull request stack tracked in #14563.
This adds the
gh issue artifactcommand group from #14529, with its first command,list, from #14523.Description
Issue artifacts are Markdown documents and links attached to an issue. Each one has a number on its issue, a name and a type.
genericandplanartifacts are documents, andlinkartifacts are links. They aren't GitHub Actions artifacts, whichgh run downloadhandles.This adds
gh issue artifact, a new command group undergh issue. Likegh discussion, it's in preview. Its first command lists the artifacts on an issue:gh issuecommands.listshows every artifact, in number order.--limitstops after that many.--typefilters by type.--type genericand--type planboth list every document, since gh treats the two types alike.--jsonexports every field the API returns.listuses the pager, likegh issue list.--jsonoutput never pages, likegh discussion list.--attach's.Two packages support this and the commands that follow in the stack:
ArtifactClientinterface, its REST implementation and a generatedmoqmock, like thegh discussionclient. Commands reach the API only through it.How did you test this change?
I recorded the built
ghlisting artifacts in bagtoad/issue-artifacts-demo: the table,--limit,--type genericwith a plan, piped output,--json, an issue with no artifacts and a pull request, withGH_DEBUG=1showing the requests. It leaves out issue URL arguments, GitHub Enterprise Server and API errors.recording.mp4
Open chapters and agent notes
Key points
The header counts only what's shown. [Design]
gh issue artifact list#14523 shows "Showing 3 of 3 artifacts", which needs a total count. The API returns none, so the header says "Showing 3 artifacts on monalisa/monas-cafe#142". With--type, it ends with "that match your search", as in [Design]gh issue artifact list#14523.No
urlfield yet. List responses don't include an artifact URL today, sourlisn't among the--jsonfields. A later pull request in this stack will add it.Both document types are fetched and merged. In [Design]
gh issue artifact list#14523,--type genericalso lists plans, and--type planalso lists generic artifacts. Each request filters on one type on the server, so either value asks for both types, up to the limit, then merges them inlistArtifacts:Rows keep their stored type, so a plan still shows
plan.Every page has the same size. Each request asks for the smaller of
--limitand 100, and pages continue until one comes back short. Pages are numbered, so changing the size partway would shift them.--limit 150asks for 100 twice and keeps 150, likegh cache list.The pull request check reuses
gh issue delete's lookup. The issue lookup runs once, behind the client interface, so command tests use the mock.Placement.
artifactsits under "Targeted commands" ingh issue --help, asdeploy-keyandautolinkdo undergh repo. It inherits-Rfromgh issue.Unlimited by default.
--limithas no default in the help, and every artifact is listed.--limit 0is a flag error, "invalid limit: 0", likegh issue list.Notes for reviewers
Start with the
listrun function, which shows the order of the checks and the output paths. Then read the client'sList, which pages, and the shared checks.TestListRunhas a row for each output rule, including a stored type gh doesn't know.TestListcovers paging, with each request URL asserted.gh issue artifact list#14523 is thelistdesign, with a screen for each scenario.gh issue artifact#14529 holds the rules shared by everygh issue artifactcommand, such as the issue argument, pull requests and hosts.Authorship and follow-up
Who wrote this:
Who answers review comments: