mirror of
https://github.com/rebelonion/Dantotsu.git
synced 2026-01-28 23:31:02 +00:00
feat: use git for commit counts
This commit is contained in:
49
.github/workflows/beta.yml
vendored
49
.github/workflows/beta.yml
vendored
@@ -105,49 +105,40 @@ jobs:
|
||||
avatar_url=$(echo "$user_details" | jq -r '.avatar_url')
|
||||
echo "$name|$login|$avatar_url"
|
||||
}
|
||||
|
||||
# Additional information for the goats
|
||||
declare -A additional_info
|
||||
additional_info["ibo"]=" Discord: <@951737931159187457>\n AniList: [takarealist112](<https://anilist.co/user/takarealist112/>)\n"
|
||||
additional_info["aayush262"]=" Discord: <@918825160654598224>\n AniList: [aayush262](<https://anilist.co/user/aayush262/>)\n"
|
||||
additional_info["rebelonion"]=" Discord: <@714249925248024617>\n AniList: [rebelonion](<https://anilist.co/user/rebelonion/>)\n PornHub: [rebelonion](<https://www.cornhub.com/model/rebelonion>)\n"
|
||||
|
||||
|
||||
# Extract contributor names from commit log and make unique list
|
||||
committers=$(echo "$COMMIT_LOG" | sed 's/%0A/\n/g' | grep -oP '(?<=~)[^%]*')
|
||||
committers=$(echo "$committers" | sort | uniq)
|
||||
|
||||
# Get commit counts on the dev branch
|
||||
commit_counts=$(git shortlog -s -n dev)
|
||||
|
||||
# Prepare commit count JSON
|
||||
json="{"
|
||||
while IFS= read -r line; do
|
||||
count=$(echo "$line" | awk '{print $1}')
|
||||
author=$(echo "$line" | cut -d' ' -f2-)
|
||||
json+="\"$author\": $count,"
|
||||
done <<< "$commit_counts"
|
||||
json="${json%,}}"
|
||||
committers=$(echo "$COMMIT_LOG" | sed 's/%0A/\n/g' | grep -oP '(?<=~)[^%]*' | sort | uniq)
|
||||
|
||||
# Initialize needed variables
|
||||
developers=""
|
||||
committers_count=0
|
||||
thumbnail_url="https://i.imgur.com/5o3Y9Jb.gif"
|
||||
|
||||
# Process commit counts
|
||||
for login in $(echo "$json" | jq -r 'keys[]'); do
|
||||
commits=$(echo "$json" | jq -r --arg login "$login" '.[$login]')
|
||||
user_info=$(fetch_user_details "$login")
|
||||
name=$(echo "$user_info" | cut -d'|' -f1)
|
||||
login=$(echo "$user_info" | cut -d'|' -f2)
|
||||
avatar_url=$(echo "$user_info" | cut -d'|' -f3)
|
||||
if echo "$committers" | grep -qw "$name"; then
|
||||
# Process contributors and filter by committers
|
||||
while read -r committer; do
|
||||
# Get commit count for this committer on the dev branch
|
||||
commit_count=$(git rev-list --count dev --author="$committer")
|
||||
|
||||
# Only proceed if the committer has commits on the dev branch
|
||||
if [ "$commit_count" -gt 0 ]; then
|
||||
user_info=$(fetch_user_details "$committer")
|
||||
name=$(echo "$user_info" | cut -d'|' -f1)
|
||||
login=$(echo "$user_info" | cut -d'|' -f2)
|
||||
avatar_url=$(echo "$user_info" | cut -d'|' -f3)
|
||||
|
||||
extra_info="${additional_info[$name]}"
|
||||
if [ -n "$extra_info" ]; then
|
||||
extra_info=$(echo -e "$extra_info" | sed 's/^/- /')
|
||||
fi
|
||||
|
||||
developers="${developers}◗ **${name}**
|
||||
${extra_info} Github: [${login}](https://github.com/${login})
|
||||
- Commits: ${commits}
|
||||
- Commits: ${commit_count}
|
||||
"
|
||||
committers_count=$((committers_count + 1))
|
||||
if [ $committers_count -eq 1 ]; then
|
||||
@@ -156,18 +147,18 @@ jobs:
|
||||
thumbnail_url="https://i.imgur.com/5o3Y9Jb.gif"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
done < <(echo "$committers")
|
||||
|
||||
# Remove trailing newline
|
||||
developers=$(echo "$developers" | sed '$ s/$//')
|
||||
commit_messages=$(echo "$COMMIT_LOG" | sed 's/%0A/\n/g; s/^/\n/')
|
||||
|
||||
|
||||
# Truncate field values
|
||||
max_length=1000
|
||||
if [ ${#developers} -gt $max_length ]; then
|
||||
developers="${developers:0:$max_length}... (truncated)"
|
||||
fi
|
||||
if [ ${#commit_messages} -gt $max_length]; then
|
||||
if [ ${#commit_messages} -gt $max_length ]; then
|
||||
commit_messages="${commit_messages:0:$max_length}... (truncated)"
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user