From a381a6e5fc064a4658bc24ce06c7c1f8907efe7b Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Wed, 19 Jul 2017 15:36:34 +0200 Subject: bin/common-functions: find_newest_of_git_revisions new --- bin/common-functions | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'bin') 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}" + ) +} -- cgit v1.2.3-54-g00ecf