Skip to content

fix: correct contribution metrics — remove double-counting and improve clarity#4936

Merged
marcusquinn merged 2 commits intomainfrom
refactor/fix-contribution-metrics
Mar 15, 2026
Merged

fix: correct contribution metrics — remove double-counting and improve clarity#4936
marcusquinn merged 2 commits intomainfrom
refactor/fix-contribution-metrics

Conversation

@marcusquinn
Copy link
Owner

@marcusquinn marcusquinn commented Mar 15, 2026

Summary

  • Fix double-counting: Removed --all from git log in contributor-activity-helper.sh. With --all, squash-merged PR commits were counted twice — once as the original branch commits and once as the squash-merge on main. This inflated totals by ~12% (e.g., marcusquinn: 3,757 → 3,339 actual).
  • Rename and reorder dashboard sections: "Contributions" → "Commits" (accurate label). "Contributor output" → "GitHub activity" and moved to top of dashboard as the most meaningful metric (issues filed, PRs created/merged, discussions). New order: GitHub activity → AI sessions → Commits.
  • Clarify column headers: "Direct" → "Direct Pushes", "PR Merges" → "PRs Merged" to make clear these are PRs authored by the contributor that were merged.

Verification

Tested contributor-activity-helper.sh summary output — numbers now match git log (no --all) exactly. ShellCheck passes clean on both modified files.

Metric Before (inflated) After (accurate)
marcusquinn 3,757 3,339
alex-solovyev 593 520
backup 125 10

Closes #4433

Summary by CodeRabbit

  • Updates
    • Renamed dashboard sections to "GitHub activity" for clearer labeling.
    • Reorganized which activity blocks feed per-repo and cross-repo sections to show more relevant metrics.
    • Updated terminology: "Direct Pushes", "PRs Merged", and "Total Commits".
  • Bug Fixes
    • Adjusted commit counting to avoid double-counting commits from merged pull requests.

…e clarity

- Remove --all from git log to count only default-branch commits, fixing
  ~12% inflation from squash-merged PR commits being counted twice (once
  as branch originals, once as the squash-merge on main)
- Rename 'Contributions' sections to 'Commits' for accuracy
- Rename 'Contributor output' to 'GitHub activity' and move to top of
  dashboard (most meaningful metric: issues, PRs, merges, comments)
- Clarify column headers: 'Direct' → 'Direct Pushes', 'PR Merges' → 'PRs Merged'
- Reorder dashboard: GitHub activity → AI sessions → Commits (most to least meaningful)
@github-actions github-actions bot added the bug Auto-created from TODO.md tag label Mar 15, 2026
@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the accuracy and readability of contribution metrics by refining how git commits are counted and presented. It addresses an issue where squash-merged pull requests were double-counted, and improves the user interface by renaming and reordering dashboard sections and clarifying report column headers, ensuring that contribution data is both precise and easily understandable.

Highlights

  • Accurate Contribution Metrics: Resolved double-counting of squash-merged PR commits by removing the --all flag from git log commands, leading to more accurate commit totals (e.g., a ~12% reduction in inflated counts).
  • Improved Dashboard Clarity: Renamed dashboard sections for better understanding, changing 'Contributions' to 'Commits' and 'Contributor output' to 'GitHub activity', and reordered them to prioritize 'GitHub activity'.
  • Clearer Column Headers: Updated column headers in activity reports from 'Direct' to 'Direct Pushes' and 'PR Merges' to 'PRs Merged' for enhanced clarity on commit types.
Changelog
  • .agents/scripts/contributor-activity-helper.sh
    • Removed the --all flag from git log commands to prevent double-counting of squash-merged PR commits, ensuring only default-branch commits are counted.
    • Updated comments to explain the change in commit counting methodology and its impact on accuracy.
    • Modified markdown output table headers from 'Direct' to 'Direct Pushes', 'PR Merges' to 'PRs Merged', and 'Total' to 'Total Commits'.
    • Revised help text to reflect the updated commit counting logic and clarified descriptions for 'Direct Pushes' and 'PRs Merged'.
  • .agents/scripts/stats-functions.sh
    • Renamed dashboard section 'Contributions to this project' to 'GitHub activity on this project'.
    • Renamed dashboard section 'Contributions to all projects' to 'GitHub activity on all projects'.
    • Renamed dashboard section 'Contributor output on this project' to 'Commits to this project'.
    • Renamed dashboard section 'Contributor output on all projects' to 'Commits to all projects'.
    • Reordered dashboard sections to place 'GitHub activity' before 'AI sessions' and 'Commits'.
    • Corrected variable usage for displaying activity data in the dashboard sections.
Activity
  • The author, marcusquinn, provided a detailed summary outlining the problem of double-counting commits due to the --all flag in git log.
  • The solution involved removing the --all flag, which was verified to reduce inflated commit totals by approximately 12% for specific contributors.
  • Verification included testing the contributor-activity-helper.sh summary output, confirming it now matches git log without --all.
  • ShellCheck was run on both modified files, passing clean.
  • Quantitative data was provided to demonstrate the impact of the fix, showing 'Before (inflated)' vs. 'After (accurate)' commit counts for several contributors.
  • The pull request closes issue [Supervisor:alex-solovyev] 1 PR, 0 assigned, 1 worker at 17:30 UTC #4433.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 15, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1931e43a-506b-4c74-b915-67bbbdfa14d3

📥 Commits

Reviewing files that changed from the base of the PR and between b4cc565 and 269a152.

📒 Files selected for processing (1)
  • .agents/scripts/contributor-activity-helper.sh

Walkthrough

Updated contributor commit counting to use the repository's default branch (avoiding --all) and revised related labels and help text; remapped dashboard sections to swap which markdown sources render per-repo vs. cross-repo commit/activity displays.

Changes

Cohort / File(s) Summary
Commit counting & labels
.agents/scripts/contributor-activity-helper.sh
Added _resolve_default_branch and replaced --all with explicit default-branch git log queries to avoid double-counting squash-merged PR commits; renamed output columns and help text (Direct→Direct Pushes, PR Merges→PRs Merged, Total→Total Commits).
Dashboard mapping
.agents/scripts/stats-functions.sh
Remapped dashboard sections and their data sources: "GitHub activity on this/all projects" now uses person_stats_md / cross_repo_person_stats_md; "Commits to this/all projects" now uses activity_md / cross_repo_md. Labels updated accordingly.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🔧 Default branch chosen true and neat,
🧮 Commits counted once — no duplicate feat,
🔁 Dashboards swapped their source and name,
📈 Metrics tidy, tidy the game,
🎉 Scripts aligned — automation complete.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: removing double-counting from contribution metrics and improving clarity in reporting.
Linked Issues check ✅ Passed The PR successfully addresses the double-counting issue evident in #4433's contributor metrics and corrects inflated totals through git log scope changes.
Out of Scope Changes check ✅ Passed All changes directly address double-counting correction and metric clarity improvements outlined in issue #4433 without introducing unrelated modifications.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/fix-contribution-metrics
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Contributor

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 362 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Sun Mar 15 17:25:40 UTC 2026: Code review monitoring started
Sun Mar 15 17:25:41 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 362

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 362
  • VULNERABILITIES: 0

Generated on: Sun Mar 15 17:25:43 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly addresses the double-counting of commits by removing the --all flag from git log commands, ensuring that only commits on the default branch are considered. The renaming of dashboard sections and table headers also significantly improves clarity. I have a couple of suggestions to make the script more robust by explicitly determining the default branch name instead of relying on the script's execution context.

Comment on lines +131 to +133
local git_data
# shellcheck disable=SC2086
git_data=$(git -C "$repo_path" log --all --format='%ae|%ce|%aI' $since_arg) || git_data=""
git_data=$(git -C "$repo_path" log --format='%ae|%ce|%aI' $since_arg) || git_data=""

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To make this script more robust, it's better to explicitly specify the default branch for git log instead of relying on the script being run from a checkout of the default branch. You can determine the default branch name dynamically.

Suggested change
local git_data
# shellcheck disable=SC2086
git_data=$(git -C "$repo_path" log --all --format='%ae|%ce|%aI' $since_arg) || git_data=""
git_data=$(git -C "$repo_path" log --format='%ae|%ce|%aI' $since_arg) || git_data=""
local git_data default_branch
default_branch=$(git -C "$repo_path" symbolic-ref --short refs/remotes/origin/HEAD | sed 's@^origin/@@')
# shellcheck disable=SC2086
git_data=$(git -C "$repo_path" log "$default_branch" --format='%ae|%ce|%aI' $since_arg) || git_data=""

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 269a152 — added _resolve_default_branch() helper that tries origin/HEAD, then main/master, then HEAD as fallback. Applied to all three git log call sites.

Comment on lines +247 to +248
local git_data
git_data=$(git -C "$repo_path" log --all --format='%ae|%ce|%aI' --since='1.year.ago') || git_data=""
git_data=$(git -C "$repo_path" log --format='%ae|%ce|%aI' --since='1.year.ago') || git_data=""

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Similarly here, explicitly specifying the default branch will make the script more robust and not dependent on the current checkout state.

Suggested change
local git_data
git_data=$(git -C "$repo_path" log --all --format='%ae|%ce|%aI' --since='1.year.ago') || git_data=""
git_data=$(git -C "$repo_path" log --format='%ae|%ce|%aI' --since='1.year.ago') || git_data=""
local git_data default_branch
default_branch=$(git -C "$repo_path" symbolic-ref --short refs/remotes/origin/HEAD | sed 's@^origin/@@')
git_data=$(git -C "$repo_path" log "$default_branch" --format='%ae|%ce|%aI' --since='1.year.ago') || git_data=""

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also fixed in the same commit (269a152).

Address Gemini review feedback — git log without --all and without an
explicit branch name walks the current branch, which is wrong when
called from a worktree on a feature branch. Add _resolve_default_branch()
helper that tries origin/HEAD, then main/master, then HEAD as fallback.
Apply to all three git log call sites.
@marcusquinn marcusquinn merged commit 60aa4b1 into main Mar 15, 2026
12 of 14 checks passed
@marcusquinn marcusquinn deleted the refactor/fix-contribution-metrics branch March 15, 2026 17:31
@github-actions
Copy link
Contributor

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 362 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Sun Mar 15 17:31:49 UTC 2026: Code review monitoring started
Sun Mar 15 17:31:50 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 362

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 362
  • VULNERABILITIES: 0

Generated on: Sun Mar 15 17:31:52 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Auto-created from TODO.md tag review-feedback-scanned Merged PR already scanned for quality feedback

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Supervisor:alex-solovyev] 1 PR, 0 assigned, 1 worker at 17:30 UTC

1 participant