Skip to content

Commit

Permalink
feat: add review links (#213)
Browse files Browse the repository at this point in the history
* feat: 🎸 add review links

* docs: add marceloalves to contributors
  • Loading branch information
MarceloAlves authored and Berkmann18 committed Nov 6, 2019
1 parent 72de75a commit deee5d0
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 3 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,15 @@
"bug",
"code"
]
},
{
"login": "MarceloAlves",
"name": "Marcelo Alves",
"avatar_url": "https://avatars1.githubusercontent.com/u/216782?v=4",
"profile": "https://github.com/marceloalves",
"contributions": [
"code"
]
}
]
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ Thanks goes to these wonderful people
</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://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>
</table>

Expand Down
9 changes: 9 additions & 0 deletions src/generate/__tests__/format-contribution-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ test('return link to issues', () => {
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', () => {
const contributor = contributors.kentcdodds
const {options} = fixtures()
Expand Down
6 changes: 3 additions & 3 deletions src/generate/__tests__/format-contributor.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test('format a simple contributor', () => {
const {options} = fixtures()

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)
})
Expand All @@ -30,7 +30,7 @@ test('format contributor with complex contribution types', () => {
const {options} = fixtures()

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)
})
Expand All @@ -53,7 +53,7 @@ test('default image size to 100', () => {
delete options.imageSize

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)
})
Expand Down
12 changes: 12 additions & 0 deletions src/repo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const SUPPORTED_REPO_TYPES = {
'<%= options.repoHost || "https://github.com" %>/<%= options.projectOwner %>/<%= options.projectName %>/commits?author=<%= contributor.login %>',
linkToIssues:
'<%= 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,
getContributors: githubAPI.getContributors,
},
Expand All @@ -24,6 +26,8 @@ const SUPPORTED_REPO_TYPES = {
'<%= options.repoHost || "https://gitlab.com" %>/<%= options.projectOwner %>/<%= options.projectName %>/commits/master',
linkToIssues:
'<%= 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,
getContributors: gitlabAPI.getContributors,
},
Expand Down Expand Up @@ -77,6 +81,13 @@ const getLinkToIssues = function(repoType) {
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) {
if (repoType in SUPPORTED_REPO_TYPES) {
return SUPPORTED_REPO_TYPES[repoType].getUserInfo(
Expand Down Expand Up @@ -107,6 +118,7 @@ module.exports = {
getTypeName,
getLinkToCommits,
getLinkToIssues,
getLinkToReviews,
getUserInfo,
getContributors,
}
1 change: 1 addition & 0 deletions src/util/contribution-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const defaultTypes = function(repoType) {
review: {
symbol: '👀',
description: 'Reviewed Pull Requests',
link: repo.getLinkToReviews(repoType),
},
security: {
symbol: '🛡️',
Expand Down

0 comments on commit deee5d0

Please sign in to comment.