From 0a527b78ead65502ed81028dd379da92df3e20e2 Mon Sep 17 00:00:00 2001 From: orgrinrt Date: Thu, 6 Feb 2025 09:38:46 +0200 Subject: [PATCH 1/2] Clean up to the format/linting that autoran for our fork's main --- src/helper/constants.ts | 8 ++++++++ src/helper/git.ts | 14 +++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/helper/constants.ts b/src/helper/constants.ts index 1de3088..52027ac 100644 --- a/src/helper/constants.ts +++ b/src/helper/constants.ts @@ -112,6 +112,14 @@ export const BUTTONS = [ ]; export const SETTINGS_SCHEMA: SettingSchemaDesc[] = [ + { + key: "customRepoRoot", + title: "Custom Repository Root Path", + type: "string", + default: "/", + description: + "Custom repository root, relative to the current graph root (can contain `..` path nodes). Defaults to /, which means the graph root.", + }, { key: "buttons", title: "Buttons", diff --git a/src/helper/git.ts b/src/helper/git.ts index a3e0468..323a441 100644 --- a/src/helper/git.ts +++ b/src/helper/git.ts @@ -8,8 +8,16 @@ export const execGitCommand = async (args: string[]) : Promise => { let res try { - const currentGitFolder = (await logseq.App.getCurrentGraph())?.path - const runArgs = currentGitFolder ? ['-C', currentGitFolder, ...args] : args + const currentGitFolder = (await logseq.App.getCurrentGraph())?.path; + const relCurrGitFolder = currentGitFolder + ? //path.resolve( + (((currentGitFolder as string) + + "/" + + logseq.settings?.customRepoRoot) as string) + : //) + (logseq.settings?.customRepoRoot as string); + const runArgs = relCurrGitFolder ? ["-C", relCurrGitFolder, ...args] : args; + //const runArgs = currentGitFolder ? ["-C", currentGitFolder, ...args] : args; _inProgress = logseq.Git.execCommand(runArgs) res = await _inProgress } finally { @@ -147,7 +155,7 @@ export const push = async (showRes = true): Promise => { * @returns The commit message. */ export const commitMessage = () : string => { - + let defaultMessage = "[logseq-plugin-git:commit]"; switch (logseq.settings?.typeCommitMessage as string) { From 89309b5ff390122a620e6c9b679f0b68979e78ae Mon Sep 17 00:00:00 2001 From: orgrinrt Date: Thu, 6 Feb 2025 09:44:03 +0200 Subject: [PATCH 2/2] Fix whitespaces --- src/helper/git.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/helper/git.ts b/src/helper/git.ts index 323a441..0896dd0 100644 --- a/src/helper/git.ts +++ b/src/helper/git.ts @@ -9,15 +9,15 @@ export const execGitCommand = async (args: string[]) : Promise => { let res try { const currentGitFolder = (await logseq.App.getCurrentGraph())?.path; - const relCurrGitFolder = currentGitFolder - ? //path.resolve( - (((currentGitFolder as string) + - "/" + - logseq.settings?.customRepoRoot) as string) - : //) - (logseq.settings?.customRepoRoot as string); - const runArgs = relCurrGitFolder ? ["-C", relCurrGitFolder, ...args] : args; - //const runArgs = currentGitFolder ? ["-C", currentGitFolder, ...args] : args; + const relCurrGitFolder = currentGitFolder + ? //path.resolve( + (((currentGitFolder as string) + + "/" + + logseq.settings?.customRepoRoot) as string) + : //) + (logseq.settings?.customRepoRoot as string); + const runArgs = relCurrGitFolder ? ["-C", relCurrGitFolder, ...args] : args; + //const runArgs = currentGitFolder ? ["-C", currentGitFolder, ...args] : args; _inProgress = logseq.Git.execCommand(runArgs) res = await _inProgress } finally { @@ -155,7 +155,7 @@ export const push = async (showRes = true): Promise => { * @returns The commit message. */ export const commitMessage = () : string => { - + let defaultMessage = "[logseq-plugin-git:commit]"; switch (logseq.settings?.typeCommitMessage as string) {