From 89a413b8f1d60e6db53aa9e6b3cd78f287ec69f2 Mon Sep 17 00:00:00 2001 From: Owen Gretzinger Date: Mon, 14 Jul 2025 17:46:38 -0400 Subject: [PATCH] chore: pr script (#8) --- solo-pr.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 solo-pr.sh diff --git a/solo-pr.sh b/solo-pr.sh new file mode 100755 index 0000000..7548645 --- /dev/null +++ b/solo-pr.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +# Usage: ./solo-pr.sh "Your commit message here" + +COMMIT_MSG=$1 + +if [ -z "$COMMIT_MSG" ]; then + echo "Usage: ./solo-pr.sh \"Commit message\"" + exit 1 +fi + +# Check for staged changes +if ! git diff --cached --quiet; then + : +else + echo "No staged changes to commit. Please stage your changes before running this script." + exit 1 +fi + +# Step 1: Generate branch name from commit message +BRANCH_NAME=$(echo "$COMMIT_MSG" \ + | tr '[:upper:]' '[:lower:]' \ + | sed -E 's/[^a-z0-9]+/-/g' \ + | sed -E 's/^-+|-+$//g' \ + | cut -c1-50) # Limit to 50 chars + +echo "Creating branch: $BRANCH_NAME" + +# Step 2: Create new branch and commit +git checkout -b "$BRANCH_NAME" +# git add . # we will manually add files so that we only commit the changes we want +git commit -m "$COMMIT_MSG" + +# Step 3: Push branch +git push -u origin "$BRANCH_NAME" + +# Step 4: Create PR +gh pr create --title "$COMMIT_MSG" --body "$COMMIT_MSG" --base main --head "$BRANCH_NAME" + +# Step 5: Merge PR +gh pr merge "$BRANCH_NAME" --squash --delete-branch + +# Step 6: Return to main and pull +git checkout main +git pull origin main