Skip to content

Commit 51a5b48

Browse files
authored
Update update-contributors.yml
1 parent 4487096 commit 51a5b48

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

.github/workflows/update-contributors.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
# Switch to dev branch
2828
git checkout dev || { echo "Failed to checkout dev branch"; exit 1; }
2929
# Get all commits in dev branch
30-
commits=$(git log --pretty=format:%H || { echo "Failed to run git log"; exit 1; })
30+
commits=$(git log --pretty=format:%H || { echo "Failed to run git log"; exit 2; })
3131
total_commits=$(echo "$commits" | wc -l | tr -d ' ')
3232
echo "Total commits to process: $total_commits"
3333
for commit in $commits; do
@@ -51,12 +51,12 @@ jobs:
5151
# Update JSON with contributor stats
5252
jq --arg login "$login" --arg net_lines "$net_lines" \
5353
'.[$login] |= (. // {netLines: 0, commits: 0, login: $login} | .netLines += ($net_lines | tonumber) | .commits += 1)' \
54-
contributors.json > tmp.json 2>/dev/null || { echo "Error: jq failed to update stats for $login in commit $commit"; exit 1; }
55-
mv tmp.json contributors.json || { echo "Error: Failed to move tmp.json"; exit 1; }
54+
contributors.json > tmp.json 2>/dev/null || { echo "Error: jq failed to update stats for $login in commit $commit"; exit 3; }
55+
mv tmp.json contributors.json || { echo "Error: Failed to move tmp.json"; exit 4; }
5656
done
5757
echo "Total commits processed: $commit_count"
5858
# Format table
59-
table=$(jq -r 'to_entries | sort_by(.value.netLines) | reverse | .[] | select(.value.netLines > 0 or .value.commits > 0) | "| [\(.key)](https://github.com/\(.key)) | \(.value.netLines) | \(.value.commits) |"' contributors.json 2>/dev/null || { echo "Error: jq failed to format table"; exit 1; })
59+
table=$(jq -r 'to_entries | sort_by(.value.netLines) | reverse | .[] | select(.value.netLines > 0 or .value.commits > 0) | "| [\(.key)](https://github.com/\(.key)) | \(.value.netLines) | \(.value.commits) |"' contributors.json 2>/dev/null || { echo "Error: jq failed to format table"; exit 5; })
6060
if [ -z "$table" ]; then
6161
table="No contributors with commits or net lines added."
6262
echo "Warning: No valid contributors found"
@@ -66,7 +66,7 @@ jobs:
6666
echo "Total contributors: $(jq 'length' contributors.json 2>/dev/null || echo "Error: jq failed to count contributors")"
6767
echo "Generated table:"
6868
echo "$table"
69-
echo "$table" > contributors.txt || { echo "Error: Failed to write contributors.txt"; exit 1; }
69+
echo "$table" > contributors.txt || { echo "Error: Failed to write contributors.txt"; exit 6; }
7070
shell: bash
7171

7272
- name: Update README

0 commit comments

Comments
 (0)