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

Test + fix for get-commit-test.js to return correct path in branchUrl #192

Merged
merged 8 commits into from
May 1, 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
2 changes: 1 addition & 1 deletion lib/get-commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function getCommit (state) {

.then(function (result) {
const {filename, patch, blob_url: blobUrl} = result.data.files[0]
var branchUrl = blobUrl.replace(/(?:blob)(.+)(?=\/)/g, 'blob/' + state.repoDefaultBranch)
var branchUrl = blobUrl.replace(/\/blob\/[^/]+/, '/blob/' + state.repoDefaultBranch)

state.commit = {
message: result.data.commit.message,
Expand Down
4 changes: 2 additions & 2 deletions test/unit/get-commit-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ test('get commit request succeeds', t => {
files: [{
filename: 'filename',
patch: 'patch',
blob_url: 'https://github.com/Techforchange/first-timers-test/blob/f00ecb1bbffe515500558568ae0b176d2a1defe8/README.md'
blob_url: 'https://github.com/Techforchange/first-timers-test/blob/f00ecb1bbffe515500558568ae0b176d2a1defe8/docs/README.md'
}],
commit: {
message: 'message'
Expand All @@ -47,7 +47,7 @@ test('get commit request succeeds', t => {
t.is(state.commit.message, 'message')
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.branchUrl, 'https://github.com/Techforchange/first-timers-test/blob/defaultBranch/docs/README.md')
Copy link
Contributor

Choose a reason for hiding this comment

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

you have to change line 28 to make it work

- blob_url: 'https://github.com/Techforchange/first-timers-test/blob/f00ecb1bbffe515500558568ae0b176d2a1defe8/README.md'
+ blob_url: 'https://github.com/Techforchange/first-timers-test/blob/f00ecb1bbffe515500558568ae0b176d2a1defe8/docs/README.md'

t.is(state.commit.authorLogin, 'username')

simple.restore()
Expand Down