Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fixed typo && pullrequest reviewers reference * added WebStrom ".idea" files to .gitignore (as in Kibibit code-editor) * added "Helping Hand" achievement * changed commit.creator to commit author and _.includes to _.find * added commiter achievement in addition to reviewer achievement * added reviewer(s) name(s) to committer achievement and vice versa * changing _.find to the right syntax * general fixes for helping hand achievement - don't give the creator the reviewer's achievement - remove the brackets for `isMultipleCommittedReviewers` - fix usernames in each other's achievements * add reviewers to the allPRUsers variable
- Loading branch information
Showing
7 changed files
with
63 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
|
||
node_modules/ | ||
logs/ | ||
logs/ | ||
.idea/ |
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,58 @@ | ||
var _ = require('lodash'); | ||
|
||
var helpingHand = { | ||
name: 'Helping Hand', | ||
check: function(pullRequest, shall) { | ||
var committedReviewers = reviewersWhoCommittedToPullRequest(pullRequest); | ||
|
||
if (!_.isEmpty(committedReviewers)) { | ||
|
||
var isMultipleCommittedReviewers = committedReviewers.length > 1 ? 's ' : ' '; | ||
|
||
var reviewerAchievement = { | ||
avatar: 'images/achievements/helpingHandHelloThere.achievement.jpg', | ||
name: 'Helping Hand', | ||
short: 'Hello there. Slow going?', | ||
description: [ | ||
'You\'ve committed to ', pullRequest.creator.username, | ||
'\'s Pull Request you are reviewing' | ||
].join(''), | ||
relatedPullRequest: pullRequest._id | ||
}; | ||
|
||
var committerAchievement = { | ||
avatar: 'images/achievements/helpingHandManInBlack.achievement.jpg', | ||
name: 'Helping Hand', | ||
short: 'Look, I don\'t mean to be rude but this is not as easy as it looks', | ||
description: [ | ||
'Your reviewer', isMultipleCommittedReviewers, | ||
_.map(committedReviewers, 'username').join(', '), | ||
' committed to your Pull Request' | ||
].join(''), | ||
relatedPullRequest: pullRequest._id | ||
}; | ||
|
||
_.forEach(committedReviewers, function(reviewer) { | ||
shall.grant(reviewer.username, reviewerAchievement); | ||
}); | ||
|
||
shall.grant(pullRequest.creator.username, committerAchievement); | ||
} | ||
} | ||
}; | ||
|
||
|
||
function reviewersWhoCommittedToPullRequest(pullRequest) { | ||
var committedReviewers = []; | ||
|
||
_.forEach(pullRequest.commits, function(commit) { | ||
if (commit.author.username !== pullRequest.creator.username && | ||
_.find(pullRequest.reviewers, {username: commit.author.username})) { | ||
committedReviewers.push(commit.author); | ||
} | ||
}); | ||
|
||
return committedReviewers; | ||
} | ||
|
||
module.exports = helpingHand; |
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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.