{{ message }}
feat: add repo read-file and repo read-dir#13580
Merged
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
…ands Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces two new preview gh repo subcommands—read-file and read-dir—to fetch repository file and directory contents over the GitHub API without cloning, with support for scriptable output (--json/--jq/--template) and acceptance coverage.
Changes:
- Add
gh repo read-filefor fetching a single file’s metadata/content and optionally writing it to disk. - Add
gh repo read-dirfor listing a repository directory (TTY table / non-TTY TSV / JSON). - Add a shared
internal/text.FormatSizehelper and acceptance fixtures for both commands.
Show a summary per file
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 11/11 changed files
- Comments generated: 10
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
Author
|
I just pushed a commit to add the new commands in |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Avoids an out-of-range panic for byte counts at or above one exabyte, which fit within int64, and lets the function accept the full int64 range. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
BagToad
approved these changes
Jun 17, 2026
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
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.

Summary
This PR adds two new (preview) commands for reading repository contents without cloning.
gh repo read-fileReads a single file from a repository and writes it to stdout (or to a file with
--output).gh repo read-dirLists the entries of a directory in a repository, showing each entry's type, name, and size.
Both commands are marked preview, default to the current repository's default branch (overridable with
--ref), and support--json/--jq/--templatefor scripting.Test plan
You can verify the command behaviour via acceptance tests and the following examples.
The commands below target public repositories so they can be run as-is.
gh repo read-filegh repo read-dir