-
Notifications
You must be signed in to change notification settings - Fork 333
[WPB-23806] Opinionated script for creating wire-server PRs. #5178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Opinionated script for creating wire-server PRs. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -euo pipefail | ||
| set -x | ||
|
|
||
| # Validate arguments | ||
| if [ $# -ne 3 ]; then | ||
|
Check failure on line 7 in hack/bin/new-pr.sh
|
||
| echo "Usage: $0 <wpb-number> <changelog-category> <description>" | ||
| echo " wpb-number: just the number (e.g., 4231)" | ||
| echo " changelog-category: must be 1, 2, 3, 4, 5, or 6; selects sub-directory in ./changelog.d/" | ||
| echo " description: the changelog text (e.g., 'Fix problem with bug.')" | ||
| exit 1 | ||
| fi | ||
|
|
||
| WPB_NUMBER="$1" | ||
| CATEGORY="$2" | ||
| DESCRIPTION="$3" | ||
|
|
||
| # Validate WPB number format (should be just digits) | ||
| if ! [[ "$WPB_NUMBER" =~ ^[0-9]+$ ]]; then | ||
| echo "Error: WPB number must be numeric" | ||
|
Check warning on line 21 in hack/bin/new-pr.sh
|
||
| exit 1 | ||
| fi | ||
|
|
||
| # Validate category | ||
| if ! [[ "$CATEGORY" =~ ^[1-6]$ ]]; then | ||
| echo "Error: Category must be 1, 2, 3, 4, 5, or 6" | ||
|
Check warning on line 27 in hack/bin/new-pr.sh
|
||
| exit 1 | ||
| fi | ||
|
|
||
| # Compute branch name from description | ||
| # Remove trailing period, convert to lowercase, replace spaces with dashes, sanitize special chars | ||
| BRANCH_SUFFIX=$(echo "$DESCRIPTION" | sed 's/\.$//' | tr '[:upper:]' '[:lower:]' | sed 's/ /-/g' | sed 's/[^a-z0-9_-]/_/g') | ||
| BRANCH_NAME="WPB-${WPB_NUMBER}-${BRANCH_SUFFIX}" | ||
|
|
||
| # Step 1: Switch to develop, pull, checkout new branch | ||
| echo "Switching to develop and pulling latest changes..." | ||
| git checkout develop | ||
| git pull origin develop | ||
| git checkout -b "$BRANCH_NAME" | ||
|
|
||
| # Step 2: Create changelog entry | ||
|
|
||
| # Find the changelog directory matching the pattern | ||
| CHANGELOG_DIR=$(find ./changelog.d -type d -name "${CATEGORY}-*" | head -n 1) | ||
|
|
||
| if [ -z "$CHANGELOG_DIR" ]; then | ||
|
Check failure on line 47 in hack/bin/new-pr.sh
|
||
| echo "Error: Could not find changelog directory matching pattern ./changelog.d/${CATEGORY}-*" | ||
|
Check warning on line 48 in hack/bin/new-pr.sh
|
||
| exit 1 | ||
| fi | ||
|
|
||
| # Create changelog file with the description as-is | ||
| CHANGELOG_FILE="${CHANGELOG_DIR}/${BRANCH_NAME}" | ||
| echo "Creating changelog entry: $CHANGELOG_FILE" | ||
| echo "$DESCRIPTION" > "$CHANGELOG_FILE" | ||
|
|
||
| # Step 3: Commit the changelog | ||
| echo "Committing changelog..." | ||
| git add "$CHANGELOG_FILE" | ||
| git commit -m "Changelog." | ||
|
|
||
| # Push the branch | ||
| echo "Pushing branch to origin..." | ||
| git push -u origin "$BRANCH_NAME" | ||
|
|
||
| # Step 4: Create draft PR | ||
| PR_TITLE="[WPB-${WPB_NUMBER}] ${DESCRIPTION}" | ||
| JIRA_URL="https://wearezeta.atlassian.net/browse/WPB-${WPB_NUMBER}" | ||
|
|
||
| # Read PR template | ||
| if [ -f .github/pull_request_template.md ]; then | ||
|
Check failure on line 71 in hack/bin/new-pr.sh
|
||
| PR_TEMPLATE=$(cat .github/pull_request_template.md) | ||
| PR_BODY="${JIRA_URL} | ||
|
|
||
| ${PR_TEMPLATE}" | ||
| else | ||
| PR_BODY="$JIRA_URL" | ||
| fi | ||
|
|
||
| echo "Creating draft PR..." | ||
| gh pr create --draft --title "$PR_TITLE" --body "$PR_BODY" --head "$BRANCH_NAME" | ||
|
|
||
| echo "" | ||
| echo "Done!" | ||
| echo " Branch: $BRANCH_NAME" | ||
| echo " Changelog: $CHANGELOG_FILE" | ||
| echo " Content: $DESCRIPTION" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit worried that this will lead to very sparse PR descriptions. (Though, I've got no data to back this, of course.)
I'm wondering if it wouldn't be better to open
$EDITORhere or have that as additional option. 🤔