Skip to content

Commit a0eabd2

Browse files
authored
Merge pull request #98 from GitGuardian/agateau/make-ci-use-pre-commit
Make CI use pre-commit
2 parents 849a02a + 77fad1b commit a0eabd2

24 files changed

+122
-100
lines changed

.github/pull_request_template.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,4 @@ For example:
3030
## PR check list
3131

3232
- [ ] As much as possible, the changes include tests
33-
- [ ] If the changes affect the end user (new feature, behavior change, bug fix) then the PR has a changelog entry.
34-
33+
- [ ] If the changes affect the end user (new feature, behavior change, bug fix) then the PR has a changelog entry.

.github/workflows/ci.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ on:
1111
- "README.md"
1212

1313
jobs:
14+
lint:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Run pre-commit
21+
run: pipx run pre-commit run --all-files --show-diff-on-failure
22+
env:
23+
# SKIP ggshield check: it's done by the "scanning" job
24+
SKIP: ggshield
25+
1426
build-and-test:
1527
runs-on: ${{ matrix.os }}
1628
strategy:

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
default_stages: [pre-commit]
22
repos:
33
- repo: https://github.com/pre-commit/pre-commit-hooks
4-
rev: v4.1.0
4+
rev: v6.0.0
55
hooks:
66
# not python related
77
- id: check-added-large-files
@@ -11,7 +11,7 @@ repos:
1111
args: [--allow-multiple-documents]
1212

1313
- repo: https://github.com/commitizen-tools/commitizen
14-
rev: v3.12.0
14+
rev: v4.9.1
1515
hooks:
1616
- id: commitizen
1717
# don't forget to run pre-commit install --hook-type commit-msg for this hook to run
@@ -24,13 +24,13 @@ repos:
2424
- id: prettier
2525

2626
- repo: https://github.com/codespell-project/codespell
27-
rev: v2.2.6
27+
rev: v2.4.1
2828
hooks:
2929
- id: codespell
3030
exclude: ^(ggshield-internal)
3131

3232
- repo: https://github.com/gitguardian/ggshield
33-
rev: v1.36.0
33+
rev: v1.43.0
3434
hooks:
3535
- id: ggshield
3636
language_version: python3

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Whether you’re a solo developer or part of a team, GitGuardian scales with you
2222

2323
- **Ignore Secrets**: After a scan, hover over the identified secret and select "GitGuardian: Ignore Secret" to add it to `.gitguardian.yaml`.
2424
- **Quota Tracking**: Run "GitGuardian: Show Quota" to monitor API call usage. Personal accounts include up to 10,000 monthly API calls.
25-
- **Check API Quota**: Stay aware of usage by running "GitGuardian: Show Quota."
25+
- **Check API Quota**: Stay aware of usage by running "GitGuardian: Show Quota."
2626

2727
### Support & Contributions
2828

@@ -33,4 +33,4 @@ Whether you’re a solo developer or part of a team, GitGuardian scales with you
3333
### Release Notes & License
3434

3535
- **Updates**: See the [Changelog](https://github.com/GitGuardian/gitguardian-vscode/blob/main/CHANGELOG.md).
36-
- **License**: GitGuardian CLI (`ggshield`) and this extension are MIT licensed.
36+
- **License**: GitGuardian CLI (`ggshield`) and this extension are MIT licensed.

src/extension.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,33 +39,33 @@ import {
3939

4040
function registerOpenViewsCommands(
4141
context: ExtensionContext,
42-
outputChannel: any
42+
outputChannel: any,
4343
) {
4444
const showOutputCommand = commands.registerCommand(
4545
"gitguardian.showOutput",
4646
() => {
4747
outputChannel.show();
48-
}
48+
},
4949
);
5050

5151
const openSidebarCommand = commands.registerCommand(
5252
"gitguardian.openSidebar",
5353
() => {
5454
commands.executeCommand("workbench.view.extension.gitguardian");
55-
}
55+
},
5656
);
5757

5858
const openProblemsCommand = commands.registerCommand(
5959
"gitguardian.openProblems",
6060
() => {
6161
commands.executeCommand("workbench.actions.view.problems");
62-
}
62+
},
6363
);
6464

6565
context.subscriptions.push(
6666
showOutputCommand,
6767
openSidebarCommand,
68-
openProblemsCommand
68+
openProblemsCommand,
6969
);
7070
}
7171

@@ -76,50 +76,50 @@ export async function activate(context: ExtensionContext) {
7676
const ggshieldResolver = new GGShieldResolver(
7777
outputChannel,
7878
context,
79-
configuration
79+
configuration,
8080
);
8181
const ggshieldViewProvider = new GitGuardianWebviewProvider(
8282
configuration,
8383
context.extensionUri,
84-
context
84+
context,
8585
);
8686

8787
const ggshieldRemediationMessageViewProvider =
8888
new GitGuardianRemediationMessageWebviewProvider(
8989
configuration,
9090
context.extensionUri,
91-
context
91+
context,
9292
);
9393
const ggshieldQuotaViewProvider = new GitGuardianQuotaWebviewProvider(
9494
configuration,
9595
context.extensionUri,
96-
context
96+
context,
9797
);
9898
window.registerWebviewViewProvider("gitguardianView", ggshieldViewProvider);
9999
window.registerWebviewViewProvider(
100100
"gitguardianRemediationMessageView",
101-
ggshieldRemediationMessageViewProvider
101+
ggshieldRemediationMessageViewProvider,
102102
);
103103
window.registerWebviewViewProvider(
104104
"gitguardianQuotaView",
105-
ggshieldQuotaViewProvider
105+
ggshieldQuotaViewProvider,
106106
);
107107
context.subscriptions.push(
108108
ggshieldViewProvider,
109109
ggshieldRemediationMessageViewProvider,
110-
ggshieldQuotaViewProvider
110+
ggshieldQuotaViewProvider,
111111
);
112112

113113
createStatusBarItem(context);
114114

115115
//generic commands to open correct view on status bar click
116116
registerOpenViewsCommands(context, outputChannel);
117117
commands.registerCommand("gitguardian.refreshQuota", () =>
118-
ggshieldQuotaViewProvider.refresh()
118+
ggshieldQuotaViewProvider.refresh(),
119119
);
120120

121121
context.subscriptions.push(
122-
languages.registerHoverProvider("*", new GitGuardianSecretHoverProvider())
122+
languages.registerHoverProvider("*", new GitGuardianSecretHoverProvider()),
123123
);
124124

125125
if (!checkGitInstalled()) {
@@ -149,12 +149,12 @@ export async function activate(context: ExtensionContext) {
149149
scanFile(
150150
textDocument.fileName,
151151
textDocument.uri,
152-
ggshieldResolver.configuration
152+
ggshieldResolver.configuration,
153153
);
154154
}
155155
}),
156156
workspace.onDidCloseTextDocument((textDocument) =>
157-
cleanUpFileDiagnostics(textDocument.uri)
157+
cleanUpFileDiagnostics(textDocument.uri),
158158
),
159159
commands.registerCommand("gitguardian.quota", () => {
160160
showAPIQuota(ggshieldResolver.configuration);
@@ -173,12 +173,12 @@ export async function activate(context: ExtensionContext) {
173173
ignoreSecret(
174174
ggshieldResolver.configuration,
175175
diagnosticData.secretSha,
176-
secretName
176+
secretName,
177177
);
178178
scanFile(
179179
currentFile,
180180
Uri.file(currentFile),
181-
ggshieldResolver.configuration
181+
ggshieldResolver.configuration,
182182
);
183183
}),
184184
commands.registerCommand("gitguardian.authenticate", async () => {
@@ -187,7 +187,7 @@ export async function activate(context: ExtensionContext) {
187187
ggshieldResolver.configuration,
188188
outputChannel,
189189
ggshieldViewProvider.getView() as WebviewView,
190-
context
190+
context,
191191
)
192192
.then(async () => {
193193
await updateAuthenticationStatus(context, configuration);
@@ -212,8 +212,8 @@ export async function activate(context: ExtensionContext) {
212212
ggshieldViewProvider.refresh();
213213
ggshieldRemediationMessageViewProvider.refresh();
214214
ggshieldQuotaViewProvider.refresh();
215-
}
216-
)
215+
},
216+
),
217217
);
218218
}
219219

src/ggshield-webview/gitguardian-quota-webview.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ export class GitGuardianQuotaWebviewProvider
1515
constructor(
1616
private ggshieldConfiguration: GGShieldConfiguration,
1717
private readonly _extensionUri: vscode.Uri,
18-
private context: vscode.ExtensionContext
18+
private context: vscode.ExtensionContext,
1919
) {}
2020

2121
public resolveWebviewView(
2222
webviewView: vscode.WebviewView,
2323
context: vscode.WebviewViewResolveContext,
24-
_token: vscode.CancellationToken
24+
_token: vscode.CancellationToken,
2525
) {
2626
this._view = webviewView;
2727
this.refresh();

src/ggshield-webview/gitguardian-remediation-message-view.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ export class GitGuardianRemediationMessageWebviewProvider
1414
constructor(
1515
private ggshieldConfiguration: GGShieldConfiguration,
1616
private readonly _extensionUri: vscode.Uri,
17-
private context: vscode.ExtensionContext
17+
private context: vscode.ExtensionContext,
1818
) {
1919
this.updateRemediationMessage();
2020
}
2121

2222
public resolveWebviewView(
2323
webviewView: vscode.WebviewView,
2424
context: vscode.WebviewViewResolveContext,
25-
_token: vscode.CancellationToken
25+
_token: vscode.CancellationToken,
2626
) {
2727
this._view = webviewView;
2828
this.refresh();
@@ -38,7 +38,7 @@ export class GitGuardianRemediationMessageWebviewProvider
3838
private checkAuthenticationStatus() {
3939
this.isAuthenticated = this.context.workspaceState.get(
4040
"authenticationStatus",
41-
false
41+
false,
4242
);
4343
}
4444

src/ggshield-webview/gitguardian-webview-view.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ import { AuthenticationStatus, ConfigSource } from "../lib/authentication";
33
import { GGShieldConfiguration } from "../lib/ggshield-configuration";
44

55
const projectDiscussionUri = vscode.Uri.parse(
6-
"https://github.com/GitGuardian/gitguardian-vscode/discussions"
6+
"https://github.com/GitGuardian/gitguardian-vscode/discussions",
77
);
88
const projectIssuesUri = vscode.Uri.parse(
9-
"https://github.com/GitGuardian/gitguardian-vscode/issues"
9+
"https://github.com/GitGuardian/gitguardian-vscode/issues",
1010
);
1111
const feedbackFormUri = vscode.Uri.parse(
12-
"https://docs.google.com/forms/d/e/1FAIpQLSc_BemGrdQfxp6lg7KgeDoB32XZg8yMfapk2gbemu0mVfskDQ/viewform"
12+
"https://docs.google.com/forms/d/e/1FAIpQLSc_BemGrdQfxp6lg7KgeDoB32XZg8yMfapk2gbemu0mVfskDQ/viewform",
1313
);
1414
const documentationUri = vscode.Uri.parse(
15-
"https://docs.gitguardian.com/ggshield-docs/configuration"
15+
"https://docs.gitguardian.com/ggshield-docs/configuration",
1616
);
1717

1818
export class GitGuardianWebviewProvider implements vscode.WebviewViewProvider {
@@ -22,13 +22,13 @@ export class GitGuardianWebviewProvider implements vscode.WebviewViewProvider {
2222
constructor(
2323
private ggshieldConfiguration: GGShieldConfiguration,
2424
private readonly _extensionUri: vscode.Uri,
25-
private context: vscode.ExtensionContext
25+
private context: vscode.ExtensionContext,
2626
) {}
2727

2828
public resolveWebviewView(
2929
webviewView: vscode.WebviewView,
3030
context: vscode.WebviewViewResolveContext,
31-
_token: vscode.CancellationToken
31+
_token: vscode.CancellationToken,
3232
) {
3333
this._view = webviewView;
3434

@@ -61,14 +61,14 @@ export class GitGuardianWebviewProvider implements vscode.WebviewViewProvider {
6161
const webview = this._view.webview;
6262

6363
const styleUri = webview.asWebviewUri(
64-
vscode.Uri.joinPath(this._extensionUri, "media", "main.css")
64+
vscode.Uri.joinPath(this._extensionUri, "media", "main.css"),
6565
);
6666
const logoUri = webview.asWebviewUri(
6767
vscode.Uri.joinPath(
6868
this._extensionUri,
6969
"images",
70-
"gitguardian-icon-primary700-background.svg"
71-
)
70+
"gitguardian-icon-primary700-background.svg",
71+
),
7272
);
7373

7474
console.log(authenticationStatus);

src/gitguardian-interface/gitguardian-hover-provider.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export class GitGuardianSecretHoverProvider implements vscode.HoverProvider {
44
public provideHover(
55
document: vscode.TextDocument,
66
position: vscode.Position,
7-
token: vscode.CancellationToken
7+
token: vscode.CancellationToken,
88
): vscode.ProviderResult<vscode.Hover> {
99
const diagnostics = vscode.languages.getDiagnostics(document.uri);
1010

@@ -20,7 +20,7 @@ export class GitGuardianSecretHoverProvider implements vscode.HoverProvider {
2020
const encodedDiagnosticData = encodeURIComponent(diagnosticData);
2121

2222
hoverMessage.appendMarkdown(
23-
`[GitGuardian: Ignore Secret (update .gitguardian.yaml)](command:gitguardian.ignoreSecret?${encodedDiagnosticData} "Click to ignore this incident")`
23+
`[GitGuardian: Ignore Secret (update .gitguardian.yaml)](command:gitguardian.ignoreSecret?${encodedDiagnosticData} "Click to ignore this incident")`,
2424
);
2525
return new vscode.Hover(hoverMessage, diagnostic.range);
2626
}
@@ -65,9 +65,9 @@ function extractInfosFromMessage(message: string): {
6565

6666
export function generateSecretName(
6767
currentFile: string,
68-
uriDiagnostic: any
68+
uriDiagnostic: any,
6969
): string {
7070
return `${uriDiagnostic.detector} - ${vscode.workspace.asRelativePath(
71-
currentFile
71+
currentFile,
7272
)}:l.${uriDiagnostic.startLine}`;
7373
}

src/lib/api-types.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@ export type Validity =
1616
| "invalid"
1717
| "valid";
1818

19-
type IncidentVaultProperties = {
20-
secret_vaulted: false;
21-
} | {
22-
secret_vaulted: true;
23-
vault_type: string;
24-
vault_name: string;
25-
vault_path: string;
26-
vault_path_count: number;
27-
}
19+
type IncidentVaultProperties =
20+
| {
21+
secret_vaulted: false;
22+
}
23+
| {
24+
secret_vaulted: true;
25+
vault_type: string;
26+
vault_name: string;
27+
vault_path: string;
28+
vault_path_count: number;
29+
};
2830

2931
export type Incident = {
3032
type: string;
@@ -34,7 +36,7 @@ export type Incident = {
3436
known_secret: boolean;
3537
incident_url: string;
3638
total_occurrences: number;
37-
} & IncidentVaultProperties
39+
} & IncidentVaultProperties;
3840

3941
export interface EntityWithIncidents {
4042
incidents: Incident[];

0 commit comments

Comments
 (0)