From dfb05aaa2ba0f4cd96e0525e0df2a87631612664 Mon Sep 17 00:00:00 2001 From: Jonas Lukasczyk Date: Mon, 14 Oct 2024 17:40:42 +0200 Subject: [PATCH] soft and hard git reset support in git commit view --- .../renderer/src/dialogs/GitResetDialog.vue | 74 +++++++++++++++++++ packages/renderer/src/views/GitCommitView.vue | 52 ++++++++----- 2 files changed, 109 insertions(+), 17 deletions(-) create mode 100644 packages/renderer/src/dialogs/GitResetDialog.vue diff --git a/packages/renderer/src/dialogs/GitResetDialog.vue b/packages/renderer/src/dialogs/GitResetDialog.vue new file mode 100644 index 0000000..03e9732 --- /dev/null +++ b/packages/renderer/src/dialogs/GitResetDialog.vue @@ -0,0 +1,74 @@ + + + diff --git a/packages/renderer/src/views/GitCommitView.vue b/packages/renderer/src/views/GitCommitView.vue index c44657f..720acac 100644 --- a/packages/renderer/src/views/GitCommitView.vue +++ b/packages/renderer/src/views/GitCommitView.vue @@ -15,6 +15,7 @@ import AppProperties from '../AppProperties.ts'; import pDebounce from 'p-debounce'; import GitDialog from '../dialogs/GitDialog.vue'; +import GitResetDialog from '../dialogs/GitResetDialog.vue'; import StringDialog from '../dialogs/StringDialog.vue'; import { useQuasar } from 'quasar' const $q = useQuasar(); @@ -189,26 +190,43 @@ const abortMerge = async()=>{ }; const reset = async()=>{ - const dialogProps = reactive({ - title: 'Resetting ARC', - ok_title: 'Ok', - cancel_title: null, - state: 0, - }); - $q.dialog({ - component: GitDialog, - componentProps: dialogProps - }).onOk( async () => { - ArcControlService.readARC(); - init(); - }); + component: GitResetDialog + }).onOk( async hard => { + const dialogProps = reactive({ + title: `Resetting ARC (${hard?'hard':'soft'})`, + ok_title: 'Ok', + cancel_title: null, + state: 0, + }); + + $q.dialog({ + component: GitDialog, + componentProps: dialogProps + }).onOk( async () => { + ArcControlService.readARC(); + init(); + }); + + // perform git reset + { + const response = await window.ipc.invoke('GitService.run', { + args: [`reset`,`--hard`], + cwd: ArcControlService.props.arc_root + }); + if(!response[0]) return dialogProps.state = 2; + } - const response = await window.ipc.invoke('GitService.run', { - args: [`reset`,`--hard`], - cwd: ArcControlService.props.arc_root + // optionally perform git clean + if(hard){ + const response = await window.ipc.invoke('GitService.run', { + args: [`clean`,`-d`, `-f`], + cwd: ArcControlService.props.arc_root + }); + if(!response[0]) return dialogProps.state = 2; + } + dialogProps.state = 1; }); - dialogProps.state = response[0] ? 1 : 2; }; const init = async()=>{