Skip to content

Commit d01c0d3

Browse files
petern48martin-g
andauthored
chore: Support 'untake' for unassigning github issues (apache#18637)
## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123. --> - Closes apache#18574 ## Rationale for this change <!-- Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed. Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes. --> See the issue; tldr we couldn't do it before, and it sometimes leads me to start work on something without 'take'-ing it ## What changes are included in this PR? <!-- There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR. --> Adds support for 'untake' command to allow contributors to manually unassign themselves. Previously they would have to ask a committer to unassign them ## Are these changes tested? <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> I tested this exact file in a personal repo I created. See [here](petern48/test-repo#1) ## Are there any user-facing changes? <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. --> No, only for contributors <!-- If there are any breaking changes to public APIs, please add the `api change` label. --> --------- Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
1 parent b1af8fe commit d01c0d3

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

.github/workflows/take.yml

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
name: Assign the issue via a `take` comment
18+
name: Assign/unassign the issue via `take` or `untake` comment
1919
on:
2020
issue_comment:
2121
types: created
@@ -26,16 +26,30 @@ permissions:
2626
jobs:
2727
issue_assign:
2828
runs-on: ubuntu-latest
29-
if: (!github.event.issue.pull_request) && github.event.comment.body == 'take'
29+
if: (!github.event.issue.pull_request) && (github.event.comment.body == 'take' || github.event.comment.body == 'untake')
3030
concurrency:
3131
group: ${{ github.actor }}-issue-assign
3232
steps:
33-
- run: |
34-
CODE=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -LI https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/assignees/${{ github.event.comment.user.login }} -o /dev/null -w '%{http_code}\n' -s)
35-
if [ "$CODE" -eq "204" ]
33+
- name: Take or untake issue
34+
env:
35+
COMMENT_BODY: ${{ github.event.comment.body }}
36+
ISSUE_NUMBER: ${{ github.event.issue.number }}
37+
USER_LOGIN: ${{ github.event.comment.user.login }}
38+
REPO: ${{ github.repository }}
39+
TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
run: |
41+
if [ "$COMMENT_BODY" == "take" ]
3642
then
37-
echo "Assigning issue ${{ github.event.issue.number }} to ${{ github.event.comment.user.login }}"
38-
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -d '{"assignees": ["${{ github.event.comment.user.login }}"]}' https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/assignees
39-
else
40-
echo "Cannot assign issue ${{ github.event.issue.number }} to ${{ github.event.comment.user.login }}"
43+
CODE=$(curl -H "Authorization: token $TOKEN" -LI https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/assignees/$USER_LOGIN -o /dev/null -w '%{http_code}\n' -s)
44+
if [ "$CODE" -eq "204" ]
45+
then
46+
echo "Assigning issue $ISSUE_NUMBER to $USER_LOGIN"
47+
curl -X POST -H "Authorization: token $TOKEN" -H "Content-Type: application/json" -d "{\"assignees\": [\"$USER_LOGIN\"]}" https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/assignees
48+
else
49+
echo "Cannot assign issue $ISSUE_NUMBER to $USER_LOGIN"
50+
fi
51+
elif [ "$COMMENT_BODY" == "untake" ]
52+
then
53+
echo "Unassigning issue $ISSUE_NUMBER from $USER_LOGIN"
54+
curl -X DELETE -H "Authorization: token $TOKEN" -H "Content-Type: application/json" -d "{\"assignees\": [\"$USER_LOGIN\"]}" https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/assignees
4155
fi

docs/source/contributor-guide/index.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,8 @@ If you want to work on an issue which is not already assigned to someone else
5959
and there are no comment indicating that someone is already working on that
6060
issue then you can assign the issue to yourself by submitting a single word
6161
comment `take`. This will assign the issue to yourself. However, if you are
62-
unable to make progress you should unassign the issue by using the `unassign me`
63-
link at the top of the issue page (and ask for help if are stuck) so that
64-
someone else can get involved in the work.
62+
unable to make progress you should unassign the issue by commenting a single
63+
word `untake`.
6564

6665
# Developer's guide
6766

0 commit comments

Comments
 (0)