fix: handle Woodpecker shallow clone in postmortem pipeline
This commit is contained in:
parent
60c04e51b7
commit
59367cc588
1 changed files with 18 additions and 6 deletions
|
|
@ -4,16 +4,28 @@
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# 1. Find which post-mortem changed
|
# 1. Find which post-mortem changed
|
||||||
PM_FILE=$(git diff HEAD~1 --name-only | grep 'docs/post-mortems/.*[.]md' | head -1)
|
# Woodpecker shallow clones (depth 1) so HEAD~1 may not exist. Fetch more history.
|
||||||
|
git fetch --deepen=2 origin master 2>/dev/null || true
|
||||||
|
PM_FILE=$(git diff HEAD~1 --name-only 2>/dev/null | grep 'docs/post-mortems/.*[.]md' | head -1)
|
||||||
if [ -z "$PM_FILE" ]; then
|
if [ -z "$PM_FILE" ]; then
|
||||||
echo "No post-mortem markdown changes detected"
|
# Fallback: check all post-mortems for TODO items
|
||||||
|
for f in docs/post-mortems/*.md; do
|
||||||
|
if grep -q '| TODO |' "$f" 2>/dev/null; then
|
||||||
|
PM_FILE="$f"
|
||||||
|
echo "Fallback: found TODOs in $f"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
if [ -z "$PM_FILE" ]; then
|
||||||
|
echo "No post-mortem with TODOs found"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
echo "Post-mortem changed: $PM_FILE"
|
echo "Post-mortem: $PM_FILE"
|
||||||
|
|
||||||
# 2. Check if there are new TODOs (not just TODO→Done updates)
|
# 2. Check if there are TODO items to process
|
||||||
if ! git diff HEAD~1 -- "$PM_FILE" | grep -q '+.*TODO'; then
|
if ! grep -q '| TODO |' "$PM_FILE"; then
|
||||||
echo "No new TODOs added — skipping"
|
echo "No TODOs in $PM_FILE — skipping"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue