mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-24 10:25:51 +03:00
merge_helpers.sh: depend less on upstream tags
Change-Id: Ic79931eba7d501e4f76e5dd069921f9f3486f86c
This commit is contained in:
parent
6076df81ed
commit
f57dd91035
2 changed files with 65 additions and 5 deletions
|
@ -22,6 +22,52 @@ require_clean_git() {
|
|||
fi
|
||||
}
|
||||
|
||||
upstream_common_base() {
|
||||
local base="$1"
|
||||
if [ -z "$base" ]; then
|
||||
local base="HEAD"
|
||||
fi
|
||||
local merged_develop=`git merge-base "$base" upstream/develop`
|
||||
local merged_main=`git merge-base "$base" upstream/main`
|
||||
>&2 echo "Last merged main: $(git log -1 --oneline "$merged_main")"
|
||||
>&2 echo "Last merged develop: $(git log -1 --oneline "$merged_develop")"
|
||||
# Is latest main or develop merge more up-to-date?
|
||||
if [ "$merged_develop" = "$merged_main" ]; then
|
||||
>&2 echo "Last merged: upstream/main = upstream/develop"
|
||||
commit="$merged_main"
|
||||
elif git merge-base --is-ancestor "$merged_develop" "$merged_main"; then
|
||||
>&2 echo "Last merged: upstream/main > upstream/develop"
|
||||
commit="$merged_main"
|
||||
elif git merge-base --is-ancestor "$merged_main" "$merged_develop"; then
|
||||
>&2 echo "Last merged: upstream/develop > upstream/main"
|
||||
commit="$merged_develop"
|
||||
else
|
||||
# Commented out: code works (I think), but may be safer to not assume such things
|
||||
#develop_timestamp=`git show -s --format=%ct "$merged_develop"`
|
||||
#main_timestamp=`git show -s --format=%ct "$merged_main"`
|
||||
#if ((develop_timestamp > main_timestamp)); then
|
||||
# >&2 echo "Last merged: upstream/develop (later ts)"
|
||||
# commit="$merged_develop"
|
||||
#elif ((develop_timestamp < main_timestamp)); then
|
||||
# >&2 echo "Last merged: upstream/main (later ts)"
|
||||
# commit="$merged_main"
|
||||
#else
|
||||
>&2 echo "ERROR: don't know how to compare main and develop upstream branches"
|
||||
exit 1
|
||||
#fi
|
||||
fi
|
||||
echo "$commit"
|
||||
}
|
||||
|
||||
upstream_previous_common_base() {
|
||||
local base="$(upstream_common_base 2>/dev/null)"
|
||||
if [ -z "$base" ]; then
|
||||
>&2 echo "ERROR: don't know how to compare main and develop upstream branches"
|
||||
exit 1
|
||||
fi
|
||||
upstream_common_base "$base~1"
|
||||
}
|
||||
|
||||
upstream_latest_tag() {
|
||||
git describe --abbrev=0 upstream/main --tags
|
||||
}
|
||||
|
@ -44,13 +90,27 @@ downstream_latest_tag() {
|
|||
}
|
||||
|
||||
upstream_diff() {
|
||||
local latest_tag=`upstream_latest_tag`
|
||||
local previous_tag=`upstream_previous_tag`
|
||||
#local latest_tag=`upstream_latest_tag`
|
||||
#local previous_tag=`upstream_previous_tag`
|
||||
if git rev-parse MERGE_HEAD > /dev/null; then
|
||||
local latest_tag=`git rev-parse MERGE_HEAD`
|
||||
local previous_tag=`upstream_common_base`
|
||||
else
|
||||
local latest_tag=`upstream_common_base`
|
||||
local previous_tag=`upstream_previous_common_base`
|
||||
fi
|
||||
git diff "$previous_tag".."$latest_tag" "$@"
|
||||
}
|
||||
upstream_log() {
|
||||
local latest_tag=`upstream_latest_tag`
|
||||
local previous_tag=`upstream_previous_tag`
|
||||
#local latest_tag=`upstream_latest_tag`
|
||||
#local previous_tag=`upstream_previous_tag`
|
||||
if git rev-parse MERGE_HEAD > /dev/null; then
|
||||
local latest_tag=`git rev-parse MERGE_HEAD`
|
||||
local previous_tag=`upstream_common_base`
|
||||
else
|
||||
local latest_tag=`upstream_common_base`
|
||||
local previous_tag=`upstream_previous_common_base`
|
||||
fi
|
||||
git log "$previous_tag".."$latest_tag" "$@"
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ source "$mydir/merge_helpers.sh"
|
|||
require_clean_git
|
||||
|
||||
# Revert Schildi's upstream string changes
|
||||
git checkout `upstream_previous_tag` -- "$mydir/vector/src/main/res/**/strings.xml"
|
||||
git checkout `upstream_common_base` -- "$mydir/vector/src/main/res/**/strings.xml"
|
||||
git commit -m "Automatic revert to unchanged upstream strings, pt.1"
|
||||
|
||||
# Keep in sync with post_merge.sh!
|
||||
|
|
Loading…
Reference in a new issue