Skip to content
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

Add --dry-run to preview changes to PR #26

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ release *OPTIONS:
git-check --check-repo=1 {{SETUP_BEND_PATH}}; \
make-release {{OPTIONS}}

# Set milestone for PR in dry-run mode
dry-run *OPTIONS:
@overlay use {{ join(SETUP_BEND_PATH, 'nu', 'milestone.nu') }}; \
milestone-update --dry-run {{OPTIONS}}

# Plugins need to be registered only once after nu v0.61
_setup:
@register -e json {{ join(NU_DIR, _query_plugin) }}
15 changes: 12 additions & 3 deletions nu/milestone.nu
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,26 @@ export def 'milestone-update' [
--milestone(-m): string, # Milestone name
--pr: string, # The PR number/url/branch of the PR that we want to add milestone.
--force(-f), # Force update milestone even if the milestone is already set.
--dry-run(-d), # Dry run, only print the milestone that would be set.
] {
if not (is-installed 'gh') {
print 'gh command not found, please install it first, see: https://cli.github.com/.'
exit $ECODE.MISSING_BINARY
}
if ($gh_token | is-not-empty) { $env.GH_TOKEN = $gh_token }
let selected = if ($milestone | is-empty) { guess-milestone $repo $pr } else { $milestone }
if $force { gh pr edit $pr --repo $repo --remove-milestone }
print $'(char nl)Setting milestone to (ansi p)($selected)(ansi reset) for PR ($pr) in repository ($repo)...'
if $force {
if $dry_run {
print $'(char nl)Would remove milestone for PR (ansi p)($pr)(ansi reset) in repository (ansi p)($repo)(ansi reset) ...'
} else {
gh pr edit $pr --repo $repo --remove-milestone
}
}
print $'(char nl)Setting milestone to (ansi p)($selected)(ansi reset) for PR (ansi p)($pr)(ansi reset) in repository (ansi p)($repo)(ansi reset) ...'
# FIXME: GraphQL: Resource not accessible by integration (updatePullRequest)
gh pr edit $pr --repo $repo --milestone $selected
if not $dry_run {
gh pr edit $pr --repo $repo --milestone $selected
}
}

# Guess milestone by the merged date of the PR and the infomation of open milestones.
Expand Down