Skip to content

Commit 4b3ba79

Browse files
committed
build: fix tslint
1 parent 6ddb45b commit 4b3ba79

File tree

5 files changed

+58
-53
lines changed

5 files changed

+58
-53
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
language: node_js
2-
node_js: "10"
2+
node_js: '10'
33
cache: yarn
44
env:
55
global:
@@ -13,7 +13,7 @@ jobs:
1313
- npm run build
1414
- npm run cover
1515
- nyc report --reporter json
16-
- "bash <(curl -s https://codecov.io/bash)"
16+
- 'bash <(curl -s https://codecov.io/bash)'
1717
stages:
1818
- test
1919
branches:

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@
119119
},
120120
"dependencies": {
121121
"date-fns": "^2.0.0-alpha.24",
122-
"rxjs": "^6.4.0"
122+
"rxjs": "^6.4.0",
123+
"tagged-template-noop": "^2.1.0"
123124
},
124125
"husky": {
125126
"hooks": {

src/blame.ts

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import formatDistanceStrict from 'date-fns/formatDistanceStrict'
22
import * as sourcegraph from 'sourcegraph'
3+
import gql from 'tagged-template-noop'
34
import { Settings } from './extension'
45
import { resolveURI } from './uri'
56
import { memoizeAsync } from './util/memoizeAsync'
@@ -54,6 +55,49 @@ const getBlameDecorationsForSelections = (hunks: Hunk[], selections: sourcegraph
5455
const getAllBlameDecorations = (hunks: Hunk[], now: number) =>
5556
hunks.map(hunk => getDecorationFromHunk(hunk, now, hunk.startLine - 1))
5657

58+
const queryBlameHunks = memoizeAsync(
59+
async (uri: string): Promise<Hunk[]> => {
60+
const { repo, rev, path } = resolveURI(uri)
61+
const { data, errors } = await sourcegraph.commands.executeCommand(
62+
'queryGraphQL',
63+
gql`
64+
query GitBlame($repo: String!, $rev: String!, $path: String!) {
65+
repository(name: $repo) {
66+
commit(rev: $rev) {
67+
blob(path: $path) {
68+
blame(startLine: 0, endLine: 0) {
69+
startLine
70+
endLine
71+
author {
72+
person {
73+
displayName
74+
}
75+
date
76+
}
77+
message
78+
rev
79+
commit {
80+
url
81+
}
82+
}
83+
}
84+
}
85+
}
86+
}
87+
`,
88+
{ repo, rev, path }
89+
)
90+
if (errors && errors.length > 0) {
91+
throw new Error(errors.join('\n'))
92+
}
93+
if (!data || !data.repository || !data.repository.commit || !data.repository.commit.blob) {
94+
throw new Error('no blame data is available (repository, commit, or path not found)')
95+
}
96+
return data.repository.commit.blob.blame
97+
},
98+
uri => uri
99+
)
100+
57101
/**
58102
* Queries the blame hunks for the document at the provided URI,
59103
* and returns blame decorations for all provided selections,
@@ -97,49 +141,6 @@ interface Hunk {
97141
}
98142
}
99143

100-
const queryBlameHunks = memoizeAsync(
101-
async (uri: string): Promise<Hunk[]> => {
102-
const { repo, rev, path } = resolveURI(uri)
103-
const { data, errors } = await sourcegraph.commands.executeCommand(
104-
'queryGraphQL',
105-
`
106-
query GitBlame($repo: String!, $rev: String!, $path: String!) {
107-
repository(name: $repo) {
108-
commit(rev: $rev) {
109-
blob(path: $path) {
110-
blame(startLine: 0, endLine: 0) {
111-
startLine
112-
endLine
113-
author {
114-
person {
115-
displayName
116-
}
117-
date
118-
}
119-
message
120-
rev
121-
commit {
122-
url
123-
}
124-
}
125-
}
126-
}
127-
}
128-
}
129-
`,
130-
{ repo, rev, path }
131-
)
132-
if (errors && errors.length > 0) {
133-
throw new Error(errors.join('\n'))
134-
}
135-
if (!data || !data.repository || !data.repository.commit || !data.repository.commit.blob) {
136-
throw new Error('no blame data is available (repository, commit, or path not found)')
137-
}
138-
return data.repository.commit.blob.blame
139-
},
140-
uri => uri
141-
)
142-
143144
function truncate(s: string, max: number, omission = '…'): string {
144145
if (s.length <= max) {
145146
return s

src/extension.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,12 @@ export function activate(context: sourcegraph.ExtensionContext): void {
3333
// When configuration changes or onDidOpenTextDocument fires, add decorations for all blame hunks.
3434
const activeEditor = () => sourcegraph.app.activeWindow && sourcegraph.app.activeWindow.activeViewComponent
3535
context.subscriptions.add(
36-
combineLatest(configurationChanges, from(sourcegraph.workspace.onDidOpenTextDocument)).subscribe(
37-
async () => {
38-
const editor = activeEditor()
39-
if (editor) {
40-
await decorate(editor, null)
41-
}
36+
combineLatest(configurationChanges, from(sourcegraph.workspace.openedTextDocuments)).subscribe(async () => {
37+
const editor = activeEditor()
38+
if (editor) {
39+
await decorate(editor, null)
4240
}
43-
)
41+
})
4442
)
4543
}
4644

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6176,6 +6176,11 @@ svgo@^1.0.0, svgo@^1.0.5:
61766176
unquote "~1.1.1"
61776177
util.promisify "~1.0.0"
61786178

6179+
tagged-template-noop@^2.1.0:
6180+
version "2.1.0"
6181+
resolved "https://registry.npmjs.org/tagged-template-noop/-/tagged-template-noop-2.1.0.tgz#3501d67fd75612ab40e6040056ea881d1161c4f5"
6182+
integrity sha512-VOPA7ZucOLvew9xq+AwABXil7AHQZa3G7T3QOQoUveNIl3EwNsMN79JHn8v7zgpM1Pd8R36MrntUvaWqLqjg1w==
6183+
61796184
tar@^4:
61806185
version "4.4.6"
61816186
resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.6.tgz#63110f09c00b4e60ac8bcfe1bf3c8660235fbc9b"

0 commit comments

Comments
 (0)