Skip to content

Commit 8f593fd

Browse files
committed
fix: align Phase 2 inactivity bot with paginated last-commit detection
Signed-off-by: Akshat Kumar <akshat230405@gmail.com>
1 parent 3f03d19 commit 8f593fd

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

.github/scripts/dry_run_inactivity_unassign_phase2.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,11 @@ for ISSUE in $ISSUES; do
9393
continue
9494
fi
9595

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 "")
96+
# Use the same "last commit" logic as the real bot (with pagination)
97+
COMMITS_JSON=$(gh api "repos/$REPO/pulls/$PR_NUM/commits" --paginate 2>/dev/null || echo "")
9898

9999
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 "")
100+
| jq -r 'last | (.commit.committer.date // .commit.author.date)' 2>/dev/null || echo "")
102101

103102
if [ -z "$LAST_COMMIT_DATE" ] || [ "$LAST_COMMIT_DATE" = "null" ]; then
104103
echo " [WARN] Could not determine last commit date for PR #$PR_NUM, skipping."

.github/scripts/inactivity_unassign_phase2.sh

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4+
# Inactivity Unassign Bot (Phase 2 - PR inactivity)
45
# Env:
56
# GH_TOKEN - provided by GitHub Actions
67
# REPO - owner/repo (fallback to GITHUB_REPOSITORY)
@@ -94,15 +95,11 @@ for ISSUE in $ISSUES; do
9495
continue
9596
fi
9697

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 "[]")
98+
# Last commit date on the PR (use API order + paginate, take last)
99+
COMMITS_JSON=$(gh api "repos/$REPO/pulls/$PR_NUM/commits" --paginate 2>/dev/null || echo "")
99100

100101
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-
')
102+
| jq -r 'last | (.commit.committer.date // .commit.author.date)' 2>/dev/null || echo "")
106103

107104
if [ -z "$LAST_COMMIT_DATE" ] || [ "$LAST_COMMIT_DATE" = "null" ]; then
108105
echo " [WARN] Could not determine last commit date for PR #$PR_NUM, skipping."

0 commit comments

Comments
 (0)