From 4b783e0f45a4a6502fd51699224250a1934d5c67 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Thu, 5 Oct 2023 15:07:11 -0700 Subject: [PATCH] separate into own script instead --- lib.sh | 16 +++++++++++----- lib/ensure_signed.sh | 7 +++++++ lib/git.sh | 10 +++++----- 3 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 lib/ensure_signed.sh diff --git a/lib.sh b/lib.sh index caa0cb1..ce33dd7 100644 --- a/lib.sh +++ b/lib.sh @@ -29,6 +29,12 @@ ci_waitjobs() { return "$code" } #!/bin/sh +set -eu +cd -- "$(dirname "$0")/../lib" +cd - >/dev/null + +ensure_signed +#!/bin/sh if [ "${LIB_FLAG-}" ]; then return 0 fi @@ -322,11 +328,6 @@ nofixups() { return fi - if [ -n "${CHECK_SIGS-}" ]; then - if [ ! "$(ensure_signed)" ]; then - return 1 - fi - fi commits="$(git log --grep='fixup!' --format=%h ${GIT_BASE:+"$GIT_BASE..HEAD"})" if [ -n "$commits" ]; then echo "$commits" | FGCOLOR=1 logpcat 'fixup detected' @@ -335,6 +336,11 @@ nofixups() { } ensure_signed() { + ensure_git_base + if [ "$(git_commit_count)" -lt 1 ]; then + return + fi + # look for signature status N: no signature if [ ! "$(git log --format="%G?" ${GIT_BASE:+"$GIT_BASE..HEAD"} | grep "N")" ]; then return diff --git a/lib/ensure_signed.sh b/lib/ensure_signed.sh new file mode 100644 index 0000000..a57de64 --- /dev/null +++ b/lib/ensure_signed.sh @@ -0,0 +1,7 @@ +#!/bin/sh +set -eu +cd -- "$(dirname "$0")/../lib" +. ./git.sh +cd - >/dev/null + +ensure_signed diff --git a/lib/git.sh b/lib/git.sh index efb2f3a..6a7de27 100644 --- a/lib/git.sh +++ b/lib/git.sh @@ -164,11 +164,6 @@ nofixups() { return fi - if [ -n "${CHECK_SIGS-}" ]; then - if [ ! "$(ensure_signed)" ]; then - return 1 - fi - fi commits="$(git log --grep='fixup!' --format=%h ${GIT_BASE:+"$GIT_BASE..HEAD"})" if [ -n "$commits" ]; then echo "$commits" | FGCOLOR=1 logpcat 'fixup detected' @@ -177,6 +172,11 @@ nofixups() { } ensure_signed() { + ensure_git_base + if [ "$(git_commit_count)" -lt 1 ]; then + return + fi + # look for signature status N: no signature if [ ! "$(git log --format="%G?" ${GIT_BASE:+"$GIT_BASE..HEAD"} | grep "N")" ]; then return