Skip to content

Commit 714c8c3

Browse files
committed
refactor: rename fields to camel case
1 parent 43c70d8 commit 714c8c3

File tree

11 files changed

+70
-72
lines changed

11 files changed

+70
-72
lines changed

src/gitManager/isomorphicGit.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ export class IsomorphicGit extends GitManager {
160160
).map((row) => this.getFileStatusResult(row));
161161

162162
const changed = status.filter(
163-
(fileStatus) => fileStatus.working_dir !== " "
163+
(fileStatus) => fileStatus.workingDir !== " "
164164
);
165165
const staged = status.filter(
166166
(fileStatus) =>
@@ -269,7 +269,7 @@ export class IsomorphicGit extends GitManager {
269269
if (status) {
270270
await Promise.all(
271271
status.changed.map((file) =>
272-
file.working_dir !== "D"
272+
file.workingDir !== "D"
273273
? this.wrapFS(
274274
git.add({
275275
...this.getRepo(),
@@ -456,9 +456,9 @@ export class IsomorphicGit extends GitManager {
456456

457457
return changedFiles.map<FileStatusResult>((file) => ({
458458
path: file.path,
459-
working_dir: "P",
459+
workingDir: "P",
460460
index: "P",
461-
vault_path: this.getRelativeVaultPath(file.path),
461+
vaultPath: this.getRelativeVaultPath(file.path),
462462
}));
463463
} catch (error) {
464464
progressNotice?.hide();
@@ -798,9 +798,7 @@ export class IsomorphicGit extends GitManager {
798798
return {
799799
path: item.path,
800800
status: item.type,
801-
vault_path: this.getRelativeVaultPath(
802-
item.path
803-
),
801+
vaultPath: this.getRelativeVaultPath(item.path),
804802
hash: log.oid,
805803
};
806804
}),
@@ -913,14 +911,14 @@ export class IsomorphicGit extends GitManager {
913911

914912
async getStagedFiles(
915913
dir = "."
916-
): Promise<{ vault_path: string; path: string }[]> {
914+
): Promise<{ vaultPath: string; path: string }[]> {
917915
const res = await this.walkDifference({
918916
walkers: [git.TREE({ ref: "HEAD" }), git.STAGE()],
919917
dir,
920918
});
921919
return res.map((file) => {
922920
return {
923-
vault_path: this.getRelativeVaultPath(file.path),
921+
vaultPath: this.getRelativeVaultPath(file.path),
924922
path: file.path,
925923
};
926924
});
@@ -1150,9 +1148,9 @@ export class IsomorphicGit extends GitManager {
11501148
// status will always be two characters
11511149
return {
11521150
index: status[0] == "?" ? "U" : status[0],
1153-
working_dir: status[1] == "?" ? "U" : status[1],
1151+
workingDir: status[1] == "?" ? "U" : status[1],
11541152
path: row[this.FILE],
1155-
vault_path: this.getRelativeVaultPath(row[this.FILE]),
1153+
vaultPath: this.getRelativeVaultPath(row[this.FILE]),
11561154
};
11571155
}
11581156

src/gitManager/simpleGit.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,13 +246,13 @@ export class SimpleGit extends GitManager {
246246
path: res.path,
247247
from: res.from,
248248
index: e.index === "?" ? "U" : e.index,
249-
working_dir: e.working_dir === "?" ? "U" : e.working_dir,
250-
vault_path: this.getRelativeVaultPath(res.path),
249+
workingDir: e.working_dir === "?" ? "U" : e.working_dir,
250+
vaultPath: this.getRelativeVaultPath(res.path),
251251
};
252252
});
253253
return {
254254
all: allFilesFormatted,
255-
changed: allFilesFormatted.filter((e) => e.working_dir !== " "),
255+
changed: allFilesFormatted.filter((e) => e.workingDir !== " "),
256256
staged: allFilesFormatted.filter(
257257
(e) => e.index !== " " && e.index != "U"
258258
),
@@ -582,8 +582,8 @@ export class SimpleGit extends GitManager {
582582
.map((e) => {
583583
return <FileStatusResult>{
584584
path: e,
585-
working_dir: "P",
586-
vault_path: this.getRelativeVaultPath(e),
585+
workingDir: "P",
586+
vaultPath: this.getRelativeVaultPath(e),
587587
};
588588
});
589589
} else {
@@ -739,7 +739,7 @@ export class SimpleGit extends GitManager {
739739
status: f.status!,
740740
path: f.file,
741741
hash: e.hash,
742-
vault_path: this.getRelativeVaultPath(f.file),
742+
vaultPath: this.getRelativeVaultPath(f.file),
743743
fromPath: f.from,
744744
fromVaultPath:
745745
f.from != undefined

src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ export default class ObsidianGit extends Plugin {
751751
try {
752752
let hadConflict = this.localStorage.getConflict();
753753

754-
let changedFiles: { vault_path: string; path: string }[];
754+
let changedFiles: { vaultPath: string; path: string }[];
755755
let status: Status | undefined;
756756
let unstagedFiles: UnstagedFile[] | undefined;
757757

@@ -800,7 +800,7 @@ export default class ObsidianGit extends Plugin {
800800
} else {
801801
unstagedFiles = await gitManager.getUnstagedFiles();
802802
changedFiles = unstagedFiles.map(({ path }) => ({
803-
vault_path:
803+
vaultPath:
804804
this.gitManager.getRelativeVaultPath(path),
805805
path,
806806
}));

src/tools.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default class Tools {
1313
constructor(private readonly plugin: ObsidianGit) {}
1414

1515
async hasTooBigFiles(
16-
files: { vault_path: string; path: string }[]
16+
files: { vaultPath: string; path: string }[]
1717
): Promise<boolean> {
1818
const branchInfo = await this.plugin.gitManager.branchInfo();
1919
const remote = branchInfo.tracking
@@ -30,7 +30,7 @@ export default class Tools {
3030

3131
for (const f of files) {
3232
const file = this.plugin.app.vault.getAbstractFileByPath(
33-
f.vault_path
33+
f.vaultPath
3434
);
3535
if (file instanceof TFile) {
3636
if (file.stat.size >= 100000000) {
@@ -50,7 +50,7 @@ export default class Tools {
5050
if (tooBigFiles.length > 0) {
5151
this.plugin.displayError(
5252
`Did not commit, because following files are too big: ${tooBigFiles
53-
.map((e) => e.vault_path)
53+
.map((e) => e.vaultPath)
5454
.join("\n")}. Please remove them.`
5555
);
5656

src/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ export interface Blame {
193193
*/
194194
export interface FileStatusResult {
195195
path: string;
196-
vault_path: string;
196+
vaultPath: string;
197197
from?: string;
198198

199199
// First digit of the status code of the file, e.g. 'M' = modified.
@@ -202,7 +202,7 @@ export interface FileStatusResult {
202202
index: string;
203203
// Second digit of the status code of the file. Represents status of the working directory
204204
// if no merge conflicts, otherwise represents status of other side of a merge.
205-
working_dir: string;
205+
workingDir: string;
206206
}
207207

208208
export interface PluginState {
@@ -242,7 +242,7 @@ export interface DiffEntry {
242242

243243
export interface DiffFile {
244244
path: string;
245-
vault_path: string;
245+
vaultPath: string;
246246
fromPath?: string;
247247
fromVaultPath?: string;
248248
hash: string;

src/ui/history/components/logFileComponent.svelte

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
}
3131
3232
function open(event: MouseEvent) {
33-
const file = view.app.vault.getAbstractFileByPath(diff.vault_path);
33+
const file = view.app.vault.getAbstractFileByPath(diff.vaultPath);
3434
3535
if (file instanceof TFile) {
3636
getNewLeaf(view.app, event)
@@ -60,7 +60,7 @@
6060
mayTriggerFileMenu(
6161
view.app,
6262
event,
63-
diff.vault_path,
63+
diff.vaultPath,
6464
view.leaf,
6565
"git-history"
6666
);
@@ -71,16 +71,16 @@
7171
>
7272
<div
7373
class="tree-item-self is-clickable nav-file-title"
74-
data-path={diff.vault_path}
74+
data-path={diff.vaultPath}
7575
data-tooltip-position={side}
76-
aria-label={diff.vault_path}
76+
aria-label={diff.vaultPath}
7777
>
7878
<div class="tree-item-inner nav-file-title-content">
79-
{getDisplayPath(diff.vault_path)}
79+
{getDisplayPath(diff.vaultPath)}
8080
</div>
8181
<div class="git-tools">
8282
<div class="buttons">
83-
{#if view.app.vault.getAbstractFileByPath(diff.vault_path) instanceof TFile}
83+
{#if view.app.vault.getAbstractFileByPath(diff.vaultPath) instanceof TFile}
8484
<div
8585
data-icon="go-to-file"
8686
aria-label="Open File"

src/ui/modals/changedFilesModal.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,30 @@ export class ChangedFilesModal extends FuzzySuggestModal<FileStatusResult> {
2020
}
2121

2222
getItemText(item: FileStatusResult): string {
23-
if (item.index == "U" && item.working_dir == "U") {
24-
return `Untracked | ${item.vault_path}`;
23+
if (item.index == "U" && item.workingDir == "U") {
24+
return `Untracked | ${item.vaultPath}`;
2525
}
2626

27-
let working_dir = "";
27+
let workingDir = "";
2828
let index = "";
2929

30-
if (item.working_dir != " ")
31-
working_dir = `Working Dir: ${item.working_dir} `;
30+
if (item.workingDir != " ")
31+
workingDir = `Working Dir: ${item.workingDir} `;
3232
if (item.index != " ") index = `Index: ${item.index}`;
3333

34-
return `${working_dir}${index} | ${item.vault_path}`;
34+
return `${workingDir}${index} | ${item.vaultPath}`;
3535
}
3636

3737
onChooseItem(item: FileStatusResult, _: MouseEvent | KeyboardEvent): void {
3838
if (
3939
this.plugin.app.metadataCache.getFirstLinkpathDest(
40-
item.vault_path,
40+
item.vaultPath,
4141
""
4242
) == null
4343
) {
44-
this.app.openWithDefaultApp(item.vault_path);
44+
this.app.openWithDefaultApp(item.vaultPath);
4545
} else {
46-
void this.plugin.app.workspace.openLinkText(item.vault_path, "/");
46+
void this.plugin.app.workspace.openLinkText(item.vaultPath, "/");
4747
}
4848
}
4949
}

src/ui/sourceControl/components/fileComponent.svelte

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@
3535
3636
function hover(event: MouseEvent) {
3737
//Don't show previews of config- or hidden files.
38-
if (view.app.vault.getAbstractFileByPath(change.vault_path)) {
39-
hoverPreview(event, view, change.vault_path);
38+
if (view.app.vault.getAbstractFileByPath(change.vaultPath)) {
39+
hoverPreview(event, view, change.vaultPath);
4040
}
4141
}
4242
4343
function open(event: MouseEvent) {
44-
const file = view.app.vault.getAbstractFileByPath(change.vault_path);
44+
const file = view.app.vault.getAbstractFileByPath(change.vaultPath);
4545
4646
if (file instanceof TFile) {
4747
getNewLeaf(view.app, event)
@@ -68,13 +68,13 @@
6868
}
6969
7070
function discard() {
71-
const deleteFile = change.working_dir == "U";
72-
new DiscardModal(view.app, deleteFile, change.vault_path).myOpen().then(
71+
const deleteFile = change.workingDir == "U";
72+
new DiscardModal(view.app, deleteFile, change.vaultPath).myOpen().then(
7373
(shouldDiscard) => {
7474
if (shouldDiscard === true) {
7575
if (deleteFile) {
7676
return view.app.vault.adapter
77-
.remove(change.vault_path)
77+
.remove(change.vaultPath)
7878
.finally(() => {
7979
view.app.workspace.trigger(
8080
"obsidian-git:refresh"
@@ -105,7 +105,7 @@
105105
mayTriggerFileMenu(
106106
view.app,
107107
event,
108-
change.vault_path,
108+
change.vaultPath,
109109
view.leaf,
110110
"git-source-control"
111111
);
@@ -116,21 +116,21 @@
116116
>
117117
<div
118118
class="tree-item-self is-clickable nav-file-title"
119-
data-path={change.vault_path}
119+
data-path={change.vaultPath}
120120
data-tooltip-position={side}
121-
aria-label={change.vault_path}
121+
aria-label={change.vaultPath}
122122
>
123123
<!-- <div
124124
data-icon="folder"
125125
bind:this={buttons[3]}
126126
style="padding-right: 5px; display: flex;"
127127
/> -->
128128
<div class="tree-item-inner nav-file-title-content">
129-
{getDisplayPath(change.vault_path)}
129+
{getDisplayPath(change.vaultPath)}
130130
</div>
131131
<div class="git-tools">
132132
<div class="buttons">
133-
{#if view.app.vault.getAbstractFileByPath(change.vault_path) instanceof TFile}
133+
{#if view.app.vault.getAbstractFileByPath(change.vaultPath) instanceof TFile}
134134
<div
135135
data-icon="go-to-file"
136136
aria-label="Open File"
@@ -155,8 +155,8 @@
155155
class="clickable-icon"
156156
/>
157157
</div>
158-
<div class="type" data-type={change.working_dir}>
159-
{change.working_dir}
158+
<div class="type" data-type={change.workingDir}>
159+
{change.workingDir}
160160
</div>
161161
</div>
162162
</div>

src/ui/sourceControl/components/pulledFileComponent.svelte

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
1313
function hover(event: MouseEvent) {
1414
//Don't show previews of config- or hidden files.
15-
if (view.app.vault.getAbstractFileByPath(change.vault_path)) {
16-
hoverPreview(event, view, change.vault_path);
15+
if (view.app.vault.getAbstractFileByPath(change.vaultPath)) {
16+
hoverPreview(event, view, change.vaultPath);
1717
}
1818
}
1919
2020
function open(event: MouseEvent) {
21-
const file = view.app.vault.getAbstractFileByPath(change.vault_path);
21+
const file = view.app.vault.getAbstractFileByPath(change.vaultPath);
2222
if (file instanceof TFile) {
2323
getNewLeaf(view.app, event)
2424
?.openFile(file)
@@ -37,7 +37,7 @@
3737
mayTriggerFileMenu(
3838
view.app,
3939
event,
40-
change.vault_path,
40+
change.vaultPath,
4141
view.leaf,
4242
"git-source-control"
4343
);
@@ -48,16 +48,16 @@
4848
>
4949
<div
5050
class="tree-item-self is-clickable nav-file-title"
51-
data-path={change.vault_path}
51+
data-path={change.vaultPath}
5252
data-tooltip-position={side}
53-
aria-label={change.vault_path}
53+
aria-label={change.vaultPath}
5454
>
5555
<div class="tree-item-inner nav-file-title-content">
56-
{getDisplayPath(change.vault_path)}
56+
{getDisplayPath(change.vaultPath)}
5757
</div>
5858
<div class="git-tools">
59-
<span class="type" data-type={change.working_dir}
60-
>{change.working_dir}</span
59+
<span class="type" data-type={change.workingDir}
60+
>{change.workingDir}</span
6161
>
6262
</div>
6363
</div>

0 commit comments

Comments
 (0)