From: Timo Rothenpieler <code@ffmpeg.org> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH] forgejo/autolabeler: add some logic to also auto-remove the "New" label (PR #20186) Date: Fri, 8 Aug 2025 23:49:12 +0300 (EEST) Message-ID: <20250808204912.C346768CD36@ffbox0-bg.ffmpeg.org> (raw) PR #20186 opened by Timo Rothenpieler (BtbN) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20186 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20186.patch From b5ab096897e92a56642a17a6ef212620f5c7d79b Mon Sep 17 00:00:00 2001 From: Timo Rothenpieler <timo@rothenpieler.org> Date: Fri, 8 Aug 2025 21:37:20 +0200 Subject: [PATCH] forgejo/autolabeler: add some logic to also auto-remove the "New" label --- .forgejo/labeler/labeler.js | 48 ++++++++++++++++++++++++++++---- .forgejo/workflows/autolabel.yml | 7 +++-- 2 files changed, 47 insertions(+), 8 deletions(-) diff --git a/.forgejo/labeler/labeler.js b/.forgejo/labeler/labeler.js index 7e17c4167c..b1c05787f0 100644 --- a/.forgejo/labeler/labeler.js +++ b/.forgejo/labeler/labeler.js @@ -1,6 +1,7 @@ module.exports = async ({github, context}) => { const title = (context.payload.pull_request?.title || context.payload.issue?.title || '').toLowerCase(); const labels = []; + const issueNumber = context.payload.pull_request?.number || context.payload.issue?.number; const kwmap = { 'avcodec': 'avcodec', @@ -13,15 +14,50 @@ module.exports = async ({github, context}) => { 'fftools': 'CLI' }; - if (context.payload.action === 'opened') { + async function isOrgMember(username) { + try { + const response = await github.rest.orgs.checkMembershipForUser({ + org: context.repo.owner, + username: username + }); + return response.status === 204; + } catch (error) { + return false; + } + } + + if (context.payload.action === 'closed' || + (context.payload.action !== 'opened' && ( + context.payload.action === 'assigned' || + context.payload.action === 'label_updated' || + context.payload.comment) && + await isOrgMember(context.payload.sender.login)) + ) { + try { + await github.rest.issues.removeLabel({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issueNumber, + // this should say 'new', but forgejo deviates from GitHub API here and expects the ID + name: '41' + }); + console.log('Removed "new" label'); + } catch (error) { + if (error.status !== 404 && error.status !== 410) { + console.log('Could not remove "new" label'); + } + } + } else if (context.payload.action === 'opened') { labels.push('new'); console.log('Detected label: new'); } - for (const [kw, label] of Object.entries(kwmap)) { - if (title.includes(kw)) { - labels.push(label); - console.log('Detected label: ' + label); + if ((context.payload.action === 'opened' || context.payload.action === 'edited') && context.eventName !== 'issue_comment') { + for (const [kw, label] of Object.entries(kwmap)) { + if (title.includes(kw)) { + labels.push(label); + console.log('Detected label: ' + label); + } } } @@ -29,7 +65,7 @@ module.exports = async ({github, context}) => { await github.rest.issues.addLabels({ owner: context.repo.owner, repo: context.repo.repo, - issue_number: context.payload.pull_request?.number || context.payload.issue?.number, + issue_number: issueNumber, labels: labels, }); } diff --git a/.forgejo/workflows/autolabel.yml b/.forgejo/workflows/autolabel.yml index 3eb8cd52ba..cb4dac67aa 100644 --- a/.forgejo/workflows/autolabel.yml +++ b/.forgejo/workflows/autolabel.yml @@ -1,12 +1,15 @@ on: pull_request_target: - types: [opened, edited, synchronize] + types: [opened, edited, synchronize, closed, assigned, labeled, unlabeled] issues: - types: [opened, edited] + types: [opened, edited, closed, assigned, labeled, unlabeled] + issue_comment: + types: [created] jobs: pr_labeler: runs-on: utilities + if: ${{ github.event.sender.login != 'ffmpeg-devel' }} steps: - name: Checkout uses: actions/checkout@v4 -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
reply other threads:[~2025-08-08 20:49 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20250808204912.C346768CD36@ffbox0-bg.ffmpeg.org \ --to=code@ffmpeg.org \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git