diff --git a/create-pr.sh b/create-pr.sh new file mode 100755 index 0000000..11ccae6 --- /dev/null +++ b/create-pr.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash +# Creates a PR from the current branch targeting this repo's master branch. +# Usage: ./create-pr.sh [title] [body] +# If title/body are omitted, they are derived from the branch name and commit log. + +set -euo pipefail + +REPO="TheJavaGuy/java-faker" +BASE="master" +BRANCH=$(git rev-parse --abbrev-ref HEAD) + +if [[ "$BRANCH" == "$BASE" ]]; then + echo "Error: already on $BASE — create a feature branch first." >&2 + exit 1 +fi + +# Use provided title or derive from branch name (kebab-case → sentence) +TITLE="${1:-$(echo "$BRANCH" | tr '-' ' ')}" + +# Use provided body or build from commits since master +if [[ $# -ge 2 ]]; then + BODY="$2" +else + COMMITS=$(git log "$BASE".."$BRANCH" --oneline) + BODY="$(cat <