<h1 align="center">
<a href="https://prompts.chat">
Fix linting and formatting issues for a GitHub PR branch, then push the changes.
Sign in to like and favorite skills
Fix linting and formatting issues for a GitHub PR branch, then push the changes.
The $PR argument can be either:
11452)https://github.com/mastra-ai/mastra/pull/11452)First, extract the PR number if a URL was provided and get PR details:
RUN gh pr view $PR --json headRefName,headRepository,headRepositoryOwner,number,url
Extract from the JSON response:
headRefName: The branch name to checkoutheadRepositoryOwner.login: The fork owner (needed for pushing)headRepository.name: The repository nameBefore switching branches, ensure there are no uncommitted changes:
RUN git status --porcelain
If there are uncommitted changes, warn the user and ask how to proceed (stash, commit, or abort).
Fetch the PR branch and check it out. Use the branch name from Step 1:
RUN git fetch origin pull/$PR/head:
If checkout fails (e.g., branch already exists), try:
RUN git checkout
Run the formatting and linting commands to auto-fix issues:
RUN pnpm prettier:format RUN pnpm format
Check if any files were modified by the linting/formatting:
RUN git status
If there are no changes, inform the user that the branch is already properly formatted and linted, then skip to Step 7.
If there are changes, commit them. Only stage the modified files (not untracked files that may be local):
RUN git add -u RUN git commit -m "chore: fix lint and formatting issues"
Push to the contributor's fork using the owner from Step 1:
RUN git push https://github.com/
If push fails due to permissions, inform the user they may need to ask the contributor to grant push access or the contributor needs to fix lint themselves.
Switch back to the main branch:
RUN git checkout main
Inform the user whether lint fixes were pushed or if the branch was already clean.