Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion .github/workflows/take.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,34 @@ jobs:
- uses: actions/github-script@v7
with:
script: |
github.rest.issues.addAssignees({
const issue = await github.rest.issues.get({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
})

if (issue.data.assignees.length > 0) {
core.info('The issue is already assigned; ignoring this `take` comment.')
return
}

const timeline = await github.paginate(github.rest.issues.listEventsForTimeline, {
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
per_page: 100,
})
const lastUnassignedIndex = timeline.findLastIndex(event => event.event === 'unassigned')
const firstTakeComment = timeline
.slice(lastUnassignedIndex + 1)
.find(event => event.event === 'commented' && event.body === 'take')

if (firstTakeComment?.id !== context.payload.comment.id) {

@klion26 klion26 Oct 21, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What will happen for the following case?

  1. Alice take the issue`
  2. Alice was unassigned because some reason(maybe she doesn't have time for now)
  3. Now the issue has no assignees
  4. What would happen if Bob comment take happen?

Seems the take in step 4 would not assign the issue to Bob? We search the previous comment here, as the take comment left by Alice is still there

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, you are correct. With the previous implementation, Bob would not be assigned because Alice's old take comment would remain the first take comment in the issue history.

I have updated the workflow to use the issue timeline. The latest unassigned event now starts a new claim period, so the behavior is:

  1. Alice comments take and is assigned.
  2. Alice is unassigned.
  3. Bob comments take.
  4. Bob is assigned because his comment is the first take after the latest unassignment.

If multiple users comment take during the same unassigned period, the first comment wins. If the issue already has an assignee, later take comments have no effect.

#4447 defines the expected first-comment-wins behavior, and #4268 is the issue where multiple assignees exposed the original problem.

I also updated CONTRIBUTING.md and tested initial assignment, existing assignment, re-claiming after unassignment, and concurrent claims.

core.info('An earlier `take` comment already claimed this issue.')
return
}

await github.rest.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
Expand Down
4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ to track it.
* Bug: A problem that prevents the project from functioning as intended.
* Subtask: A subtask of a Feature/Improvement that can be broken down into smaller steps.

You can assign the issue to yourself by leaving a comment with content `take`.
You can claim an unassigned issue by leaving a comment containing exactly `take`. Only the first
user to comment `take` while the issue is unassigned will be assigned. Later `take` comments have
no effect unless the assignee is removed.

## Pull requests

Expand Down
Loading