mirror of https://github.com/CalyxOS/scripts
aosp-merger: Improve merge commit message
* Merge and commit separately, to get newline between commit content and Change-Id * Install prepare-commit-msg git hook, for nicer conflict messages https://gist.github.com/mikeNG/e55ef8e7a1e5cd596a950386503054fd/ Change-Id: I97370b352ccf4f146b4b6ea89af75e032fb13730
This commit is contained in:
parent
ba9a055d43
commit
3f6df5c8a0
|
@ -32,6 +32,8 @@ readonly vars_path="${script_path}/../vars"
|
|||
|
||||
source "${vars_path}/common"
|
||||
|
||||
readonly hook="${script_path}/prepare-commit-msg"
|
||||
|
||||
TOP="${script_path}/../../.."
|
||||
BRANCH="${calyxos_branch}"
|
||||
STAGINGBRANCH="staging/${BRANCH}_${OPERATION}-${NEWTAG}"
|
||||
|
@ -40,6 +42,9 @@ cd "${TOP}/${PROJECTPATH}"
|
|||
repo start "${STAGINGBRANCH}" .
|
||||
git fetch -q --tags aosp "${NEWTAG}"
|
||||
|
||||
[[ ! -e .git/hooks/prepare-commit-msg ]] && cp "${hook}" .git/hooks/
|
||||
chmod +x .git/hooks/prepare-commit-msg
|
||||
|
||||
PROJECTOPERATION="${OPERATION}"
|
||||
|
||||
# Check if we've actually changed anything before attempting to merge
|
||||
|
@ -69,7 +74,7 @@ fi
|
|||
|
||||
if [[ "${PROJECTOPERATION}" == "merge" ]]; then
|
||||
echo "#### Merging ${NEWTAG} into ${PROJECTPATH} ####"
|
||||
git merge --no-edit --log "${NEWTAG}"
|
||||
git merge --no-commit --log "${NEWTAG}" && git commit --no-edit
|
||||
elif [[ "${PROJECTOPERATION}" == "rebase" ]]; then
|
||||
echo "#### Rebasing ${PROJECTPATH} onto ${NEWTAG} ####"
|
||||
git rebase --onto "${NEWTAG}" "${OLDTAG}"
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
#!/bin/sh
|
||||
|
||||
case "$2,$3" in
|
||||
merge,)
|
||||
if grep -q "# It looks like you may be committing a merge." "$1"; then
|
||||
sed -i -e '/# ------------------------ >8 ------------------------/,+3d' "$1"
|
||||
/usr/bin/perl -i.bak -ne 's/^#// if /^# Conflicts/ .. /^#\R/; print' "$1"
|
||||
sed -i '/ It looks like you may be committing a merge./i # ------------------------ >8 ------------------------' "$1"
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
;;
|
||||
esac
|
Loading…
Reference in New Issue