diff --git a/oss-contributor-stats/README.md b/oss-contributor-stats/README.md new file mode 100644 index 0000000..5d5efe7 --- /dev/null +++ b/oss-contributor-stats/README.md @@ -0,0 +1,5 @@ +To get the percentage of non-founder contributions: + +0. Run `cd oss-contributor-stats` +1. Run `./get_stats.sh > stats.txt`. In this script is defined how many days to look back. +2. Run `python process_stats.py`. In this script is defined who the founders are. diff --git a/oss-contributor-stats/get_stats.sh b/oss-contributor-stats/get_stats.sh new file mode 100755 index 0000000..37b4870 --- /dev/null +++ b/oss-contributor-stats/get_stats.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# Get the list of authors and their commit counts for the last 60 days +git log --since="200 days ago" --pretty=format:"%an" | sort | uniq -c | sort -rn + +# Get the total number of commits in the last 60 days +total=$(git log --since="200 days ago" --oneline | wc -l) + +echo "Total commits: $total" + +# to run this file: ./get_stats.sh > stats.txt \ No newline at end of file diff --git a/oss-contributor-stats/process_stats.py b/oss-contributor-stats/process_stats.py new file mode 100644 index 0000000..181929c --- /dev/null +++ b/oss-contributor-stats/process_stats.py @@ -0,0 +1,32 @@ +def process_stats(filename, founders): + with open(filename, 'r') as f: + lines = f.readlines() + + total_commits = int(lines[-1].split(":")[1].strip()) + founder_commits = 0 + + for line in lines[:-1]: + count, author = line.strip().split(None, 1) + if author in founders: + founder_commits += int(count) + + non_founder_commits = total_commits - founder_commits + return total_commits, non_founder_commits + +def calculate_percentage(founders): + total_commits = 0 + non_founder_commits = 0 + + stats_file = './stats.txt' + repo_total, repo_non_founder = process_stats(stats_file, founders) + total_commits += repo_total + non_founder_commits += repo_non_founder + + percentage = (non_founder_commits / total_commits) * 100 if total_commits > 0 else 0 + return round(percentage, 2) + +# List of founders +founders = ['Duke Pan', 'Nathan A'] + +percentage = calculate_percentage(founders) +print(f"Percentage of non-founder contributions in the last 200 days: {percentage}%") \ No newline at end of file diff --git a/oss-contributor-stats/stats.txt b/oss-contributor-stats/stats.txt new file mode 100644 index 0000000..e580e89 --- /dev/null +++ b/oss-contributor-stats/stats.txt @@ -0,0 +1,7 @@ + 29 Duke Pan + 2 Wigya + 2 Malo + 1 akash3444 + 1 Nikita Teslyuk + 1 Max +Total commits: 36