Skip to content
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

Exclude commit description from issue titles and add $AUTHOR value for issue templates #186

Merged
merged 2 commits into from
Feb 28, 2018
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
5 changes: 3 additions & 2 deletions lib/create-issue.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
module.exports = createIssue

function createIssue (state) {
const {filename, patch, branchUrl} = state.commit
const {filename, patch, branchUrl, message, authorLogin} = state.commit
const content = state.template
.replace(/\$DIFF/, patch)
.replace(/\$FILENAME/, filename)
.replace(/\$BRANCH_URL/, branchUrl)
.replace(/\$REPO/, state.installRepo)
.replace(/\$AUTHOR/, `@${authorLogin}`)

state.debug('creating issue...')

return state.api.issues.create({
owner: state.owner,
repo: state.issueRepo,
title: state.commit.message,
title: message.split('\n\n')[0],
body: content,
labels: state.labels
})
Expand Down
3 changes: 2 additions & 1 deletion lib/get-commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ function getCommit (state) {
message: result.data.commit.message,
filename,
patch,
branchUrl: branchUrl
branchUrl: branchUrl,
authorLogin: result.data.author.login
}

state.debug(`found commit "${state.commit.message}". Changed file "${filename}" Found branchUrl "${state.commit.branchUrl}"`)
Expand Down
3 changes: 2 additions & 1 deletion test/unit/create-issue-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test('create issue request succeeds', t => {
sha: 'sha',
labels: 'label-1',
commit: {
message: 'title',
message: 'title\n\ndescription',
patch: 'patch',
filename: 'filename',
branchUrl: 'branchUrl'
Expand All @@ -39,6 +39,7 @@ test('create issue request succeeds', t => {
.then((response) => {
const createIssueArgs = api.issues.create.lastCall.arg
t.is(response.data.html_url, 'html_url')
t.is(createIssueArgs.title, 'title')
t.is(createIssueArgs.body, 'test value1: patch value2: filename value3: branchUrl value4: installRepo')
t.is(createIssueArgs.repo, 'issueRepo')
t.is(createIssueArgs.labels, 'label-1')
Expand Down
4 changes: 4 additions & 0 deletions test/unit/get-commit-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ test('get commit request succeeds', t => {
}],
commit: {
message: 'message'
},
author: {
login: 'username'
}
}
})
Expand All @@ -45,6 +48,7 @@ test('get commit request succeeds', t => {
t.is(state.commit.filename, 'filename')
t.is(state.commit.patch, 'patch')
t.is(state.commit.branchUrl, 'https://github.com/Techforchange/first-timers-test/blob/defaultBranch/README.md')
t.is(state.commit.authorLogin, 'username')

simple.restore()
t.end()
Expand Down