-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
425 additions
and
346 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* @file PR 自动根据 tag 去添加 reviewer | ||
* @author xuexb <fe.xiaowu@gmail.com> | ||
*/ | ||
|
||
const { getPkgConfig } = require('../../utils') | ||
const { createReviewRequest } = require('../../github') | ||
|
||
const config = getPkgConfig() | ||
const assignMap = config.labelToAuthor || {} | ||
|
||
module.exports = { | ||
name: 'pullRequest/autoReviewRequest', | ||
register (on) { | ||
on('pull_request_labeled', ({payload}) => { | ||
if (assignMap[payload.label.name]) { | ||
createReviewRequest( | ||
payload, | ||
{ | ||
reviewers: assignMap[payload.label.name] | ||
} | ||
) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* @file PR 提示标题正确性 | ||
* @author xuexb <fe.xiaowu@gmail.com> | ||
*/ | ||
|
||
const format = require('string-template') | ||
const { getPkgCommitPrefix } = require('../../utils') | ||
const { | ||
commentPullRequest, | ||
addLabelsToPullRequest, | ||
removeLabelsToPullRequest, | ||
pullRequestHasLabel | ||
} = require('../../github') | ||
|
||
const actions = getPkgCommitPrefix() | ||
const match = title => { | ||
return actions.some(action => title.indexOf(`${action}:`) === 0) | ||
} | ||
|
||
const commentSuccess = [ | ||
'hi @{user},非常感谢您及时修正标题格式,祝您玩的开心!' | ||
].join('') | ||
|
||
const commentError = [ | ||
'hi @{user},非常感谢您的 PR ,', | ||
'但是您没有使用 [PR 标题规则](https://github.com/xuexb/github-bot#commit-log-和-pr-标题规则) 格式,', | ||
'请及时修改, 谢谢!' | ||
].join('') | ||
|
||
module.exports = { | ||
name: 'pullRequest/replyInvaidTitle', | ||
register (on) { | ||
if (actions.length) { | ||
on('pull_request_opened', ({ payload, repo }) => { | ||
if (!match(payload.pull_request.title)) { | ||
commentPullRequest( | ||
payload, | ||
format(commentError, { | ||
user: payload.pull_request.user.login | ||
}) | ||
) | ||
|
||
addLabelsToPullRequest(payload, 'invalid') | ||
} | ||
}) | ||
|
||
on('pull_request_edited', async ({ payload, repo }) => { | ||
if (match(payload.pull_request.title) && await pullRequestHasLabel(payload, 'invalid')) { | ||
commentPullRequest( | ||
payload, | ||
format(commentSuccess, { | ||
user: payload.pull_request.user.login | ||
}) | ||
) | ||
|
||
removeLabelsToPullRequest(payload, 'invalid') | ||
} | ||
}) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.