Skip to content

Add early check for gh default repo in gh wrapper scripts#243

Merged
arran4 merged 2 commits intomainfrom
fix-gh-repo-default-check-9894805141929727994
Mar 7, 2026
Merged

Add early check for gh default repo in gh wrapper scripts#243
arran4 merged 2 commits intomainfrom
fix-gh-repo-default-check-9894805141929727994

Conversation

@google-labs-jules
Copy link
Contributor

Added early exit conditions to executable_gh-release.sh and executable_gh-pr.sh if the GitHub CLI does not have a default repository configured (gh repo set-default). This catches the error before the script attempts to make modifications to the git repository (such as creating and pushing tags or branches), addressing the user's request. Tested via shellcheck.


PR created automatically by Jules for task 9894805141929727994 started by @arran4

Added a check to `executable_gh-release.sh` and `executable_gh-pr.sh` using `gh repo set-default --view` to ensure a default remote repository is configured before performing any git operations like creating tags or branches. This prevents scripts from failing midway when `gh` commands require a default repository context.
@google-labs-jules
Copy link
Contributor Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

exit 1
fi

if ! gh repo set-default --view > /dev/null 2>&1; then
Copy link
Owner

Choose a reason for hiding this comment

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

@jules does this only occur if it needs to be set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes! The gh repo set-default --view command only fails (returns a non-zero exit code) if a default repository hasn't been set yet. If one is already set, it successfully views it and returns 0, so the if block is skipped and the script continues.

set -eux

if ! gh repo set-default --view > /dev/null 2>&1; then
echo "X No default remote repository has been set." >&2
Copy link
Owner

Choose a reason for hiding this comment

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

@jules does this only occur if it needs to be set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes! The gh repo set-default --view command only fails (returns a non-zero exit code) if a default repository hasn't been set yet. If one is already set, it successfully views it and returns 0, so the if block is skipped and the script continues.

Added a check to `executable_gh-release.sh` and `executable_gh-pr.sh` using `gh repo set-default --view` to ensure a default remote repository is configured before performing any git operations like creating tags or branches. This prevents scripts from failing midway when `gh` commands require a default repository context.
@arran4 arran4 merged commit 1aabc2e into main Mar 7, 2026
4 checks passed
@arran4 arran4 deleted the fix-gh-repo-default-check-9894805141929727994 branch March 7, 2026 00:15
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.

1 participant