Offline gym log for Android. No account, no ads, no internet.
Dart androidbodybuildingdartexercisesf-droidfitnessfluttergymgym-apphealthprivacyself-hostedworkoutworkout-appworkout-tracker
ci: /claim, /unclaim and /approved issue commands
InlitX7bcf4422b82a
diff --git a/.github/workflows/claim.yml b/.github/workflows/claim.ymlindex 449dfc6..5f88293 100644--- a/.github/workflows/claim.yml+++ b/.github/workflows/claim.yml@@ -1,34 +1,31 @@-# /claim and /unclaim for issues.+# Issue commands, written as a comment on the issue:#-# - `/claim` on an issue labelled `approved` assigns the commenter.-# - `/claim` on an issue that is not approved yet labels it `claim-pending`;-# when the owner adds `approved`, the first person who claimed it is assigned.-# - `/unclaim` removes the commenter from the issue.+# /claim ask to work on the issue+# /unclaim step back from it+# /approved (maintainers only, also /approve) approve the issue+#+# Nobody is assigned until a maintainer approves the issue. Approving adds the+# `approved` label and assigns the first person who claimed it; after that, the+# next /claim is assigned straight away.## Only the event payload and the API are read; no code from the repo is run.-name: Claim+name: Issue commandson:issue_comment:types: [created]- issues:- types: [labeled]permissions:issues: writeconcurrency:- group: claim-${{ github.event.issue.number }}+ group: issue-commands-${{ github.event.issue.number }}cancel-in-progress: falsejobs:- claim:- if: >-- (github.event_name == 'issue_comment' &&- github.event.issue.pull_request == null &&- github.event.comment.user.type == 'User') ||- (github.event_name == 'issues' && github.event.label.name == 'approved')+ command:+ if: github.event.issue.pull_request == null && github.event.comment.user.type == 'User'runs-on: ubuntu-lateststeps:- uses: actions/github-script@v9@@ -36,55 +33,77 @@ jobs:script: |const { owner, repo } = context.repo;const issue = context.payload.issue;+ const comment = context.payload.comment;const number = issue.number;+ const login = comment.user.login;const APPROVED = 'approved';const PENDING = 'claim-pending';- const labels = () => issue.labels.map(l => l.name);+ const command = comment.body.trim().toLowerCase();+ const labels = issue.labels.map(l => l.name);+ const assignees = issue.assignees.map(a => a.login);const reply = body =>github.rest.issues.createComment({ owner, repo, issue_number: number, body });- const isCommand = (text, cmd) => text.trim().toLowerCase() === cmd;- const assignees = issue.assignees.map(a => a.login);async function removePending() {- if (!labels().includes(PENDING)) return;- await github.rest.issues.removeLabel({ owner, repo, issue_number: number, name: PENDING })+ if (!labels.includes(PENDING)) return;+ await github.rest.issues+ .removeLabel({ owner, repo, issue_number: number, name: PENDING }).catch(() => {});}- async function assign(login) {- await github.rest.issues.addAssignees({ owner, repo, issue_number: number, assignees: [login] });+ async function assign(who) {+ await github.rest.issues.addAssignees({ owner, repo, issue_number: number, assignees: [who] });await removePending();- await reply(`@${login}, this issue is now yours. Thanks for helping! When you open the pull request, link it with \`Fixes #${number}\`. If you can't finish it, comment \`/unclaim\` so someone else can take it.`);}- // The owner approved an issue: hand it to the first pending claim.- if (context.eventName === 'issues') {- if (assignees.length > 0) return;+ const assignedText = who =>+ `@${who}, this issue is now yours. Thanks for helping! Link your pull request with \`Fixes #${number}\`. If you can't finish it, comment \`/unclaim\` so someone else can take it.`;++ // ---------- /approved (maintainers only) ----------+ if (command === '/approved' || command === '/approve') {+ const role = comment.author_association;+ if (!['OWNER', 'MEMBER', 'COLLABORATOR'].includes(role)) {+ await reply(`@${login}, only the maintainer can approve issues.`);+ return;+ }+ if (labels.includes(APPROVED)) return;+ await github.rest.issues.addLabels({ owner, repo, issue_number: number, labels: [APPROVED] });++ if (assignees.length > 0) {+ await reply('✅ Approved.');+ return;+ }+ // Hand it to the first person who claimed it and didn't step back.const comments = await github.paginate(github.rest.issues.listComments, {owner, repo, issue_number: number, per_page: 100,});let claimer = null;for (const c of comments) {if (c.user.type !== 'User') continue;- if (isCommand(c.body, '/claim')) claimer = claimer ?? c.user.login;- if (isCommand(c.body, '/unclaim') && c.user.login === claimer) claimer = null;+ const text = c.body.trim().toLowerCase();+ if (text === '/claim' && !claimer) claimer = c.user.login;+ if (text === '/unclaim' && c.user.login === claimer) claimer = null;+ }+ if (claimer) {+ await assign(claimer);+ await reply(`✅ Approved. ${assignedText(claimer)}`);+ } else {+ await reply('✅ Approved. Anyone who wants to work on it can comment `/claim`.');}- if (claimer) await assign(claimer);return;}- const comment = context.payload.comment;- const login = comment.user.login;-- if (isCommand(comment.body, '/unclaim')) {+ // ---------- /unclaim ----------+ if (command === '/unclaim') {if (!assignees.includes(login)) return;await github.rest.issues.removeAssignees({ owner, repo, issue_number: number, assignees: [login] });await reply(`@${login} is no longer assigned. This issue is free to \`/claim\` again.`);return;}- if (!isCommand(comment.body, '/claim')) return;+ // ---------- /claim ----------+ if (command !== '/claim') return;if (issue.state === 'closed') {await reply(`@${login}, this issue is closed, so it can't be claimed.`);@@ -92,16 +111,15 @@ jobs:}if (assignees.includes(login)) return;if (assignees.length > 0) {- await reply(`@${login}, this issue is already assigned to @${assignees[0]}. If it goes quiet for a while, feel free to ask here.`);+ await reply(`@${login}, this issue is already assigned to @${assignees[0]}.`);return;}- if (labels().includes(APPROVED)) {+ if (labels.includes(APPROVED)) {await assign(login);+ await reply(assignedText(login));return;}-- // Not approved yet: keep the claim and wait for the owner.- if (!labels().includes(PENDING)) {+ if (!labels.includes(PENDING)) {await github.rest.issues.addLabels({ owner, repo, issue_number: number, labels: [PENDING] });}- await reply(`Thanks @${login}! This issue hasn't been approved yet. Your claim is saved: if it gets approved, you'll be assigned automatically. If it isn't approved, it won't be worked on.`);+ await reply(`Thanks @${login}! Your claim is saved. This issue isn't approved yet: nobody is assigned until the maintainer approves it. If it's approved, you'll be assigned automatically; if not, it won't be worked on.`);diff --git a/.github/workflows/issue-responder.yml b/.github/workflows/issue-responder.ymlindex b173c78..ae9fb5c 100644--- a/.github/workflows/issue-responder.yml+++ b/.github/workflows/issue-responder.yml@@ -22,7 +22,7 @@ jobs:'','- **Duplicate?** If there is already an issue about this, please comment there instead (extra details, or just "it happens to me too").','- **Response time:** GymMane is made by a student, so replies can take a while, but every issue gets read. Thanks for your patience!',- '- **Want to work on it?** Comment `/claim`. If the issue is approved, it is yours; if not, it won\'t be done.',+ '- **Want to work on it?** Comment `/claim`. Nobody is assigned until the maintainer approves the issue: if it is approved, it is yours; if not, it won\'t be done.',].join('\n');await github.rest.issues.createComment({owner: context.repo.owner,diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 4168b0d..7383968 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -14,6 +14,23 @@- **Translations:** edit the `.arb` file of your language and send a pullrequest, see [TRANSLATING.md](TRANSLATING.md).+## Working on an issue++Comment on the issue to use these commands:++| Command | What it does |+|---|---|+| `/claim` | Ask to work on the issue. |+| `/unclaim` | Step back so someone else can take it. |++**Nobody is assigned until the maintainer approves the issue** with `/approved`,+no matter how many claims or comments it has. Once it is approved, the first+person who claimed it is assigned automatically, and later claims on an approved,+unassigned issue are assigned straight away. If an issue is not approved, it+won't be worked on.++GymMane is made by a student, so reviews can take a while. Thanks for your patience!+## Two rules that never bend1. **No accounts, no logins, no remote user data.** Ever.