File tree Expand file tree Collapse file tree 2 files changed +17
-7
lines changed
Expand file tree Collapse file tree 2 files changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -93,10 +93,14 @@ for ISSUE in $ISSUES; do
9393 continue
9494 fi
9595
96- LAST_COMMIT_DATE= $( gh api " repos/ $REPO /pulls/ $PR_NUM /commits " \
97- --jq ' .[-1].commit.committer.date // .[-1].commit.author.date ' 2> /dev/null || echo " " )
96+ # Use the same "max by timestamp" logic as the real bot
97+ COMMITS_JSON= $( gh api " repos/ $REPO /pulls/ $PR_NUM /commits " 2> /dev/null || echo " " )
9898
99- if [ -z " $LAST_COMMIT_DATE " ]; then
99+ LAST_COMMIT_DATE=$( echo " $COMMITS_JSON " \
100+ | jq -r ' max_by(.commit.committer.date // .commit.author.date)
101+ | (.commit.committer.date // .commit.author.date)' 2> /dev/null || echo " " )
102+
103+ if [ -z " $LAST_COMMIT_DATE " ] || [ " $LAST_COMMIT_DATE " = " null" ]; then
100104 echo " [WARN] Could not determine last commit date for PR #$PR_NUM , skipping."
101105 continue
102106 fi
Original file line number Diff line number Diff line change @@ -94,11 +94,17 @@ for ISSUE in $ISSUES; do
9494 continue
9595 fi
9696
97- # Last commit date on the PR
98- LAST_COMMIT_DATE=$( gh api " repos/$REPO /pulls/$PR_NUM /commits" \
99- --jq ' .[-1].commit.committer.date // .[-1].commit.author.date' 2> /dev/null || echo " " )
97+ # Last commit date on the PR: pick the truly latest by timestamp
98+ COMMITS_JSON=$( gh api " repos/$REPO /pulls/$PR_NUM /commits" --paginate 2> /dev/null || echo " []" )
10099
101- if [ -z " $LAST_COMMIT_DATE " ]; then
100+ LAST_COMMIT_DATE=$( echo " $COMMITS_JSON " \
101+ | jq -r '
102+ select(length > 0)
103+ | max_by(.commit.committer.date // .commit.author.date)
104+ | (.commit.committer.date // .commit.author.date)
105+ ' )
106+
107+ if [ -z " $LAST_COMMIT_DATE " ] || [ " $LAST_COMMIT_DATE " = " null" ]; then
102108 echo " [WARN] Could not determine last commit date for PR #$PR_NUM , skipping."
103109 continue
104110 fi
You can’t perform that action at this time.
0 commit comments