Skip to content

Commit 8a4a380

Browse files
committed
Update
1 parent 896ab5b commit 8a4a380

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/register-action.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ import { getCurrentUser } from './util'
77
// TODO(sqs) SECURITY(sqs): sanitize for real
88
const escapedMarkdownCode = (text: string): string => '`' + text.replace(/`/g, '\\`') + '`'
99

10+
// TODO: make this file filter configurable.
11+
// The filter is applied on all files of each matching repo (confirm - is that correct?)
12+
const fileFilter = (path: string): boolean => path.endsWith('.yaml') || path.endsWith('.yml') || path.endsWith('.md')
13+
1014
export const registerFindReplaceAction = (): Subscription => {
1115
const subscription = new Subscription()
1216
subscription.add(
1317
sourcegraph.commands.registerCommand('start-find-replace', async () => {
14-
1518
// To create campaigns, a namespace is used, which can be the current user's username.
16-
const currentUser = await getCurrentUser();
19+
const currentUser = await getCurrentUser()
1720
const namespaceName = currentUser?.username
1821
console.log('currentUser', currentUser)
1922

@@ -47,8 +50,7 @@ export const registerFindReplaceAction = (): Subscription => {
4750
description,
4851
steps: [
4952
{
50-
fileFilter: path =>
51-
path.endsWith('.yaml') || path.endsWith('.yml') || path.endsWith('.md'), // TODO(sqs)
53+
fileFilter,
5254
editFile: (path, text) => {
5355
if (!text.includes(match)) {
5456
return null
@@ -72,7 +74,7 @@ export const registerFindReplaceAction = (): Subscription => {
7274
message: description,
7375
author: {
7476
name: currentUser.username,
75-
email: currentUser.email
77+
email: currentUser.email,
7678
},
7779
},
7880
published: false,

src/util.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sourcegraph from 'sourcegraph'
22

3-
export async function getCurrentUser(): Promise<{username: string, email: string}> {
3+
export async function getCurrentUser(): Promise<{ username: string; email: string }> {
44
const response = await sourcegraph.commands.executeCommand(
55
'queryGraphQL',
66
`{
@@ -9,6 +9,5 @@ export async function getCurrentUser(): Promise<{username: string, email: string
99
}
1010
}`
1111
)
12-
console.log('A response is going to the extension', response.data)
1312
return response?.data?.currentUser
1413
}

0 commit comments

Comments
 (0)