Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE]: Git Co-Author - GitHub actions #892

Open
surapuramakhil opened this issue Nov 20, 2024 · 0 comments
Open

[FEATURE]: Git Co-Author - GitHub actions #892

surapuramakhil opened this issue Nov 20, 2024 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@surapuramakhil
Copy link
Collaborator

surapuramakhil commented Nov 20, 2024

Feature summary

Problem to fix when commits are sqashed.

Feature description

this is a common problem - when commits are squashed during PR merges - credit for original contributors gets lot.

git co-author is for that

https://www.dormant.ninja/git-co-author-script/

draft co author - github CI

name: Add Co-Authors
on:
  pull_request:
    types: [closed]
jobs:
  add-coauthors:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3
      - name: Add co-authors
        run: |
          # Extract contributors and append as co-authors (refer script)
          
# Define the base branch (e.g., main or master)
BASE_BRANCH=main

# Find the merge base (divergence point) between the current branch and the base branch
MERGE_BASE=$(git merge-base HEAD $BASE_BRANCH)

# Extract contributors from the commits starting at the merge base up to HEAD
CONTRIBUTORS=$(git log $MERGE_BASE..HEAD --format='%aN <%aE>' | sort | uniq)

# Output or append contributors as Co-authored-by lines
for CONTRIBUTOR in $CONTRIBUTORS; do
  echo "Co-authored-by: $CONTRIBUTOR"
done

Motivation

No response

Alternatives considered

No response

Additional context

No response

@surapuramakhil surapuramakhil added the enhancement New feature or request label Nov 20, 2024
@surapuramakhil surapuramakhil added planned planned goal and removed planned planned goal labels Nov 20, 2024
@surapuramakhil surapuramakhil changed the title [FEATURE]: Git Co-Author helper commit.template [FEATURE]: Git Co-Author - GitHub actions Nov 22, 2024
@surapuramakhil surapuramakhil added the good first issue Good for newcomers label Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
Status: No status
Development

No branches or pull requests

1 participant