Skip to content

Commit

Permalink
Tweak origin properties
Browse files Browse the repository at this point in the history
  • Loading branch information
cookpete committed Nov 7, 2017
1 parent 9d2bd33 commit 9b956d5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 19 deletions.
12 changes: 6 additions & 6 deletions src/commits.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,21 @@ function getMerge (message, origin) {

function getCommitLink (hash, origin) {
if (origin.hostname === 'bitbucket.org') {
return `${origin.repoURL}/commits/${hash}`
return `${origin.url}/commits/${hash}`
}
return `${origin.repoURL}/commit/${hash}`
return `${origin.url}/commit/${hash}`
}

function getIssueLink (id, origin) {
return `${origin.repoURL}/issues/${id}`
return `${origin.url}/issues/${id}`
}

function getPullLink (id, origin) {
if (origin.hostname === 'bitbucket.org') {
return `${origin.repoURL}/pull-requests/${id}`
return `${origin.url}/pull-requests/${id}`
}
if (origin.hostname === 'gitlab.com') {
return `${origin.repoURL}/merge_requests/${id}`
return `${origin.url}/merge_requests/${id}`
}
return `${origin.repoURL}/pull/${id}`
return `${origin.url}/pull/${id}`
}
6 changes: 3 additions & 3 deletions src/origin.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ export async function fetchOrigin (remote) {
}
const origin = parseRepoURL(originURL)
const protocol = origin.protocol === 'http:' ? 'http:' : 'https:'
const host = origin.hostname || origin.host
const hostname = origin.hostname || origin.host
return {
...origin,
repoURL: `${protocol}//${host}/${origin.repo}`
hostname,
url: `${protocol}//${hostname}/${origin.repo}`
}
}
4 changes: 2 additions & 2 deletions src/releases.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ function filterCommit (commit, merges) {

function getCompareLink (from, to, origin) {
if (origin.hostname === 'bitbucket.org') {
return `${origin.repoURL}/compare/${to}%0D${from}`
return `${origin.url}/compare/${to}%0D${from}`
}
return `${origin.repoURL}/compare/${from}...${to}`
return `${origin.url}/compare/${from}...${to}`
}

function sortCommits (a, b) {
Expand Down
9 changes: 3 additions & 6 deletions test/commits.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,15 @@ const getMerge = __get__('getMerge')
const origin = {
github: {
hostname: 'github.com',
repoURL: 'https://github.com/user/repo',
repo: 'user/repo'
url: 'https://github.com/user/repo'
},
gitlab: {
hostname: 'gitlab.com',
repoURL: 'https://gitlab.com/user/repo',
repo: 'user/repo'
url: 'https://gitlab.com/user/repo'
},
bitbucket: {
hostname: 'bitbucket.org',
repoURL: 'https://bitbucket.org/user/repo',
repo: 'user/repo'
url: 'https://bitbucket.org/user/repo'
}
}

Expand Down
3 changes: 1 addition & 2 deletions test/releases.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import { parseReleases } from '../src/releases'

const origin = {
hostname: 'github.com',
repoURL: 'https://github.com/user/repo',
repo: 'user/repo'
url: 'https://github.com/user/repo'
}

describe('parseReleases', () => {
Expand Down

0 comments on commit 9b956d5

Please sign in to comment.