implemented issueBranchRef
nclazz/gitea-bot/pipeline/head This commit looks good Details

master
Niclas Thobaben 2022-07-09 01:06:27 +02:00
parent eaa8758025
commit 115512f6ea
2 changed files with 17 additions and 3 deletions

View File

@ -19,4 +19,8 @@ issue number and optionally a `bug` label, resulting in the following format:
> `feature/{issue}-{title}`
the prefix is either`feature` or `bugfix`. Whitespaces in the title are replaced by
`-`.
`-`.
### issueBranchRef
References matching branch to an existing issue.

View File

@ -1,3 +1,5 @@
const gitea = require('../gitea-api')
const log = (msg) => {
console.log('[issueBranchRef]', msg)
}
@ -5,10 +7,18 @@ const log = (msg) => {
module.exports = {
exec: (req) => {
if(req.headers['x-gitea-event'] !== 'issues') {
if(req.headers['x-gitea-event'] !== 'push') {
return
}
log('issue branch ref')
const { ref, repository } = req.body
log(`Try referencing ref ${ref} to issue`)
const regex = /refs\/heads\/(feature|bugfix)\/(\d+)-/
const issueId = regex.exec(ref)[2]
const path = `/repos/${repository.full_name}/issues/${issueId}`
gitea.patch(path, { ref })
}
}