diff --git a/src/helper/constants.ts b/src/helper/constants.ts index 1de3088..13cbebe 100644 --- a/src/helper/constants.ts +++ b/src/helper/constants.ts @@ -109,6 +109,7 @@ export const BUTTONS = [ { key: "commit", title: "Commit", event: "commit" }, { key: "push", title: "Push", event: "push" }, { key: "commitAndPush", title: "Commit & Push", event: "commitAndPush" }, + { key: "commitAndPullRebaseAndPush", title: "Commit & Pull Rebase & Push", event: "commitAndPullRebaseAndPush" }, ]; export const SETTINGS_SCHEMA: SettingSchemaDesc[] = [ diff --git a/src/main.tsx b/src/main.tsx index bcdd691..15576c9 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -102,6 +102,26 @@ if (isDevelopment) { } checkStatus(); }), + commitAndPullRebaseAndPush: debounce(async function () { + setPluginStyle(LOADING_STYLE); + hidePopup(); + + const status = await checkStatus(); + const changed = status?.stdout !== ""; + if (changed) { + const res = await commit( + true, + commitMessage() + ); + + if (res.exitCode === 0) { + const pull_res = await pullRebase(); + if (pull_res.exitCode == 0) await push(true); + } + } + checkStatus(); + }), + log: debounce(async function () { console.log("[faiz:] === log click"); const res = await log(false); @@ -216,6 +236,17 @@ if (isDevelopment) { }, () => operations.commitAndPush() ); + logseq.App.registerCommandPalette( + { + key: "logseq-plugin-git:commit&pullrebase&push", + label: "Commit & Pull Rebase & Push", + keybinding: { + binding: "unset", + mode: "global", + }, + }, + () => operations.commitAndPullRebaseAndPush() + ); logseq.App.registerCommandPalette( { key: "logseq-plugin-git:rebase",