Skip to content

Instantly share code, notes, and snippets.

@peterwilsoncc
Last active July 25, 2023 03:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterwilsoncc/eb93b5c5faec599b96b2741f176665ce to your computer and use it in GitHub Desktop.
Save peterwilsoncc/eb93b5c5faec599b96b2741f176665ce to your computer and use it in GitHub Desktop.
Backport a WP commit without having to check out the entire repo.
#!/bin/bash
# Use:
# backport.sh 12345
#
# Based on https://gist.github.com/johnbillion/22dcc4ae736a3e8d022c
# Modifications
# - Uses the format recommended in the handbook
# - Pulls the current branch from `svn info` rather than using the directory basename
#
# Note: The commit message created will need some edits:
# - move the merges line between props and the ticket reference
# - add the username of the person who provided dev-review if required
#
# The commit message is copied in to your clipboard, probably.
REV=$1
svn up --ignore-externals . > /dev/null
svn merge -c$REV '^/trunk' .
LOG=$(svn log -r$REV '^/trunk' | grep -v '\-------' | tail -n +3)
BRANCH=$(svn info | grep '^URL:' | egrep -o '(tags|branches)/[^/]+|trunk' | egrep -o '[^/]+$')
echo -en "$LOG\n\nMerges [$REV] to the $BRANCH branch." | pbcopy
echo ""
pbpaste
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment