Skip to content

Commit 2ccc350

Browse files
committed
Track committer additions with git history
After #31, people who received commit access since a year ago were tracked with the date of commit bit reception. While this works, it's not necessary in the long term, because the git history will keep track of when commit bits are given. This change starts using the commit history when possible, which allows avoiding the need for adding addition dates for new committers.
1 parent 0ddf4a2 commit 2ccc350

9 files changed

Lines changed: 49 additions & 14 deletions

File tree

.github/workflows/retire.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ jobs:
3434
uses: actions/checkout@v4
3535
with:
3636
token: ${{ steps.app-token.outputs.token }}
37+
# Fetch full history to determine when committers were added
38+
fetch-depth: 0
3739
- name: Run script
3840
# One month plus a bit of leeway
3941
run: scripts/retire.sh NixOS nixpkgs nixpkgs-committers members "yesterday 1 month ago"

members/Enzime

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
2025-08-20

members/LordGrimmauld

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
2025-08-20

members/MattSturgeon

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
2025-08-20

members/SigmaSquadron

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
2025-08-20

members/jmbaur

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
2025-08-20

members/m1cr0man

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
2025-08-20

scripts/retire.sh

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,31 @@ DIR=${4:-$(usage)}
3737
NOTICE_CUTOFF=${5:-$(usage)}
3838

3939
mainBranch=$(git branch --show-current)
40-
newCutoff=$(date --date="1 year ago" +%s)
4140
noticeCutoff=$(date --date="$NOTICE_CUTOFF" +%s)
4241

42+
# People that received the commit bit after this date won't be retired
43+
newCutoff=$(date --date="1 year ago" +%s)
44+
45+
# We need to know when people received their commit bit to avoid retiring them within the first year.
46+
# For now this is done either with the git creation date of the file, or its contents:
47+
#
48+
# | commit bit reception date | file creation date | file contents |
49+
# | -------------------------- | ------------------ | -------------- |
50+
# | A) -∞ - 2024-10-06 | 2025-07-08 | empty |
51+
# | B) 2024-10-07 - 2025-04-22 | 2025-07-08 | reception date |
52+
# | C) 2025-08-13 - ∞ | reception date | empty |
53+
#
54+
# After 2026-04-23 (one year after C started), the file creation date
55+
# for all first-year committers will match the reception date,
56+
# while everybody else will have been a committer for more than one year.
57+
# This means the code can then be simplified to just
58+
# check if the file creation date is in the last year.
59+
#
60+
# For now however, the code needs to check if the file creation date
61+
# is before 2025-07-09 to distinguish between periods A and C,
62+
# so we hardcode that date for the code to use.
63+
createdOnReceptionEpoch=$(date --date=2025-07-09 +%s)
64+
4365
if [[ -z "${PROD:-}" ]]; then
4466
tmp=$(git rev-parse --show-toplevel)/.tmp
4567
rm -rf "$tmp"
@@ -54,12 +76,30 @@ mkdir -p "$DIR"
5476
cd "$DIR"
5577
for login in *; do
5678

57-
# Don't remove people that have been added recently
58-
if [[ -s "$login" ]]; then
59-
epochAdded=$(date --date="$(<"$login")" +%s)
60-
if (( newCutoff < epochAdded )); then
61-
continue
79+
# Figure out when this person received the commit bit
80+
# Get the unix epoch of the first commit that touched this file
81+
# --first-parent is important to get the time of when the main branch was changed
82+
fileCommitEpoch=$(git log --reverse --first-parent --format=%cd --date=unix -- "$login" | head -1)
83+
if (( fileCommitEpoch < createdOnReceptionEpoch )); then
84+
# If it was created before creation actually matched the reception date
85+
# This branch can be removed after 2026-04-23
86+
87+
if [[ -s "$login" ]]; then
88+
# If the file is non-empty it indicates an explicit reception date
89+
receptionEpoch=$(date --date="$(<"$login")" +%s)
90+
else
91+
# Otherwise they received the commit bit more than a year ago (start of unix epoch, 1970)
92+
receptionEpoch=0
6293
fi
94+
else
95+
# Otherwise creation matches reception
96+
receptionEpoch=$fileCommitEpoch
97+
fi
98+
99+
# If the commit bit was received after the cutoff date, don't retire in any case
100+
if (( newCutoff < receptionEpoch )); then
101+
log "$login became a committer less than 1 year ago, skipping retirement check"
102+
continue
63103
fi
64104

65105
trace gh api -X GET /repos/"$ORG"/"$ACTIVITY_REPO"/activity \

scripts/sync.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ gh api /orgs/"$ORG"/teams/"$TEAM"/members --paginate --jq '.[].login' |
1717
if [[ -f "$DIR/$login" ]]; then
1818
mv "$DIR/$login" "$DIR.new"
1919
else
20-
# Keep track of when the user was added
21-
date +%F > "$DIR.new/$login"
20+
touch "$DIR.new/$login"
2221
fi
2322
done
2423

0 commit comments

Comments
 (0)