You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by ad...@apache.org on 2026/03/02 20:08:37 UTC

(fineract) branch develop updated: Fineract-2462: added one commit per user check

This is an automated email from the ASF dual-hosted git repository.

adamsaghy pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git


The following commit(s) were added to refs/heads/develop by this push:
     new 3288a5a324 Fineract-2462: added one commit per user check
3288a5a324 is described below

commit 3288a5a32461ec47675aaa2a9b477865b3404257
Author: edk12564 <ed...@gmail.com>
AuthorDate: Fri Feb 6 03:55:30 2026 -0600

    Fineract-2462: added one commit per user check
    
    - added commit check
    - accounted for edge case where git and github emails don't match
    - accounted for edge case where wrong git account hasn't squashed
    
    DesignedBy: Edward Kang and Aman Mittal
    ReviewedBy: Aman Mittal
    ReportedBy: Aman Mittal
---
 .github/workflows/pr-one-commit-per-user-check.yml | 57 ++++++++++++++++++++++
 1 file changed, 57 insertions(+)

diff --git a/.github/workflows/pr-one-commit-per-user-check.yml b/.github/workflows/pr-one-commit-per-user-check.yml
new file mode 100644
index 0000000000..3025a9d75f
--- /dev/null
+++ b/.github/workflows/pr-one-commit-per-user-check.yml
@@ -0,0 +1,57 @@
+name: Fineract PR One Commit Per User Check
+
+
+on:
+ pull_request:
+   types: [opened, reopened, synchronize]
+
+
+permissions:
+ pull-requests: write
+
+
+jobs:
+ verify-commits:
+   name: Validate One Commit Per User
+   runs-on: ubuntu-latest
+   timeout-minutes: 1
+   steps:
+     - name: Verify Commit Policy
+       id: check
+       env:
+         GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+       run: |
+
+         commits=$(gh api "repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/commits") || { echo "::error::GitHub API request failed"; exit 1; }
+
+         if echo "$commits" | jq -e '.[] | select(.author == null)' > /dev/null; then
+           echo "null_authors=true" >> $GITHUB_OUTPUT
+           echo "::error::Some commits have a git email that is not linked to a GitHub account. Please ensure your git email matches one of your GitHub Account emails.\n\nPlease also squash your commits to prevent this message again."
+           exit 1
+         fi
+
+         user_ids=$(echo "$commits" | jq -r '.[] | select(.author.type != "Bot") | .author.id')
+         if echo "$user_ids" | sort | uniq -d | grep -q .; then
+           echo "multiple_commits=true" >> $GITHUB_OUTPUT
+           echo "::error::Multiple commits from the same author have been detected."
+           exit 1
+         fi
+
+         echo "Success: Each author has exactly one commit."
+
+     - name: Comment on PR
+       if: failure()
+       env:
+         GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+       run: |
+
+         if [ "${{ steps.check.outputs.null_authors }}" == "true" ]; then
+           gh pr comment ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --body \
+         $'**One Commit Per User Check Failed**\n\nSome committers have a git email that does not match their GitHub account. Please ensure your git email matches one of your GitHub Account emails. Please also squash your commits to prevent this message again.'
+         fi
+
+
+         if [ "${{ steps.check.outputs.multiple_commits }}" == "true" ]; then
+           gh pr comment ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --body \
+         $'**One Commit Per User Check Failed**\n\nEach user may only have one commit per PR. Please squash your commits.'
+         fi