mirror of
https://github.com/all-contributors/cli.git
synced 2025-01-10 05:56:29 +00:00
feat: add review links (#213)
* feat: 🎸 add review links
* docs: add marceloalves to contributors
This commit is contained in:
parent
72de75abc5
commit
deee5d0a01
6 changed files with 35 additions and 3 deletions
|
@ -362,6 +362,15 @@
|
||||||
"bug",
|
"bug",
|
||||||
"code"
|
"code"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"login": "MarceloAlves",
|
||||||
|
"name": "Marcelo Alves",
|
||||||
|
"avatar_url": "https://avatars1.githubusercontent.com/u/216782?v=4",
|
||||||
|
"profile": "https://github.com/marceloalves",
|
||||||
|
"contributions": [
|
||||||
|
"code"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,6 +128,7 @@ Thanks goes to these wonderful people
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center"><a href="https://www.destro.me"><img src="https://avatars1.githubusercontent.com/u/7031675?v=4" width="100px;" alt="Fabrizio"/><br /><sub><b>Fabrizio</b></sub></a><br /><a href="https://github.com/all-contributors/all-contributors-cli/issues?q=author%3Adexpota" title="Bug reports">🐛</a> <a href="https://github.com/all-contributors/all-contributors-cli/commits?author=dexpota" title="Code">💻</a></td>
|
<td align="center"><a href="https://www.destro.me"><img src="https://avatars1.githubusercontent.com/u/7031675?v=4" width="100px;" alt="Fabrizio"/><br /><sub><b>Fabrizio</b></sub></a><br /><a href="https://github.com/all-contributors/all-contributors-cli/issues?q=author%3Adexpota" title="Bug reports">🐛</a> <a href="https://github.com/all-contributors/all-contributors-cli/commits?author=dexpota" title="Code">💻</a></td>
|
||||||
|
<td align="center"><a href="https://github.com/marceloalves"><img src="https://avatars1.githubusercontent.com/u/216782?v=4" width="100px;" alt="Marcelo Alves"/><br /><sub><b>Marcelo Alves</b></sub></a><br /><a href="https://github.com/all-contributors/all-contributors-cli/commits?author=MarceloAlves" title="Code">💻</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,15 @@ test('return link to issues', () => {
|
||||||
expect(formatContributionType(options, contributor, 'bug')).toBe(expected)
|
expect(formatContributionType(options, contributor, 'bug')).toBe(expected)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('return link to reviews', () => {
|
||||||
|
const contributor = contributors.kentcdodds
|
||||||
|
const {options} = fixtures()
|
||||||
|
const expected =
|
||||||
|
'<a href="https://github.com/all-contributors/all-contributors-cli/pulls?q=is%3Apr+reviewed-by%3Akentcdodds" title="Reviewed Pull Requests">👀</a>'
|
||||||
|
|
||||||
|
expect(formatContributionType(options, contributor, 'review')).toBe(expected)
|
||||||
|
})
|
||||||
|
|
||||||
test('make any symbol into a link if contribution is an object', () => {
|
test('make any symbol into a link if contribution is an object', () => {
|
||||||
const contributor = contributors.kentcdodds
|
const contributor = contributors.kentcdodds
|
||||||
const {options} = fixtures()
|
const {options} = fixtures()
|
||||||
|
|
|
@ -20,7 +20,7 @@ test('format a simple contributor', () => {
|
||||||
const {options} = fixtures()
|
const {options} = fixtures()
|
||||||
|
|
||||||
const expected =
|
const expected =
|
||||||
'<a href="http://kentcdodds.com"><img src="https://avatars1.githubusercontent.com/u/1500684" width="150px;" alt="Kent C. Dodds"/><br /><sub><b>Kent C. Dodds</b></sub></a><br /><a href="#review-kentcdodds" title="Reviewed Pull Requests">👀</a>'
|
'<a href="http://kentcdodds.com"><img src="https://avatars1.githubusercontent.com/u/1500684" width="150px;" alt="Kent C. Dodds"/><br /><sub><b>Kent C. Dodds</b></sub></a><br /><a href="https://github.com/all-contributors/all-contributors-cli/pulls?q=is%3Apr+reviewed-by%3Akentcdodds" title="Reviewed Pull Requests">👀</a>'
|
||||||
|
|
||||||
expect(formatContributor(options, contributor)).toBe(expected)
|
expect(formatContributor(options, contributor)).toBe(expected)
|
||||||
})
|
})
|
||||||
|
@ -30,7 +30,7 @@ test('format contributor with complex contribution types', () => {
|
||||||
const {options} = fixtures()
|
const {options} = fixtures()
|
||||||
|
|
||||||
const expected =
|
const expected =
|
||||||
'<a href="http://kentcdodds.com"><img src="https://avatars1.githubusercontent.com/u/1500684" width="150px;" alt="Kent C. Dodds"/><br /><sub><b>Kent C. Dodds</b></sub></a><br /><a href="https://github.com/all-contributors/all-contributors-cli/commits?author=kentcdodds" title="Documentation">📖</a> <a href="#review-kentcdodds" title="Reviewed Pull Requests">👀</a> <a href="#question-kentcdodds" title="Answering Questions">💬</a>'
|
'<a href="http://kentcdodds.com"><img src="https://avatars1.githubusercontent.com/u/1500684" width="150px;" alt="Kent C. Dodds"/><br /><sub><b>Kent C. Dodds</b></sub></a><br /><a href="https://github.com/all-contributors/all-contributors-cli/commits?author=kentcdodds" title="Documentation">📖</a> <a href="https://github.com/all-contributors/all-contributors-cli/pulls?q=is%3Apr+reviewed-by%3Akentcdodds" title="Reviewed Pull Requests">👀</a> <a href="#question-kentcdodds" title="Answering Questions">💬</a>'
|
||||||
|
|
||||||
expect(formatContributor(options, contributor)).toBe(expected)
|
expect(formatContributor(options, contributor)).toBe(expected)
|
||||||
})
|
})
|
||||||
|
@ -53,7 +53,7 @@ test('default image size to 100', () => {
|
||||||
delete options.imageSize
|
delete options.imageSize
|
||||||
|
|
||||||
const expected =
|
const expected =
|
||||||
'<a href="http://kentcdodds.com"><img src="https://avatars1.githubusercontent.com/u/1500684" width="100px;" alt="Kent C. Dodds"/><br /><sub><b>Kent C. Dodds</b></sub></a><br /><a href="#review-kentcdodds" title="Reviewed Pull Requests">👀</a>'
|
'<a href="http://kentcdodds.com"><img src="https://avatars1.githubusercontent.com/u/1500684" width="100px;" alt="Kent C. Dodds"/><br /><sub><b>Kent C. Dodds</b></sub></a><br /><a href="https://github.com/all-contributors/all-contributors-cli/pulls?q=is%3Apr+reviewed-by%3Akentcdodds" title="Reviewed Pull Requests">👀</a>'
|
||||||
|
|
||||||
expect(formatContributor(options, contributor)).toBe(expected)
|
expect(formatContributor(options, contributor)).toBe(expected)
|
||||||
})
|
})
|
||||||
|
|
|
@ -12,6 +12,8 @@ const SUPPORTED_REPO_TYPES = {
|
||||||
'<%= options.repoHost || "https://github.com" %>/<%= options.projectOwner %>/<%= options.projectName %>/commits?author=<%= contributor.login %>',
|
'<%= options.repoHost || "https://github.com" %>/<%= options.projectOwner %>/<%= options.projectName %>/commits?author=<%= contributor.login %>',
|
||||||
linkToIssues:
|
linkToIssues:
|
||||||
'<%= options.repoHost || "https://github.com" %>/<%= options.projectOwner %>/<%= options.projectName %>/issues?q=author%3A<%= contributor.login %>',
|
'<%= options.repoHost || "https://github.com" %>/<%= options.projectOwner %>/<%= options.projectName %>/issues?q=author%3A<%= contributor.login %>',
|
||||||
|
linkToReviews:
|
||||||
|
'<%= options.repoHost || "https://github.com" %>/<%= options.projectOwner %>/<%= options.projectName %>/pulls?q=is%3Apr+reviewed-by%3A<%= contributor.login %>',
|
||||||
getUserInfo: githubAPI.getUserInfo,
|
getUserInfo: githubAPI.getUserInfo,
|
||||||
getContributors: githubAPI.getContributors,
|
getContributors: githubAPI.getContributors,
|
||||||
},
|
},
|
||||||
|
@ -24,6 +26,8 @@ const SUPPORTED_REPO_TYPES = {
|
||||||
'<%= options.repoHost || "https://gitlab.com" %>/<%= options.projectOwner %>/<%= options.projectName %>/commits/master',
|
'<%= options.repoHost || "https://gitlab.com" %>/<%= options.projectOwner %>/<%= options.projectName %>/commits/master',
|
||||||
linkToIssues:
|
linkToIssues:
|
||||||
'<%= options.repoHost || "https://gitlab.com" %>/<%= options.projectOwner %>/<%= options.projectName %>/issues?author_username=<%= contributor.login %>',
|
'<%= options.repoHost || "https://gitlab.com" %>/<%= options.projectOwner %>/<%= options.projectName %>/issues?author_username=<%= contributor.login %>',
|
||||||
|
linkToReviews:
|
||||||
|
'<%= options.repoHost || "https://gitlab.com" %>/<%= options.projectOwner %>/<%= options.projectName %>/merge_requests?scope=all&state=all&approver_usernames[]=<%= contributor.login %>',
|
||||||
getUserInfo: gitlabAPI.getUserInfo,
|
getUserInfo: gitlabAPI.getUserInfo,
|
||||||
getContributors: gitlabAPI.getContributors,
|
getContributors: gitlabAPI.getContributors,
|
||||||
},
|
},
|
||||||
|
@ -77,6 +81,13 @@ const getLinkToIssues = function(repoType) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getLinkToReviews = function(repoType) {
|
||||||
|
if (repoType in SUPPORTED_REPO_TYPES) {
|
||||||
|
return SUPPORTED_REPO_TYPES[repoType].linkToReviews
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
const getUserInfo = function(username, repoType, repoHost) {
|
const getUserInfo = function(username, repoType, repoHost) {
|
||||||
if (repoType in SUPPORTED_REPO_TYPES) {
|
if (repoType in SUPPORTED_REPO_TYPES) {
|
||||||
return SUPPORTED_REPO_TYPES[repoType].getUserInfo(
|
return SUPPORTED_REPO_TYPES[repoType].getUserInfo(
|
||||||
|
@ -107,6 +118,7 @@ module.exports = {
|
||||||
getTypeName,
|
getTypeName,
|
||||||
getLinkToCommits,
|
getLinkToCommits,
|
||||||
getLinkToIssues,
|
getLinkToIssues,
|
||||||
|
getLinkToReviews,
|
||||||
getUserInfo,
|
getUserInfo,
|
||||||
getContributors,
|
getContributors,
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,6 +81,7 @@ const defaultTypes = function(repoType) {
|
||||||
review: {
|
review: {
|
||||||
symbol: '👀',
|
symbol: '👀',
|
||||||
description: 'Reviewed Pull Requests',
|
description: 'Reviewed Pull Requests',
|
||||||
|
link: repo.getLinkToReviews(repoType),
|
||||||
},
|
},
|
||||||
security: {
|
security: {
|
||||||
symbol: '🛡️',
|
symbol: '🛡️',
|
||||||
|
|
Loading…
Reference in a new issue