Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2017-07-19 15:36:34 +0200
committerErich Eckner <git@eckner.net>2017-07-19 15:36:34 +0200
commita381a6e5fc064a4658bc24ce06c7c1f8907efe7b (patch)
tree0768faa6bf645d6ff005e571edf2e1fee7a9b047
parenta3a1fe4b7ee8815af6568b7b42056fad14cc057b (diff)
bin/common-functions: find_newest_of_git_revisions new
-rwxr-xr-xbin/common-functions33
1 files changed, 33 insertions, 0 deletions
diff --git a/bin/common-functions b/bin/common-functions
index 2d2fd52..baf5750 100755
--- a/bin/common-functions
+++ b/bin/common-functions
@@ -493,3 +493,36 @@ append_architectures() {
local PKGBUILD="$1"
sed -i '/^arch=(/s/(/(i686 /'
}
+
+# find_newest_of_git_revisions
+# find newest git revision of the ones provided at stdin
+# (assuming linear history)
+
+find_newest_of_git_revisions() {
+ local revisions
+ local repo
+ revisions="$(cat)"
+
+ repo="$(
+ find_repository_with_commit \
+ "$(
+ echo "${revisions}" | \
+ grep -xm1 '[0-9a-f]\{40\}'
+ )"
+ )"
+
+ eval 'repo="${repo_paths__'"${repo}"'}"'
+
+ echo "${revisions}" | \
+ xargs -rn1 git -C "${repo}" rev-parse | \
+ (
+ newest=''
+ while read -r current; do
+ if [ -z "${newest}" ] || \
+ git -C "${repo}" merge-base --is-ancestor "${newest}" "${current}"; then
+ newest="${current}"
+ fi
+ done
+ echo "${newest}"
+ )
+}