Skip to content

Commit

Permalink
separate into own script instead
Browse files Browse the repository at this point in the history
  • Loading branch information
gavin-ts committed Oct 5, 2023
1 parent 232e4d5 commit 4b783e0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
16 changes: 11 additions & 5 deletions lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand All @@ -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
Expand Down
7 changes: 7 additions & 0 deletions lib/ensure_signed.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
set -eu
cd -- "$(dirname "$0")/../lib"
. ./git.sh
cd - >/dev/null

ensure_signed
10 changes: 5 additions & 5 deletions lib/git.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand Down

0 comments on commit 4b783e0

Please sign in to comment.