fix go-to-gitlab link to branch, commit range and line (#532)

* fix go-to-gitlab link to branch, commit range and line
This commit is contained in:
Vanesa 2018-10-26 11:20:04 -07:00 committed by GitHub
parent ae16d8fcb6
commit 6691d29e47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -108,18 +108,18 @@ export class GoToCodeHostAction extends React.PureComponent<Props, State> {
const { displayName, icon } = serviceTypeDisplayNameAndIcon(externalURL.serviceType)
const Icon = icon || ExportIcon
// Special-case for GitHub: add branch and line numbers to URL.
// Extract url to add branch, line numbers or commit range.
let url = externalURL.url
if (externalURL.serviceType === 'github') {
// If in a branch, add branch path to the GitHub URL.
if (externalURL.serviceType === 'github' || externalURL.serviceType === 'gitlab') {
// If in a branch, add branch path to the code host URL.
if (this.props.rev && this.props.rev !== defaultBranch && !this.state.fileExternalLinksOrError) {
url += `/tree/${this.props.rev}`
}
// If showing a comparison, add comparison specifier to the GitHub URL.
// If showing a comparison, add comparison specifier to the code host URL.
if (this.props.commitRange) {
url += `/compare/${this.props.commitRange.replace(/^\.\.\./, 'HEAD...').replace(/\.\.\.$/, '...HEAD')}`
}
// Add range or position path to the GitHub URL.
// Add range or position path to the code host URL.
if (this.props.range) {
url += `#L${this.props.range.start.line}-L${this.props.range.end.line}`
} else if (this.props.position) {