Skip to content

Instantly share code, notes, and snippets.

@dougreese
Created November 16, 2022 16:37
Show Gist options
  • Save dougreese/6f8d6f96513a74c3d21a2640861abd44 to your computer and use it in GitHub Desktop.
Save dougreese/6f8d6f96513a74c3d21a2640861abd44 to your computer and use it in GitHub Desktop.
# GitHub commands using 'hub' https://github.com/github/hub
# To use: source alias-github
# List all milestones for a repo
list-milestones() {
hub api --cache 3600 graphql -f query='
{
repository(owner: "{owner}", name: "{repo}") {
milestones(first: 100, states: OPEN, orderBy: {field:CREATED_AT, direction:DESC}) {
edges {
node {
title
number
}
}
}
}
}
' | jq -r '.data.repository.milestones.edges[].node | [.number,.title] | @tsv'
}
# List open issues for a repo
# param 1: Milestone number
# param 2: Date since
list-open-issues() {
list-issues open $1 $2
}
# List closed issues for a repo
# param 1: Milestone number
# param 2: Date since
list-closed-issues() {
list-issues closed $1 $2
}
# List issues for a repo
# param 1: Status - open or closed
# param 2: Milestone number
# param 3: Date since
list-issues() {
STATUS_PARAM="" # 1
MS_PARAM="" # 2
DATE_PARAM="" # 3
# check for status param
if [ "" != "$1" ]; then
STATUS_PARAM="-s $1"
fi
# check for milestone param
if [ "" != "$2" ]; then
MS_PARAM="-M $2"
fi
# check for date param
if [ "" != "$3" ]; then
DATE_PARAM="-d $3"
fi
hub issue $STATUS_PARAM $MS_PARAM $DATE_PARAM -f "%sC%>(8)%i%Creset %t (updated %uI)%+ Mt %U%n"
}
# List issues for a repo - brief
# param 1: Status - open or closed
# param 2: Milestone number
# param 3: Date since
list-issues-brief() {
STATUS_PARAM="" # 1
MS_PARAM="" # 2
DATE_PARAM="" # 3
# check for status param
if [ "" != "$1" ]; then
STATUS_PARAM="-s $1"
fi
# check for milestone param
if [ "" != "$2" ]; then
MS_PARAM="-M $2"
fi
# check for date param
if [ "" != "$3" ]; then
DATE_PARAM="-d $3"
fi
hub issue $STATUS_PARAM $MS_PARAM $DATE_PARAM -f "%sC%i%Creset %t%n"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment