From 7d467d622a55e311e6cb3d6d398302dfc82af6f7 Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Tue, 8 Sep 2020 18:53:10 +0200 Subject: [PATCH] Update merge helpers Change-Id: I2da35a52c6f7209acc822c7fd878255df082bc52 --- merge_helpers.sh | 28 ++++++++++++++++++++++++++++ post_merge.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ pre_merge.sh | 22 +++++++--------------- 3 files changed, 83 insertions(+), 15 deletions(-) create mode 100755 post_merge.sh diff --git a/merge_helpers.sh b/merge_helpers.sh index ab7fa91e00..b7119c65e6 100755 --- a/merge_helpers.sh +++ b/merge_helpers.sh @@ -1,13 +1,41 @@ #!/bin/bash +find_last_commit_for_title() { + local title="$1" + git log --oneline --author=SpiritCroc | grep "$title" | head -n 1 | sed 's| .*||' +} + +revert_last() { + local title="$1" + git revert --no-edit `find_last_commit_for_title "$title"` +} + +require_clean_git() { + uncommitted=`git status --porcelain` + if [ ! -z "$uncommitted" ]; then + echo "Uncommitted changes are present, please commit first!" + exit 1 + fi +} + upstream_latest_tag() { git describe upstream/master --tags } upstream_previous_tag() { git describe `upstream_latest_tag`~1 --tags } +downstream_latest_tag() { + git describe sc --tags +} + upstream_diff() { local latest_tag=`upstream_latest_tag` local previous_tag=`upstream_previous_tag` git diff "$previous_tag".."$latest_tag" "$@" } + +downstream_upstream_diff() { + local previous_tag=`upstream_previous_tag` + local downstream_tag=`downstream_latest_tag` + git diff "$previous_tag".."$downstream_latest_tag" "$@" +} diff --git a/post_merge.sh b/post_merge.sh new file mode 100755 index 0000000000..a7ca07ec42 --- /dev/null +++ b/post_merge.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +set -e + +mydir="$(dirname "$(realpath "$0")")" +source "$mydir/merge_helpers.sh" + +# Require clean git state +require_clean_git + +# Oposite of restore_upstream in post_merge.sh +restore_sc() { + local f="$(basename "$1")" + local path="$(dirname "$1")" + local sc_f="tmp_sc_$f" + local upstream_f="upstream_$f" + if [ -e "$path/$f" ]; then + mv "$path/$f" "$path/$upstream_f" + fi + if [ -e "$path/$sc_f" ]; then + mv "$path/$sc_f" "$path/$f" + fi +} + + +# Keep in sync with pre_merge.sh! +restore_sc README.md +restore_sc fastlane + +git add -A +git commit -m "Automatic upstream merge postprocessing" + + +"$mydir"/correct_strings.sh + +revert_last 'Revert "Resolve required manual intervention in german strings"' + +while grep -q "wolpertinger\|schlumpfwesen" "$mydir/vector/src/main/res/values-de/strings.xml"; do + read -p "Please resolve remaining language, then press enter!" +done + +uncommitted=`git status --porcelain` +if [ -z "$uncommitted" ]; then + echo "Seems like no new language conflicts appeared :)" +else + git add -A + git commit -m 'Resolve required manual intervention in german strings' +fi diff --git a/pre_merge.sh b/pre_merge.sh index f22e52a82d..ad2a447b9c 100755 --- a/pre_merge.sh +++ b/pre_merge.sh @@ -2,23 +2,13 @@ set -e +mydir="$(dirname "$(realpath "$0")")" +source "$mydir/merge_helpers.sh" + # Require clean git state -uncommitted=`git status --porcelain` -if [ ! -z "$uncommitted" ]; then - echo "Uncommitted changes are present, please commit first!" - exit 1 -fi - -find_last_commit_for_title() { - local title="$1" - git log --oneline --author=SpiritCroc | grep "$title" | head -n 1 | sed 's| .*||' -} - -revert_last() { - local title="$1" - git revert --no-edit `find_last_commit_for_title "$title"` -} +require_clean_git +# Oposite of restore_sc in post_merge.sh restore_upstream() { local f="$(basename "$1")" local path="$(dirname "$1")" @@ -33,7 +23,9 @@ restore_upstream() { revert_last 'Resolve required manual intervention in german strings' revert_last 'Automatic SchildiChat string correction' +# Keep in sync with post_merge.sh! restore_upstream fastlane restore_upstream README.md + git add -A git commit -m "[TMP] Automatic upstream merge preparation"