Skip to content

Enable closing pr during resetting and re-downloading#75

Open
desmondwong1215 wants to merge 7 commits intogit-mastery:mainfrom
desmondwong1215:infra/auto-closing-pr
Open

Enable closing pr during resetting and re-downloading#75
desmondwong1215 wants to merge 7 commits intogit-mastery:mainfrom
desmondwong1215:infra/auto-closing-pr

Conversation

@desmondwong1215
Copy link
Copy Markdown
Contributor

All open pr by the user will be closed during resetting and re-downloading.

VikramGoyal23
VikramGoyal23 previously approved these changes Apr 6, 2026
Copy link
Copy Markdown
Contributor

@VikramGoyal23 VikramGoyal23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Comment on lines +207 to +221
[
"gh",
"pr",
"list",
"--repo",
repo,
"--author",
username,
"--state",
"open",
"--json",
"number",
"--jq",
".[].number",
],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only fetches the first 30 PRs, and while technically the better option would be to add a flag of the form --limit 9999999 for edge cases, it is extremely unlikely the user will ever open >30 PRs on their repo (unless done deliberately). So it may be fine to leave it this way.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for automatically closing a user’s open pull requests during exercise reset and re-download workflows, using GitHub CLI, and persists PR-related metadata in the exercise config to drive that behavior.

Changes:

  • Introduce close_pr() helper in app/utils/github_cli.py to close all open PRs authored by the current user in a given repo.
  • Extend ExerciseRepoConfig to include pr_number and pr_repo_full_name, and read them from .gitmastery-exercise.json.
  • Invoke PR-closing during progress reset and when re-downloading over an existing exercise directory.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
app/utils/github_cli.py Adds GH CLI helper to list and close open PRs authored by the user.
app/configs/exercise_config.py Adds PR metadata fields to exercise repo config and reads them from JSON.
app/commands/progress/reset.py Closes open PRs (when configured) before deleting the fork during reset.
app/commands/download.py Attempts to close PRs from a prior exercise config when re-downloading over an existing directory.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants