diff --git a/src-tauri/yaak-git/index.ts b/src-tauri/yaak-git/index.ts index 8014eb2f..9b92429e 100644 --- a/src-tauri/yaak-git/index.ts +++ b/src-tauri/yaak-git/index.ts @@ -51,6 +51,14 @@ export function useGit(dir: string) { mutationFn: (args) => invoke('plugin:yaak-git|commit', { dir, ...args }), onSuccess, }), + commitAndPush: useMutation({ + mutationKey: ['git', 'commitpush', dir], + mutationFn: async (args) => { + await invoke('plugin:yaak-git|commit', { dir, ...args }); + return invoke('plugin:yaak-git|push', { dir }); + }, + onSuccess, + }), fetchAll: useMutation({ mutationKey: ['git', 'checkout', dir], mutationFn: () => invoke('plugin:yaak-git|fetch_all', { dir }), diff --git a/src-web/components/GitCommitDialog.tsx b/src-web/components/GitCommitDialog.tsx index bdf7ada0..92f73027 100644 --- a/src-web/components/GitCommitDialog.tsx +++ b/src-web/components/GitCommitDialog.tsx @@ -39,7 +39,7 @@ interface TreeNode { } export function GitCommitDialog({ syncDir, onDone, workspace }: Props) { - const [{ status }, { commit, add, unstage, push }] = useGit(syncDir); + const [{ status }, { commit, commitAndPush, add, unstage, push }] = useGit(syncDir); const [message, setMessage] = useState(''); const handleCreateCommit = async () => { @@ -53,8 +53,7 @@ export function GitCommitDialog({ syncDir, onDone, workspace }: Props) { const handleCreateCommitAndPush = async () => { try { - await commit.mutateAsync({ message }); - await push.mutateAsync(); + await commitAndPush.mutateAsync({ message }); showToast({ id: 'git-push-success', message: 'Pushed changes', color: 'success' }); onDone(); } catch (err) { @@ -66,10 +65,13 @@ export function GitCommitDialog({ syncDir, onDone, workspace }: Props) { const allEntries = []; const yaakEntries = []; const externalEntries = []; + for (const entry of status.data?.entries ?? []) { allEntries.push(entry); if (entry.next == null && entry.prev == null) { externalEntries.push(entry); + } else if (entry.next?.model === 'environment' || entry.prev?.model === 'environment') { + externalEntries.push(entry); } else { yaakEntries.push(entry); } @@ -184,7 +186,7 @@ export function GitCommitDialog({ syncDir, onDone, workspace }: Props) { size="sm" onClick={handleCreateCommit} disabled={!hasAddedAnything} - isLoading={push.isPending || commit.isPending} + isLoading={push.isPending || commitAndPush.isPending || commit.isPending} > Commit @@ -193,7 +195,7 @@ export function GitCommitDialog({ syncDir, onDone, workspace }: Props) { size="sm" disabled={!hasAddedAnything} onClick={handleCreateCommitAndPush} - isLoading={push.isPending || commit.isPending} + isLoading={push.isPending || commitAndPush.isPending || commit.isPending} > Commit and Push