implemented issueBranchRef
parent
eaa8758025
commit
115512f6ea
|
@ -20,3 +20,7 @@ issue number and optionally a `bug` label, resulting in the following format:
|
|||
|
||||
the prefix is either`feature` or `bugfix`. Whitespaces in the title are replaced by
|
||||
`-`.
|
||||
|
||||
### issueBranchRef
|
||||
|
||||
References matching branch to an existing issue.
|
|
@ -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 })
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue