Skip to content

Commit

Permalink
Add new dynamic param value {DEFAULT_REMOTE_NAME} for optional usag…
Browse files Browse the repository at this point in the history
…e in any command args
  • Loading branch information
phil294 committed Apr 17, 2024
1 parent f0c71bc commit 4eb4612
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ The only required parameters per action are `title` and `args`.
// More detailed help to understand what this command is about: Will help more inexperienced users. Will be collapsed by default, so this may be verbose. For the defaults, this is largely the DESCRIPTION section of `git help [the-command]`:
"info": "Switch to a specified branch. The working tree and the index are updated to match the branch. All new commits will be added to the tip of this branch.\n\nOptionally a new branch could be created with either -c, -C, automatically from a remote branch of bla bla etc",
"args": "switch \"$1\"", // The actual command, appended to `git `. This will be executed WITHOUT VALIDATION SO BE CAREFUL. $1, $2 and so on are placeholders for the respective `params`.
"params": [ "{LOCAL_BRANCH_NAME}" ], // Default values for the `args` placeholders. You can write anything here, including special keywords that include: {BRANCH_NAME}, {LOCAL_BRANCH_NAME}, {REMOTE_NAME}, {COMMIT_HASH}, {COMMIT_HASHES}, {STASH_NAME}, {TAG_NAME}, {SOURCE_BRANCH_NAME} and {TARGET_BRANCH_NAME} (where it makes sense).
"params": [ "{LOCAL_BRANCH_NAME}" ], // Default values for the `args` placeholders. You can write anything here, including special keywords that include: {BRANCH_NAME}, {LOCAL_BRANCH_NAME}, {REMOTE_NAME}, {COMMIT_HASH}, {COMMIT_HASHES}, {STASH_NAME}, {TAG_NAME}, {SOURCE_BRANCH_NAME}, {TARGET_BRANCH_NAME} and {DEFAULT_REMOTE_NAME} (where it makes sense, respectively).
// `options` are just an easy and quick way to toggle common trailing options. You can also specify them manually in `args` of course, given that `args` is also editable yet again at runtime.
"options": [
{
Expand Down
22 changes: 16 additions & 6 deletions web/src/views/store.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -127,27 +127,37 @@ export global_actions = computed =>
default_git_actions['actions.global'].concat(config.value.actions?.global or [])
export commit_actions = (###* @type string ### hash) => computed =>
config_commit_actions = default_git_actions['actions.commit'].concat(config.value.actions?.commit or [])
parse_config_actions(config_commit_actions, [['{COMMIT_HASH}', hash]])
parse_config_actions(config_commit_actions, [
['{COMMIT_HASH}', hash]
['{DEFAULT_REMOTE_NAME}', default_origin.value or 'MISSING_REMOTE_NAME']])
export commits_actions = (###* @type string[] ### hashes) => computed =>
config_commits_actions = default_git_actions['actions.commits'].concat(config.value.actions?.commits or [])
parse_config_actions(config_commits_actions, [['{COMMIT_HASHES}', hashes.join(' ')]])
parse_config_actions(config_commits_actions, [
['{COMMIT_HASHES}', hashes.join(' ')]
['{DEFAULT_REMOTE_NAME}', default_origin.value or 'MISSING_REMOTE_NAME']])
export branch_actions = (###* @type Branch ### branch) => computed =>
config_branch_actions = default_git_actions['actions.branch'].concat(config.value.actions?.branch or [])
parse_config_actions(config_branch_actions, [
['{BRANCH_NAME}', branch.id]
['{LOCAL_BRANCH_NAME}', branch.name]
['{REMOTE_NAME}', branch.remote_name or branch.tracking_remote_name or default_origin.value or 'MISSING_REMOTE_NAME']])
['{REMOTE_NAME}', branch.remote_name or branch.tracking_remote_name or default_origin.value or 'MISSING_REMOTE_NAME']
['{DEFAULT_REMOTE_NAME}', default_origin.value or 'MISSING_REMOTE_NAME']])
export tag_actions = (###* @type string ### tag_name) => computed =>
config_tag_actions = default_git_actions['actions.tag'].concat(config.value.actions?.tag or [])
parse_config_actions(config_tag_actions, [['{TAG_NAME}', tag_name]])
parse_config_actions(config_tag_actions, [
['{TAG_NAME}', tag_name]
['{DEFAULT_REMOTE_NAME}', default_origin.value or 'MISSING_REMOTE_NAME']])
export stash_actions = (###* @type string ### stash_name) => computed =>
config_stash_actions = default_git_actions['actions.stash'].concat(config.value.actions?.stash or [])
parse_config_actions(config_stash_actions, [['{STASH_NAME}', stash_name]])
parse_config_actions(config_stash_actions, [
['{STASH_NAME}', stash_name]
['{DEFAULT_REMOTE_NAME}', default_origin.value or 'MISSING_REMOTE_NAME']])
export combine_branches_actions = computed =>
config_combine_branches_actions = default_git_actions['actions.branch-drop'].concat(config.value.actions?['branch-drop'] or [])
parse_config_actions(config_combine_branches_actions, [
['{SOURCE_BRANCH_NAME}', combine_branches_from_branch_name.value]
['{TARGET_BRANCH_NAME}', combine_branches_to_branch_name.value]])
['{TARGET_BRANCH_NAME}', combine_branches_to_branch_name.value]
['{DEFAULT_REMOTE_NAME}', default_origin.value or 'MISSING_REMOTE_NAME']])

export combine_branches_to_branch_name = ref ''
export combine_branches_from_branch_name = ref ''
Expand Down

0 comments on commit 4eb4612

Please sign in to comment.