From 8c36c9f209a97ef4a88902b63e92effbafe75331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20W=C3=BCrl?= Date: Mon, 9 Sep 2024 13:02:24 +0200 Subject: [PATCH] Add Commit & Pull Rebase & Push action for convenient all in one update --- src/helper/constants.ts | 1 + src/main.tsx | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) 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",