Conversation
pkg/cmd/repo/list/list.go
Outdated
| if notArchived && repo.IsArchived { | ||
| matchCount-- | ||
| listResult.TotalCount-- | ||
| continue |
There was a problem hiding this comment.
When doing gh repo list --fork or gh repo list --source, don't list archived repos.
This mimics the way GitHub does filter repos in the web UI.
|
@cristiand391 Thanks for picking this up! This looks great already. I'm going to suggest some output tweaks that are different from the design spec you were working off of, and ask input from my team to see if any of this resonates with them:
|
I'm honestly agnostic on this one! If there's no strong push for it, I'm fine to punt on it.
I don't feel super strongly about this either. But, even for programatic use cases, I can imagine if you archive a repository, it might be a lot of clutter to see them showing up in lists by default? And as a get around, wouldn't passing both
I like this change! 👍 |
+1. I definitely don't think this is needed unless we actually see some significant demand for it.
I have no strong opinions about this either. Honestly I don't think it matters that much, and therefore would opt to mirror what dotcom does, especially since that helps reduce clutter as @ampinsk pointed out.
This is 💯 |
|
@mislav I've added some tests and pushed some changes to address suggestions. |
Also order results by PUSHED_AT instead of UPDATED_AT to match the web interface.
Dynamically construct the GraphQL query by using the `viewer` connection if the owner isn't set and the `repositoryOwner(login:"...")` connection if the owner was set.
There was a problem hiding this comment.
Thank you for all your work!
I've pushed changes to:
- Avoid having to separately request the current username when owner isn't specified via argument;
Remove all logic that filters out archived repos, since this level of filtering isn't supported in the API layer;- Sort the returned results by
PUSHED_ATinstead ofUPDATED_ATto match the web interface; - Enable the pager for tty output.
|
Feature request: filtering by language. set -e
repos() {
local owner="${1?}"
shift 1
gh api graphql --paginate -f owner="$owner" "$@" -f query='
query($owner: String!, $per_page: Int = 100, $endCursor: String) {
repositoryOwner(login: $owner) {
repositories(first: $per_page, after: $endCursor, ownerAffiliations: OWNER) {
nodes {
nameWithOwner
description
primaryLanguage { name }
isFork
pushedAt
}
pageInfo {
hasNextPage
endCursor
}
}
}
}
' | jq -r '.data.repositoryOwner.repositories.nodes[] | [.nameWithOwner,.pushedAt,.description,.primaryLanguage.name,.isFork] | @tsv' | sort
}
repos "$@" |
|
@data-man That's an excellent suggestion. Added! Note that for filtering by language, we have to turn to the |
Like `--language`, archived filters also use the Search API.
|
Proposals: |
|
@data-man Thanks, but I do not think that every long flag needs to have a shorthand. In particular, |
|
It would be nice to show a primary language as well. |
Closes #642
This PR adds support for listing repositories of a user or organization, some examples:
TTY Output

Non-TTY Output

UI Spec: https://docs.google.com/document/d/1QoktdMTS8FEXYLH_1WvzZe_OoGV_ZiTxf0c3QVF1soY/edit#