Created
February 5, 2023 08:58
-
-
Save ohader/cae9392ae996fb840af9ebef772b2bc1 to your computer and use it in GitHub Desktop.
TYPO3 Git Commit Splitter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
### | |
# TYPO3 Git Cherry-Picked Commit Splitter ("Cherry-Split") | |
# @author Oliver Hader <oliver@typo3.org> | |
# @license GPL v2 on any later version | |
# | |
# Usage | |
# - cherry-pick change to local Git working copy | |
# - execute this script `./cherry-split.sh` which processed the tip commit | |
# - generates files per hash and extension, e.g. `abcd1234-frontend.patch` | |
## | |
TYPO3_PREFIX='typo3/sysext/' | |
LOG=$(git log --oneline -1) | |
FILES=$(git diff HEAD^ --name-only) | |
COMMIT=$(git rev-parse --short HEAD) | |
EXTENSIONS='' | |
for file in ${FILES}; do | |
if [[ $file =~ ^${TYPO3_PREFIX} ]]; then | |
ext=$(cut -d/ -f3 <<< ${file}) | |
if [[ "${EXTENSIONS}" == "" ]]; then | |
EXTENSIONS=${ext} | |
else | |
EXTENSIONS=$(echo "${EXTENSIONS}\n${ext}" | sort -u) | |
fi | |
fi | |
done | |
cat <<< ${LOG} | |
echo | |
echo "Commit (used as output file prefix):\n${COMMIT}" | |
echo | |
echo "Files:" | |
cat <<< "${FILES}" | |
echo | |
echo "Extensions:" | |
cat <<< "${EXTENSIONS}" | |
echo | |
read -p 'Continue (y/n)? ' result | |
case "$result" in | |
y|Y ) ;; | |
* ) exit 1;; | |
esac | |
for ext in ${EXTENSIONS}; do | |
path="${TYPO3_PREFIX}${ext}/" | |
file="${COMMIT}-${ext}.patch" | |
git diff HEAD^ --relative="${path}" -- :^${path}Tests/ > ${file} | |
if [ -s "${file}" ]; then | |
echo "+ ${file}" | |
else | |
rm ${file} | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example execution (based on this commit https://review.typo3.org/c/Packages/TYPO3.CMS/+/77522):