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

Added logic to check if a contributor has already contributed to good first issue #28

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Haimantika
Copy link

  1. Added a check to see if the assignee has already contributed to a good first issue.
  2. If the check if true, then it returns a message.

Closes #26.

action.yml Outdated
@@ -37,6 +42,18 @@ runs:
using: "composite"
steps:
- run: |
check_if_contributed_to_good_first_issue() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

refactor (blocking): for the good first issue check, all that needs to be checked is if they've ever contributed to the repository, regardless of the labels.

Copy link
Author

Choose a reason for hiding this comment

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

Would something like this make sense:

check_if_contributed_to_repository() {
           local assignee="$1"
           local response=$(curl -s -H "Authorization: token $GITHUB_PAT" "https://api.github.com/search/issues?q=is:pr+author:$assignee")
           local total_count=$(echo "$response" | jq -r '.total_count')

           if [ "$total_count" -gt 0 ]; then
               echo "true"
           else
               echo "false"
           fi
       }

Copy link
Collaborator

Choose a reason for hiding this comment

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

This checks all issues. What I'd suggest is not even PRs or issues. If they have at least one commit in the given project, that disqualifies them from contributing to a good first issue.

Here's a rough example care of ChatGPT (don't necessarily trust it)

# Set your GitHub username, repository name, owner username, and access token
USERNAME="your_username"
REPO="repository_name"
OWNER="repository_owner_username"
ACCESS_TOKEN="your_access_token"

# Make a cURL request to list commits in the repository by the specified user
curl -H "Authorization: token $ACCESS_TOKEN" \
     -H "Accept: application/vnd.github.v3+json" \
     "https://api.github.com/repos/$OWNER/$REPO/commits?author=$USERNAME"

# You can filter the response to check if the user has commits
# For example, you can use 'jq' to parse JSON response and count the number of commits
# Ensure you have 'jq' installed: https://stedolan.github.io/jq/download/
# Example:
# curl -H "Authorization: token $ACCESS_TOKEN" \
#      -H "Accept: application/vnd.github.v3+json" \
#      "https://api.github.com/repos/$OWNER/$REPO/commits?author=$USERNAME" | jq '. | length'

Copy link
Author

Choose a reason for hiding this comment

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

Okay this makes sense. Thanks for clarifying, I will try to take a look over the weekend.

Copy link
Collaborator

Choose a reason for hiding this comment

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

No rush @Haimantika, and thanks again for tackling this!

Copy link
Collaborator

Choose a reason for hiding this comment

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

@Haimantika, do you have a repository where you tested this? That would help speed up the review process.

Copy link
Author

Choose a reason for hiding this comment

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

Here you go - Haimantika/test_repo#6

Copy link
Collaborator

Choose a reason for hiding this comment

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

I created an issue without a good first issue label and I was able to take it, so existing functionality works. ✅

I tried taking an issue with a good first issue label however and it let me take it even though it previously didn't allow you to take it. See Haimantika/test_repo#6

Copy link
Author

Choose a reason for hiding this comment

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

@nickytonline I tried again now, works for me.

Copy link
Author

Choose a reason for hiding this comment

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

All the changes I made are in the workflow. If you think it is good to go, I will update the PR here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Add an optional setting to only allow new contributors to take good first issues
2 participants