Allow listing merged PRs by milestone (#773)

Also changes `date?` parameter to `--date` and slight code refactoring
This commit is contained in:
Jakub Žádník 2024-03-05 22:27:30 +02:00 committed by GitHub
parent bccdab661a
commit 351691f118
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -11,21 +11,38 @@ def md-link [
# list all merged PRs since last release
export def main [
repo: string # the name of the repo, e.g. `nushell/nushell`
date?: datetime # the date of the last release (default to 4 weeks ago, excluded)
--date: datetime # the date of the last release (default to 4 weeks ago, excluded, if no milestone is set)
--milestone: string # search PRs by milestone
--label: string # the label to filter the PRs by, e.g. `good-first-issue`
--pretty # pretty-print for the MarkDown release not
--no-author # do not group the contributions by author
] {
let date = $date | default ((date now) - 4wk) | format date "%Y-%m-%d"
mut query_parts = []
let since = (date now | format date %F | into datetime) - ($date | into datetime)
log info $"listing PRs in ($repo) since ($date) \(($since) ago\)"
let query = if $label == null {
$"merged:>($date)"
let date = if $date == null and $milestone == null {
(date now) - 4wk
} else {
$"merged:>($date) label:($label)"
$date
}
| format date "%Y-%m-%d"
if $date != null {
let since = (date now | format date %F | into datetime) - ($date | into datetime)
log info $"listing PRs in ($repo) since ($date) \(($since) ago\)"
$query_parts ++= [ $"merged:>($date)" ]
}
if $milestone != null {
log info $"listing PRs in milestone ($milestone)"
$query_parts ++= [ $'milestone:"($milestone)"' ]
}
if $label != null {
log info $"listing PRs with label ($label)"
$query_parts ++= [ $'label:($label)' ]
}
let query = $query_parts | str join ' '
let prs = (
gh --repo $repo pr list