Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/master' into bl/regression-test
Browse files Browse the repository at this point in the history
  • Loading branch information
beyang committed Jun 5, 2019
2 parents 2f6a5f8 + 77b6410 commit 31f5851
Show file tree
Hide file tree
Showing 39 changed files with 3,373 additions and 1,354 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ All notable changes to Sourcegraph are documented in this file.
- Fixed repository search patterns which contain `.*`. Previously our optimizer would ignore `.*`, which in some cases would lead to our repository search excluding some repositories from the results.
- Fixed an issue where the Phabricator native integration would be broken on recent Phabricator versions. This fix depends on v1.2 of the [Phabricator extension](https://github.com/sourcegraph/phabricator-extension).
- Fixed an issue where the "Empty repository" banner would be shown on a repository page when starting to clone a repository.
- Repositories containing submodules not on Sourcegraph will now load without error (#2947)

## 3.4.3 (unreleased)

Expand All @@ -35,6 +36,10 @@ All notable changes to Sourcegraph are documented in this file.

### Fixed

- Improved performance of the /site-admin/repositories page significantly (prevents timeouts). [#4063](https://github.com/sourcegraph/sourcegraph/issues/4063)
- Fixed an issue where Gitolite repositories would be inaccessible to non-admin users after upgrading to 3.3.0+ from an older version. [#4263](https://github.com/sourcegraph/sourcegraph/issues/4263)
- Repository names are now treated as case-sensitive, fixing an issue where users saw `pq: duplicate key value violates unique constraint \"repo_name_unique\"` [#4283](https://github.com/sourcegraph/sourcegraph/issues/4283)

## 3.4.2

### Added
Expand All @@ -45,7 +50,7 @@ All notable changes to Sourcegraph are documented in this file.

### Fixed

- Fixed https://github.com/sourcegraph/sourcegraph/issues/4127
- Fixed incorrect wording in site-admin onboarding. [#4127](https://github.com/sourcegraph/sourcegraph/issues/4127)

## 3.4.1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
exports[`Bitbucket DOM functions diffDOMFunctions Split view line number 54 in head diff part getCodeElementFromLineNumber() should return the right code element given the line number 1`] = `
Object {
"content": "routes []*Route",
"selector": false,
"selector": "DIV.diff-editor.side-by-side-diff-editor-to > DIV.CodeMirror.cm-s-stash-default > DIV.CodeMirror-scroll > DIV.CodeMirror-sizer > DIV > DIV.CodeMirror-lines > DIV > DIV.CodeMirror-code > DIV.context.line:nth-child(54) > PRE.CodeMirror-line > SPAN",
}
`;

exports[`Bitbucket DOM functions diffDOMFunctions Split view line number 54 in head diff part getLineElementFromLineNumber() should return the right line element given the line number 1`] = `
Object {
"content": "This line has a comment.Add a comment on this line.54  routes []*Route",
"selector": "DIV.diff-editor.side-by-side-diff-editor-to > DIV.CodeMirror.cm-s-stash-default > DIV.CodeMirror-scroll > DIV.CodeMirror-sizer > DIV > DIV.CodeMirror-lines > DIV > DIV.CodeMirror-code > DIV.context.line:nth-child(54)",
}
`;

Expand All @@ -14,44 +21,93 @@ Object {
}
`;

exports[`Bitbucket DOM functions diffDOMFunctions Split view line number 60 in head diff part getLineElementFromLineNumber() should return the right line element given the line number 1`] = `
Object {
"content": "This line has a comment.Add a comment on this line.60+ namedRoutes2 map[string]*Route",
"selector": "DIV.added.modified.line.last-focus:nth-child(60)",
}
`;

exports[`Bitbucket DOM functions diffDOMFunctions Split view line number 102 in base diff part getCodeElementFromLineNumber() should return the right code element given the line number 1`] = `
Object {
"content": "c.regexp.path = copyRouteRegexp(r.regexp.path)",
"selector": "DIV.removed.modified.line:nth-child(102) > PRE.CodeMirror-line > SPAN",
}
`;

exports[`Bitbucket DOM functions diffDOMFunctions Split view line number 102 in base diff part getLineElementFromLineNumber() should return the right line element given the line number 1`] = `
Object {
"content": "This line has a comment.Add a comment on this line.102- c.regexp.path = copyRouteRegexp(r.regexp.path)",
"selector": "DIV.removed.modified.line:nth-child(102)",
}
`;

exports[`Bitbucket DOM functions diffDOMFunctions Unified view line number 54 in head diff part getCodeElementFromLineNumber() should return the right code element given the line number 1`] = `
Object {
"content": "routes []*Route",
"selector": "DIV.context.line:nth-child(6) > PRE.CodeMirror-line > SPAN",
}
`;

exports[`Bitbucket DOM functions diffDOMFunctions Unified view line number 54 in head diff part getLineElementFromLineNumber() should return the right line element given the line number 1`] = `
Object {
"content": "This line has a comment.Add a comment on this line.5454  routes []*Route",
"selector": "DIV.context.line:nth-child(6)",
}
`;

exports[`Bitbucket DOM functions diffDOMFunctions Unified view line number 60 in head diff part getCodeElementFromLineNumber() should return the right code element given the line number 1`] = `
Object {
"content": "namedRoutes2 map[string]*Route",
"selector": "DIV.added.modified.line:nth-child(12) > PRE.CodeMirror-line > SPAN",
}
`;

exports[`Bitbucket DOM functions diffDOMFunctions Unified view line number 60 in head diff part getLineElementFromLineNumber() should return the right line element given the line number 1`] = `
Object {
"content": "This line has a comment.Add a comment on this line. 60+ namedRoutes2 map[string]*Route",
"selector": "DIV.added.modified.line:nth-child(12)",
}
`;

exports[`Bitbucket DOM functions diffDOMFunctions Unified view line number 102 in base diff part getCodeElementFromLineNumber() should return the right code element given the line number 1`] = `
Object {
"content": "c.regexp.path = copyRouteRegexp(r.regexp.path)",
"selector": "DIV.removed.modified.line:nth-child(38) > PRE.CodeMirror-line > SPAN",
}
`;

exports[`Bitbucket DOM functions diffDOMFunctions Unified view line number 102 in base diff part getLineElementFromLineNumber() should return the right line element given the line number 1`] = `
Object {
"content": "This line has a comment.Add a comment on this line.102 - c.regexp.path = copyRouteRegexp(r.regexp.path)",
"selector": "DIV.removed.modified.line:nth-child(38)",
}
`;

exports[`Bitbucket DOM functions singleFileDOMFunctions line number 1 getCodeElementFromLineNumber() should return the right code element given the line number 1`] = `
Object {
"content": "// Copyright 2012 The Gorilla Authors. All rights reserved.",
"selector": "DIV.line:nth-child(1) > PRE.CodeMirror-line > SPAN",
}
`;

exports[`Bitbucket DOM functions singleFileDOMFunctions line number 1 getLineElementFromLineNumber() should return the right line element given the line number 1`] = `
Object {
"content": "1// Copyright 2012 The Gorilla Authors. All rights reserved.",
"selector": "DIV.line:nth-child(1)",
}
`;

exports[`Bitbucket DOM functions singleFileDOMFunctions line number 18 getCodeElementFromLineNumber() should return the right code element given the line number 1`] = `
Object {
"content": "return setVars(r, val)",
"selector": "DIV.line:nth-child(18) > PRE.CodeMirror-line > SPAN",
}
`;

exports[`Bitbucket DOM functions singleFileDOMFunctions line number 18 getLineElementFromLineNumber() should return the right line element given the line number 1`] = `
Object {
"content": "18 return setVars(r, val)",
"selector": "DIV.line:nth-child(18)",
}
`;
4 changes: 2 additions & 2 deletions browser/src/libs/bitbucket/code_intelligence.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { AdjustmentDirection, DOMFunctions, PositionAdjuster } from '@sourcegraph/codeintellify'
import { AdjustmentDirection, PositionAdjuster } from '@sourcegraph/codeintellify'
import { of } from 'rxjs'
import { Omit } from 'utility-types'
import { PlatformContext } from '../../../../shared/src/platform/context'
import { FileSpec, RepoSpec, ResolvedRevSpec, RevSpec } from '../../../../shared/src/util/url'
import { querySelectorOrSelf } from '../../shared/util/dom'
import { CodeHost, MountGetter } from '../code_intelligence'
import { CodeView } from '../code_intelligence/code_views'
import { CodeView, DOMFunctions } from '../code_intelligence/code_views'
import { ViewResolver } from '../code_intelligence/views'
import { getContext } from './context'
import { diffDOMFunctions, singleFileDOMFunctions } from './dom_functions'
Expand Down
65 changes: 39 additions & 26 deletions browser/src/libs/bitbucket/dom_functions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
import { DOMFunctions } from '@sourcegraph/codeintellify'
import { DiffPart } from '@sourcegraph/codeintellify'
import { DOMFunctions } from '../code_intelligence/code_views'

const getSingleFileLineElementFromLineNumber = (codeView: HTMLElement, line: number): HTMLElement => {
const lineNumElem = codeView.querySelector<HTMLElement>(`[data-line-number="${line}"`)
if (!lineNumElem) {
throw new Error(`Line ${line} not found in code view`)
}

const lineElem = lineNumElem.closest('.line') as HTMLElement | null
if (!lineElem) {
throw new Error('Could not find line elem for line element')
}

return lineElem
}

export const singleFileDOMFunctions: DOMFunctions = {
getCodeElementFromTarget: target => {
Expand All @@ -24,19 +39,27 @@ export const singleFileDOMFunctions: DOMFunctions = {

return lineNum
},
getCodeElementFromLineNumber: (codeView, line) => {
const lineNumElem = codeView.querySelector<HTMLElement>(`[data-line-number="${line}"`)
if (!lineNumElem) {
throw new Error(`Line ${line} not found in code view`)
}
getLineElementFromLineNumber: getSingleFileLineElementFromLineNumber,
getCodeElementFromLineNumber: (codeView, line) =>
getSingleFileLineElementFromLineNumber(codeView, line).querySelector<HTMLElement>(
'.CodeMirror-line span[role="presentation"]'
),
}

const lineElem = lineNumElem.closest('.line') as HTMLElement | null
if (!lineElem) {
throw new Error('Could not find line elem for line element')
const getDiffLineElementFromLineNumber = (codeView: HTMLElement, line: number, part?: DiffPart): HTMLElement => {
for (const lineNumElem of codeView.getElementsByClassName(`line-number-${part === 'head' ? 'to' : 'from'}`)) {
const lineNum = parseInt((lineNumElem.textContent || '').trim(), 10)
if (!isNaN(lineNum) && lineNum === line) {
const lineElem = lineNumElem.closest('.line') as HTMLElement | null
if (!lineElem) {
throw new Error('Could not find lineElem from lineNumElem')
}

return lineElem
}
}

return lineElem.querySelector<HTMLElement>('.CodeMirror-line span[role="presentation"]')
},
throw new Error(`Could not locate line number element for line ${line}, part: ${part}`)
}

export const diffDOMFunctions: DOMFunctions = {
Expand Down Expand Up @@ -65,21 +88,11 @@ export const diffDOMFunctions: DOMFunctions = {

throw new Error('Could not find line number element for code element')
},
getCodeElementFromLineNumber: (codeView, line, part) => {
for (const lineNumElem of codeView.getElementsByClassName(`line-number-${part === 'head' ? 'to' : 'from'}`)) {
const lineNum = parseInt((lineNumElem.textContent || '').trim(), 10)
if (!isNaN(lineNum) && lineNum === line) {
const lineElem = lineNumElem.closest('.line') as HTMLElement | null
if (!lineElem) {
throw new Error('Could not find line elem for line element')
}

return lineElem.querySelector<HTMLElement>('.CodeMirror-line span[role="presentation"]')
}
}

throw new Error(`Could not locate line number element for line ${line}`)
},
getLineElementFromLineNumber: getDiffLineElementFromLineNumber,
getCodeElementFromLineNumber: (codeView, line, part) =>
getDiffLineElementFromLineNumber(codeView, line, part).querySelector<HTMLElement>(
'.CodeMirror-line span[role="presentation"]'
),
getDiffCodePart: codeElement => {
if (!document.querySelector('.side-by-side-diff')) {
return codeElement.closest('.line')!.classList.contains('removed') ? 'base' : 'head'
Expand Down
Loading

0 comments on commit 31f5851

Please sign in to comment.