Skip to content

feat(gh): list my stars #1109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions custom-completions/gh/gh-completions.nu
Original file line number Diff line number Diff line change
Expand Up @@ -568,3 +568,37 @@ export def "gh pr view inlined-comments" [
| select user.login body diff_hunk
| rename user comment diff )
}

def "gh get stars" [
end_cursor: string = "" # endCursor from a previous query
--first: int = 100 # returns the first n elements from the list
] {
# https://docs.github.com/en/graphql/reference/objects#user
^gh api graphql -F $'first=($first)' -F $'endCursor=($end_cursor)' -f query='
query($first: Int, $endCursor: String!){
viewer {
starredRepositories(first: $first, after: $endCursor, orderBy: {field: STARRED_AT, direction: DESC}) {
edges { node { url description } starredAt }
pageInfo { hasNextPage endCursor }
}
}
}
'
| from json | select data.viewer.starredRepositories.edges data.viewer.starredRepositories.pageInfo
| rename stars pageInfo
}

export def "gh my stars" [] {
mut stars = []
mut end_cursor = ""
loop {
let $part = gh get stars $end_cursor
$stars = $stars | append $part.stars
if $part.pageInfo?.hasNextPage? == true {
$end_cursor = $part.pageInfo.endCursor
} else {
break
}
}
$stars | flatten | update cells --columns [starredAt] {$in| date humanize} | sort-by starredAt
}