Skip to content

Commit f9ac74e

Browse files
committed
Rename source files to kebab-case; Clean up uri-util exports
- Rename contentProvider -> content-provider, uriUtil -> uri-util (src + test) - Replace private SCHEME alias with single exported GIT_CRYPT_SCHEME constant - Update architecture sections in CLAUDE.md and CONTRIBUTING.md
1 parent 06c002a commit f9ac74e

8 files changed

Lines changed: 19 additions & 21 deletions

File tree

CLAUDE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ src/
2020
extension.ts # Activation, FileDecorationProvider, wiring
2121
git.ts # execFile wrappers for git and git-crypt commands
2222
detector.ts # GitCryptDetector: cached Set<string> of git-crypt files per repo
23-
contentProvider.ts # resolveContent(): decodes git-crypt: URI -> decrypted text
23+
content-provider.ts # resolveContent(): decodes git-crypt: URI -> decrypted text
2424
diff.ts # showDiff(), registerDiffCommand(): opens vscode.diff editor
25-
uriUtil.ts # encode/decode git-crypt://<hash>/<ref>/<path>?<repoRoot> URIs
25+
uri-util.ts # encode/decode git-crypt://<hash>/<ref>/<path>?<repoRoot> URIs
2626
test/
2727
fixture.ts # Creates temporary git-crypt repo for tests
2828
*.test.ts # Unit tests (node:test + tsx)

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ src/
4949
extension.ts # Activation, wiring, file decoration provider
5050
git.ts # Low-level git/git-crypt command helpers (execFile, no shell)
5151
detector.ts # Cached set of git-crypt files per repository
52-
contentProvider.ts # Resolves git-crypt: URIs to decrypted content
52+
content-provider.ts # Resolves git-crypt: URIs to decrypted content
5353
diff.ts # Diff command (opens vscode.diff editor)
54-
uriUtil.ts # Encode/decode git-crypt: URI scheme
54+
uri-util.ts # Encode/decode git-crypt: URI scheme
5555
```
5656

5757
The extension activates lazily (`onStartupFinished`), checks for `git-crypt` availability, scans workspace repositories for git-crypt files via `git check-attr`, and registers commands and providers. All git interaction uses `execFile` with array arguments (no shell) to prevent command injection.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { getTextConv } from './git.js';
2-
import { decodeGitCryptUri } from './uriUtil.js';
2+
import { decodeGitCryptUri } from './uri-util.js';
33

44
export async function resolveContent(uriString: string): Promise<string> {
55
const { repoRoot, ref, relPath } = decodeGitCryptUri(uriString);

src/diff.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as vscode from 'vscode';
22
import * as path from 'node:path';
33
import { GitCryptDetector } from './detector.js';
4-
import { encodeGitCryptUri } from './uriUtil.js';
4+
import { encodeGitCryptUri } from './uri-util.js';
55

66
export async function showDiff(
77
detector: GitCryptDetector,

src/extension.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as vscode from 'vscode';
22
import { isGitCryptAvailable, isRepoUnlocked } from './git.js';
33
import { GitCryptDetector } from './detector.js';
4-
import { resolveContent } from './contentProvider.js';
5-
import { GIT_CRYPT_SCHEME } from './uriUtil.js';
4+
import { resolveContent } from './content-provider.js';
5+
import { GIT_CRYPT_SCHEME } from './uri-util.js';
66
import { registerDiffCommand } from './diff.js';
77

88
const log = vscode.window.createOutputChannel('git-crypt Diff');
Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import * as crypto from 'node:crypto';
22

3-
const SCHEME = 'git-crypt';
3+
export const GIT_CRYPT_SCHEME = 'git-crypt';
44

55
export function encodeGitCryptUri(repoRoot: string, ref: string, relPath: string): string {
66
const rootHash = crypto.createHash('sha256').update(repoRoot).digest('hex').slice(0, 8);
77
// Store repoRoot in query so it survives URI encoding round-trips
88
const query = encodeURIComponent(repoRoot);
9-
return `${SCHEME}://${rootHash}/${encodeURIComponent(ref)}/${relPath}?${query}`;
9+
return `${GIT_CRYPT_SCHEME}://${rootHash}/${encodeURIComponent(ref)}/${relPath}?${query}`;
1010
}
1111

1212
export interface DecodedGitCryptUri {
@@ -16,15 +16,15 @@ export interface DecodedGitCryptUri {
1616
}
1717

1818
export function decodeGitCryptUri(uriString: string): DecodedGitCryptUri {
19-
if (!uriString.startsWith(`${SCHEME}://`)) {
20-
throw new Error(`Not a ${SCHEME} URI: ${uriString}`);
19+
if (!uriString.startsWith(`${GIT_CRYPT_SCHEME}://`)) {
20+
throw new Error(`Not a ${GIT_CRYPT_SCHEME} URI: ${uriString}`);
2121
}
2222

2323
// Parse: git-crypt://<hash>/<ref>/<relPath>?<repoRoot>
24-
const withoutScheme = uriString.slice(`${SCHEME}://`.length);
24+
const withoutScheme = uriString.slice(`${GIT_CRYPT_SCHEME}://`.length);
2525
const queryIdx = withoutScheme.indexOf('?');
2626
if (queryIdx === -1) {
27-
throw new Error(`Malformed ${SCHEME} URI (missing query): ${uriString}`);
27+
throw new Error(`Malformed ${GIT_CRYPT_SCHEME} URI (missing query): ${uriString}`);
2828
}
2929

3030
const pathPart = withoutScheme.slice(0, queryIdx);
@@ -33,19 +33,17 @@ export function decodeGitCryptUri(uriString: string): DecodedGitCryptUri {
3333
// pathPart = "<hash>/<ref>/<relPath>"
3434
const firstSlash = pathPart.indexOf('/');
3535
if (firstSlash === -1) {
36-
throw new Error(`Malformed ${SCHEME} URI (missing ref): ${uriString}`);
36+
throw new Error(`Malformed ${GIT_CRYPT_SCHEME} URI (missing ref): ${uriString}`);
3737
}
3838

3939
const afterHash = pathPart.slice(firstSlash + 1);
4040
const secondSlash = afterHash.indexOf('/');
4141
if (secondSlash === -1) {
42-
throw new Error(`Malformed ${SCHEME} URI (missing path): ${uriString}`);
42+
throw new Error(`Malformed ${GIT_CRYPT_SCHEME} URI (missing path): ${uriString}`);
4343
}
4444

4545
const ref = decodeURIComponent(afterHash.slice(0, secondSlash));
4646
const relPath = afterHash.slice(secondSlash + 1);
4747

4848
return { repoRoot, ref, relPath };
4949
}
50-
51-
export const GIT_CRYPT_SCHEME = SCHEME;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { describe, it, before, after } from 'node:test';
22
import * as assert from 'node:assert/strict';
3-
import { resolveContent } from '../src/contentProvider.js';
4-
import { encodeGitCryptUri } from '../src/uriUtil.js';
3+
import { resolveContent } from '../src/content-provider.js';
4+
import { encodeGitCryptUri } from '../src/uri-util.js';
55
import { createFixture, destroyFixture, type TestFixture } from './fixture.js';
66

77
let fixture: TestFixture;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, it } from 'node:test';
22
import * as assert from 'node:assert/strict';
3-
import { encodeGitCryptUri, decodeGitCryptUri } from '../src/uriUtil.js';
3+
import { encodeGitCryptUri, decodeGitCryptUri } from '../src/uri-util.js';
44

55
describe('encodeGitCryptUri', () => {
66
it('encodes a repo root, ref, and path into a URI string', () => {

0 commit comments

Comments
 (0)