From 32a68b736143ac875c6a4cc168f4ada6efc1966e Mon Sep 17 00:00:00 2001 From: phil294 Date: Mon, 1 May 2023 20:10:19 +0200 Subject: [PATCH] make vscode config *extend* the default actions (global, branch etc.) instead of overwriting - so it's not necessary anymore to replicate all of them if you want to add a new one. Editing/removing default ones is not possible anymore though, this would require a new setting - seems pretty pointless though. --- package.json | 300 +------------------------ web/src/views/default-git-actions.json | 290 ++++++++++++++++++++++++ web/src/views/store.coffee | 15 +- 3 files changed, 304 insertions(+), 301 deletions(-) create mode 100644 web/src/views/default-git-actions.json diff --git a/package.json b/package.json index 1bc7ee6..d048250 100644 --- a/package.json +++ b/package.json @@ -88,44 +88,7 @@ } } } - }, - "default": [ - { - "title": "", - "icon": "chevron-up", - "description": "Stash (include untracked)", - "args": "stash -u", - "options": [ - { - "value": "--include-untracked", - "default_active": true - } - ], - "immediate": true - }, - { - "title": "", - "icon": "chevron-down", - "description": "Stash pop", - "args": "stash pop", - "immediate": true - }, - { - "title": "", - "icon": "cloud-download", - "description": "Fetch all", - "args": "fetch --all", - "immediate": true - }, - { - "title": "", - "icon": "circle-slash", - "description": "Abort the current merge or cherry-pick or rebase, if present.", - "args": "merge --abort; git cherry-pick --abort; git rebase --abort; git reset --merge", - "immediate": true, - "ignore_errors": true - } - ] + } }, "git-log--graph.actions.branch-drop": { "description": "Please check the extension's README for documentation. BE CAREFUL EDITING THESE OPTIONS.", @@ -180,52 +143,7 @@ } } } - }, - "default": [ - { - "title": "Merge {SOURCE_BRANCH_NAME} into {TARGET_BRANCH_NAME}...", - "icon": "git-merge", - "args": "checkout '$2' && git merge '$1'", - "params": [ - "{SOURCE_BRANCH_NAME}", - "{TARGET_BRANCH_NAME}" - ], - "options": [ - { - "value": "--no-commit", - "default_active": false - } - ] - }, - { - "title": "Rebase {SOURCE_BRANCH_NAME} into {TARGET_BRANCH_NAME}...", - "icon": "references", - "args": "checkout '$2' && git rebase '$1'", - "params": [ - "{SOURCE_BRANCH_NAME}", - "{TARGET_BRANCH_NAME}" - ] - }, - { - "title": "Reset {SOURCE_BRANCH_NAME} onto {TARGET_BRANCH_NAME}...", - "icon": "reply", - "args": "checkout '$1' && git reset '$2'", - "params": [ - "{SOURCE_BRANCH_NAME}", - "{TARGET_BRANCH_NAME}" - ], - "options": [ - { - "value": "--soft", - "default_active": false - }, - { - "value": "--hard", - "default_active": false - } - ] - } - ] + } }, "git-log--graph.actions.commit": { "description": "Please check the extension's README for documentation. BE CAREFUL EDITING THESE OPTIONS.", @@ -280,97 +198,7 @@ } } } - }, - "default": [ - { - "title": "Checkout", - "icon": "git-commit", - "immediate": true, - "args": "checkout '$1'", - "params": [ - "{COMMIT_HASH}" - ] - }, - { - "title": "Create branch", - "icon": "add", - "args": "branch '$1' '$2'", - "params": [ - "new_branch_name", - "{COMMIT_HASH}" - ] - }, - { - "title": "Create tag", - "icon": "tag", - "args": "tag '$1' '$2' --message '$3'", - "params": [ - "new_tag_name", - "{COMMIT_HASH}", - "" - ], - "options": [ - { - "value": "--annotate", - "default_active": true - } - ] - }, - { - "title": "Cherry pick", - "icon": "record", - "args": "cherry-pick '$1'", - "params": [ - "{COMMIT_HASH}" - ], - "options": [ - { - "value": "--no-commit", - "default_active": false - } - ] - }, - { - "title": "Revert", - "icon": "discard", - "args": "revert '$1'", - "params": [ - "{COMMIT_HASH}" - ], - "options": [ - { - "value": "--no-commit", - "default_active": false - } - ] - }, - { - "title": "Rebase", - "icon": "references", - "args": "rebase '$1'", - "params": [ - "{COMMIT_HASH}" - ] - }, - { - "title": "Reset", - "icon": "reply", - "args": "reset '$1'", - "params": [ - "{COMMIT_HASH}" - ], - "options": [ - { - "value": "--soft", - "default_active": false - }, - { - "value": "--hard", - "default_active": false - } - ] - } - ] + } }, "git-log--graph.actions.stash": { "description": "Please check the extension's README for documentation. BE CAREFUL EDITING THESE OPTIONS.", @@ -425,44 +253,7 @@ } } } - }, - "default": [ - { - "title": "Apply", - "icon": "arrow-right", - "immediate": true, - "args": "stash apply '$1'", - "params": [ - "{STASH_NAME}" - ] - }, - { - "title": "Pop", - "icon": "export", - "immediate": true, - "args": "stash pop '$1'", - "params": [ - "{STASH_NAME}" - ] - }, - { - "title": "Drop", - "icon": "trash", - "args": "stash drop '$1'", - "params": [ - "{STASH_NAME}" - ] - }, - { - "title": "To branch", - "icon": "add", - "args": "stash branch '$1' '$2'", - "params": [ - "new_branch_name", - "{STASH_NAME}" - ] - } - ] + } }, "git-log--graph.actions.tag": { "description": "Please check the extension's README for documentation. BE CAREFUL EDITING THESE OPTIONS.", @@ -517,17 +308,7 @@ } } } - }, - "default": [ - { - "title": "Delete", - "icon": "trash", - "args": "tag -d '$1'", - "params": [ - "{TAG_NAME}" - ] - } - ] + } }, "git-log--graph.actions.branch": { "description": "Please check the extension's README for documentation. BE CAREFUL EDITING THESE OPTIONS.", @@ -582,76 +363,7 @@ } } } - }, - "default": [ - { - "title": "Checkout", - "icon": "git-commit", - "description": "", - "immediate": true, - "args": "checkout '$1'", - "params": [ - "{BRANCH_NAME}" - ] - }, - { - "title": "Merge", - "icon": "git-merge", - "args": "merge '$1'", - "params": [ - "{BRANCH_NAME}" - ], - "options": [ - { - "value": "--no-commit", - "default_active": false - } - ] - }, - { - "title": "Pull", - "icon": "fold-down", - "description": "Pull", - "args": "pull" - }, - { - "title": "Push", - "icon": "fold-up", - "description": "Push", - "args": "push" - }, - { - "title": "Rename", - "icon": "edit", - "args": "branch -m '$1' '$2'", - "params": [ - "{BRANCH_NAME}", - "new_branch_name" - ] - }, - { - "title": "Delete", - "icon": "trash", - "args": "branch -d '$1'", - "params": [ - "{BRANCH_NAME}" - ], - "options": [ - { - "value": "--force", - "default_active": false - } - ] - }, - { - "title": "Rebase", - "icon": "references", - "args": "rebase '$1'", - "params": [ - "{BRANCH_NAME}" - ] - } - ] + } }, "git-log--graph.branch-width": { "description": "The width of the individual branch lines, including both line and right spacing. The default 'auto' chooses between 10 and 2 depending on the size of the repository.", diff --git a/web/src/views/default-git-actions.json b/web/src/views/default-git-actions.json new file mode 100644 index 0000000..b349e0f --- /dev/null +++ b/web/src/views/default-git-actions.json @@ -0,0 +1,290 @@ +{ + "actions.global": [ + { + "title": "", + "icon": "chevron-up", + "description": "Stash (include untracked)", + "args": "stash -u", + "options": [ + { + "value": "--include-untracked", + "default_active": true + } + ], + "immediate": true + }, + { + "title": "", + "icon": "chevron-down", + "description": "Stash pop", + "args": "stash pop", + "immediate": true + }, + { + "title": "", + "icon": "cloud-download", + "description": "Fetch all", + "args": "fetch --all", + "immediate": true + }, + { + "title": "", + "icon": "circle-slash", + "description": "Abort the current merge or cherry-pick or rebase, if present.", + "args": "merge --abort; git cherry-pick --abort; git rebase --abort; git reset --merge", + "immediate": true, + "ignore_errors": true + } + ], + "actions.branch-drop": [ + { + "title": "Merge {SOURCE_BRANCH_NAME} into {TARGET_BRANCH_NAME}...", + "icon": "git-merge", + "args": "checkout '$2' && git merge '$1'", + "params": [ + "{SOURCE_BRANCH_NAME}", + "{TARGET_BRANCH_NAME}" + ], + "options": [ + { + "value": "--no-commit", + "default_active": false + } + ] + }, + { + "title": "Rebase {SOURCE_BRANCH_NAME} into {TARGET_BRANCH_NAME}...", + "icon": "references", + "args": "checkout '$2' && git rebase '$1'", + "params": [ + "{SOURCE_BRANCH_NAME}", + "{TARGET_BRANCH_NAME}" + ] + }, + { + "title": "Reset {SOURCE_BRANCH_NAME} onto {TARGET_BRANCH_NAME}...", + "icon": "reply", + "args": "checkout '$1' && git reset '$2'", + "params": [ + "{SOURCE_BRANCH_NAME}", + "{TARGET_BRANCH_NAME}" + ], + "options": [ + { + "value": "--soft", + "default_active": false + }, + { + "value": "--hard", + "default_active": false + } + ] + } + ], + "actions.commit": [ + { + "title": "Checkout", + "icon": "git-commit", + "immediate": true, + "args": "checkout '$1'", + "params": [ + "{COMMIT_HASH}" + ] + }, + { + "title": "Create branch", + "icon": "add", + "args": "branch '$1' '$2'", + "params": [ + "new_branch_name", + "{COMMIT_HASH}" + ] + }, + { + "title": "Create tag", + "icon": "tag", + "args": "tag '$1' '$2' --message '$3'", + "params": [ + "new_tag_name", + "{COMMIT_HASH}", + "" + ], + "options": [ + { + "value": "--annotate", + "default_active": true + } + ] + }, + { + "title": "Cherry pick", + "icon": "record", + "args": "cherry-pick '$1'", + "params": [ + "{COMMIT_HASH}" + ], + "options": [ + { + "value": "--no-commit", + "default_active": false + } + ] + }, + { + "title": "Revert", + "icon": "discard", + "args": "revert '$1'", + "params": [ + "{COMMIT_HASH}" + ], + "options": [ + { + "value": "--no-commit", + "default_active": false + } + ] + }, + { + "title": "Rebase", + "icon": "references", + "args": "rebase '$1'", + "params": [ + "{COMMIT_HASH}" + ] + }, + { + "title": "Reset", + "icon": "reply", + "args": "reset '$1'", + "params": [ + "{COMMIT_HASH}" + ], + "options": [ + { + "value": "--soft", + "default_active": false + }, + { + "value": "--hard", + "default_active": false + } + ] + } + ], + "actions.stash": [ + { + "title": "Apply", + "icon": "arrow-right", + "immediate": true, + "args": "stash apply '$1'", + "params": [ + "{STASH_NAME}" + ] + }, + { + "title": "Pop", + "icon": "export", + "immediate": true, + "args": "stash pop '$1'", + "params": [ + "{STASH_NAME}" + ] + }, + { + "title": "Drop", + "icon": "trash", + "args": "stash drop '$1'", + "params": [ + "{STASH_NAME}" + ] + }, + { + "title": "To branch", + "icon": "add", + "args": "stash branch '$1' '$2'", + "params": [ + "new_branch_name", + "{STASH_NAME}" + ] + } + ], + "actions.tag": [ + { + "title": "Delete", + "icon": "trash", + "args": "tag -d '$1'", + "params": [ + "{TAG_NAME}" + ] + } + ], + "actions.branch": [ + { + "title": "Checkout", + "icon": "git-commit", + "description": "", + "immediate": true, + "args": "checkout '$1'", + "params": [ + "{BRANCH_NAME}" + ] + }, + { + "title": "Merge", + "icon": "git-merge", + "args": "merge '$1'", + "params": [ + "{BRANCH_NAME}" + ], + "options": [ + { + "value": "--no-commit", + "default_active": false + } + ] + }, + { + "title": "Pull", + "icon": "fold-down", + "description": "Pull", + "args": "pull" + }, + { + "title": "Push", + "icon": "fold-up", + "description": "Push", + "args": "push" + }, + { + "title": "Rename", + "icon": "edit", + "args": "branch -m '$1' '$2'", + "params": [ + "{BRANCH_NAME}", + "new_branch_name" + ] + }, + { + "title": "Delete", + "icon": "trash", + "args": "branch -d '$1'", + "params": [ + "{BRANCH_NAME}" + ], + "options": [ + { + "value": "--force", + "default_active": false + } + ] + }, + { + "title": "Rebase", + "icon": "references", + "args": "rebase '$1'", + "params": [ + "{BRANCH_NAME}" + ] + } + ] +} \ No newline at end of file diff --git a/web/src/views/store.coffee b/web/src/views/store.coffee index ee911f0..ca45431 100644 --- a/web/src/views/store.coffee +++ b/web/src/views/store.coffee @@ -1,8 +1,9 @@ -import { parse_config_actions } from "./GitInput.coffee" +import { ref, computed } from "vue" +import default_git_actions from './default-git-actions.json' import { parse } from "./log-utils.coffee" import { git, get_config, exchange_message } from "../bridge.coffee" +import { parse_config_actions } from "./GitInput.coffee" import GitInputModel from './GitInput.coffee' -import { ref, computed } from "vue" ``###* # @typedef {import('./types').GitRef} GitRef # @typedef {import('./types').Branch} Branch @@ -132,11 +133,11 @@ export init = => refresh_config() folder_names.value = await exchange_message 'get-folder-names' export refresh_config = => - global_actions.value = await get_config 'actions.global' - config_branch_actions.value = await get_config 'actions.branch' - config_commit_actions.value = await get_config 'actions.commit' - config_stash_actions.value = await get_config 'actions.stash' - config_tag_actions.value = await get_config 'actions.tag' + global_actions.value = default_git_actions['actions.global'].concat(await get_config 'actions.global') + config_branch_actions.value = default_git_actions['actions.branch'].concat(await get_config 'actions.branch') + config_commit_actions.value = default_git_actions['actions.commit'].concat(await get_config 'actions.commit') + config_stash_actions.value = default_git_actions['actions.stash'].concat(await get_config 'actions.stash') + config_tag_actions.value = default_git_actions['actions.tag'].concat(await get_config 'actions.tag') _unparsed_combine_branches_actions.value = await get_config 'actions.branch-drop'