lazygit
lazygit copied to clipboard
{{index .PromptResponses 0 }} on second prompt doesn't work
Describe the bug A clear and concise description of what the bug is.
I added this custom command
- key : '<c-n>'
description: 'Checkout a remote branch as FETCH_HEAD'
command: "git fetch {{ index .PromptResponses 0 }} {{ index .PromptResponses 1 }} && git switch {{ index .PromptResponses 1 }}"
context: 'localBranches'
prompts:
- type: 'input'
title: 'Remote:'
initialValue: "{{index .SelectedRemote.Name }}"
- type: 'menuFromCommand'
title: 'Remote branch:'
command: "git branch -r --list {{index .PromptResponses 0 }}/*"
filter: "{{index .PromptResponses 0 }}/(?P<branch>.*)"
valueFormat: '{{ .branch }}'
labelFormat: '{{ .branch | green }}'
but I have noting in {{index .PromptResponses 0 }} on the second prompt command I see only this
To Reproduce Steps to reproduce the behavior:
- create a config file on macOS
- add a custom command
- open a fresh lazygit using iTerm2
- I run
<c-n> - i have a popup with
origin - I use
enterwith my keyboard - I saw the picture in the log
- I saw a popup with empty
branchand just the cancel button
Expected behavior
A clear and concise description of what you expected to happen.
need to have origin in the command logged
git branch -r --list origin/*
Screenshots If applicable, add screenshots to help explain your problem.
Version info: commit=, build date=, build source=homebrew, version=0.35, os=darwin, arch=amd64 git version 2.37.1
Additional context Add any other context about the problem here.
Note: please try updating to the latest version or manually building the latest master to see if the issue still occurs.
Just a quick question to help me understand this, this command should just checkout a remote branch?
Just a quick question to help me understand this, this command should just checkout a remote branch?
yes this command "git fetch {{ index .PromptResponses 0 }} {{ index .PromptResponses 1 }} && git switch {{ index .PromptResponses 1 }}" is for checkout the remote branch,
and the command "git branch -r --list {{index .PromptResponses 0 }}/*" is for list all available branch on remote.
but I have this issue on other command I used every day, actually other command I hard coded the origin remote name, but sometimes I need to use upstream remote and I can't do that due the issue.
the issue is on {{index .PromptResponses 0 }} which don't have any value of the first alert prompt to use it on the second alert prompt
Alright, that's an issue that will be looked at. Thanks for reporting!
As a potential workaround, have you tried going to the Local Branches pane, pressing ] to reach the Remotes tab? After picking a remote you can checkout a branch by pressing space.
Alright, that's an issue that will be looked at. Thanks for reporting!
As a potential workaround, have you tried going to the
Local Branchespane, pressing]to reach theRemotestab? After picking a remote you can checkout a branch by pressingspace.
yes I know this feature, I used sometimes, but I prefer to have a prompt alert with all remote branchs, thanks @mark2185
FWIW all the action for this lives in pkg/gui/services/custom_commands/handler_creator.go specifically HandlerCreator's call method. Should be fairly easy to get to the bottom of
In other news, isn't this exact feature supposed to be behind the mapping c, i.e. checkout by name?
It brings up a prompt to find any branch by name :thinking:
Any news about the fix on this issue
No progress has been made. But I bet this would be a quick fix so I'll chuck a good first issue label on it. Is this something you'd be up to investigating @amine2233 ? I can give pointers where needed
@amine2233 could you check to see if the current master works?
@jesseduffield & @mark2185, sorry for my late answer, it's work perfectly, I'm able now to use my custom command, great work, thanks,