From 60e7ab278cbed710f09178046d1f9880a8ee68fb Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Fri, 12 Jul 2019 12:20:23 +0200 Subject: bin/nit-picker: check if commit is ahead of HEAD --- bin/nit-picker | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'bin/nit-picker') diff --git a/bin/nit-picker b/bin/nit-picker index 50524e9..87c7b92 100755 --- a/bin/nit-picker +++ b/bin/nit-picker @@ -87,6 +87,7 @@ while pgrep -x ii >/dev/null \ printf 'SELECT DISTINCT' printf ' "commit",' printf '`git_repositories`.`name`,' + printf '`git_repositories`.`head`,' printf '`package_sources`.`git_revision`' printf ' FROM `package_sources`' mysql_join_package_sources_upstream_repositories @@ -96,6 +97,9 @@ while pgrep -x ii >/dev/null \ printf 'SELECT DISTINCT' printf ' "commit",' printf '"archlinux32",' + # shellcheck disable=SC2154 + printf '"%s",' \ + "${repo_heads__archlinux32}" printf '`package_sources`.`mod_git_revision`' printf ' FROM `package_sources`' printf ';\n' @@ -121,6 +125,8 @@ while pgrep -x ii >/dev/null \ 'commit') # check whether a given commit is present in the git repo git_repo="${parameters%% *}" git_rev="${parameters#${git_repo} }" + git_head="${parameters%% *}" + git_rev="${git_rev#${git_head} }" eval "$( printf 'git_dir="${repo_paths__%s}"\n' \ "${git_repo}" @@ -137,6 +143,26 @@ while pgrep -x ii >/dev/null \ | irc_say fi fi + # shellcheck disable=SC2154 + if ! git -C "${git_dir}" cat-file -t "${git_head}" 2> /dev/null | \ + grep -qxF 'commit'; then + git -C "${git_dir}" fetch --all -p >/dev/null 2>&1 + if ! git -C "${git_dir}" cat-file -t "${git_head}" 2> /dev/null | \ + grep -qxF 'commit'; then + printf 'commit %s is missing from repository %s\n' \ + "${git_head}" \ + "${git_repo}" \ + | irc_say + fi + fi + # shellcheck disable=SC2154 + if ! git -C "${git_dir}" merge-base --is-ancestor "${git_rev}" "${git_head}" 2> /dev/null; then + printf 'commit %s is not an ancestor of HEAD %s in repository %s\n' \ + "${git_rev}" \ + "${git_head}" \ + "${git_repo}" \ + | irc_say + fi ;; 'binary-dependencies') ${master_mirror_rsync_command} \ -- cgit v1.2.3-54-g00ecf