Skip to content

feat: support adding people with mentions #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/utils/parse-comment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const plugin = {
nlp.plugin(plugin)

function parseAddComment(doc, action) {
const who = doc
const whoMatched = doc
.match(`${action} [.]`)
.normalize({
whitespace: true, // remove hyphens, newlines, and force one space between words
Expand All @@ -75,6 +75,8 @@ function parseAddComment(doc, action) {
})
.data()[0].text

const who = whoMatched.startsWith('@') ? whoMatched.substr(1) : whoMatched
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:+1


// TODO: handle plurals (e.g. some said docs)
let contributions = doc
.match('#Contribution')
Expand Down
12 changes: 12 additions & 0 deletions test/utils/parse-comment/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ describe('parseComment', () => {
})
})

test('Support adding people with mentions', () => {
expect(
parseComment(
`@${testBotName} please add @sinchang for infrastructure`,
),
).toEqual({
action: 'add',
who: 'sinchang',
contributions: ['infra'],
})
})

// TODO: make it so this works
// test('Support split words (like user testing)', () => {
// expect(
Expand Down