24 lines
549 B
JavaScript
24 lines
549 B
JavaScript
const gitea = require('../gitea-api')
|
|
|
|
const log = (msg) => {
|
|
console.log('[issueBranchRef]', msg)
|
|
}
|
|
|
|
module.exports = {
|
|
|
|
exec: (req) => {
|
|
if(req.headers['x-gitea-event'] !== 'push') {
|
|
return
|
|
}
|
|
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 })
|
|
}
|
|
|
|
} |