mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-21 00:30:00 +02:00
Construct arg vector manually rather than parse string
By constructing an arg vector manually, we no longer need to quote arguments Mandate that args must be passed when building a command Now you need to provide an args array when building a command. There are a handful of places where we need to deal with a string, such as with user-defined custom commands, and for those we now require that at the callsite they use str.ToArgv to do that. I don't want to provide a method out of the box for it because I want to discourage its use. For some reason we were invoking a command through a shell when amending a commit, and I don't believe we needed to do that as there was nothing user- supplied about the command. So I've switched to using a regular command out- side the shell there
This commit is contained in:
pkg
app
commands
git.gogit_cmd_obj_builder.go
git_commands
bisect.gobranch.gobranch_test.gocommit.gocommit_file_loader.gocommit_loader.gocommit_loader_test.gocommit_test.gocustom.godiff.gofile.gofile_loader.gofile_loader_test.gofile_test.goflow.goflow_test.gogit_command_builder.gogit_command_builder_test.gopatch.gopatch_test.gorebase.gorebase_test.goreflog_commit_loader.goreflog_commit_loader_test.goremote.goremote_loader.gostash.gostash_loader.gostash_loader_test.gostash_test.gostatus.gosubmodule.gosync.gosync_test.gotag.gotag_loader.gotag_loader_test.goversion.goworking_tree.goworking_tree_test.go
oscommands
gui
controllers
integration
components
tests
bisect
branch
checkout_by_name.gocreate_tag.godelete.godetached_head.goopen_with_cli_arg.gorebase.gorebase_and_drop.gorebase_does_not_autosquash.goreset.goreset_upstream.goset_upstream.gosuggestions.go
cherry_pick
commit
amend.gocommit.gocommit_multiline.gocommit_wip_with_prefix.gocommit_with_prefix.gocreate_tag.godiscard_old_file_change.gohistory.gohistory_complex.gonew_branch.goreset_author.gorevert.gorevert_merge.goreword.gosearch.goset_author.gostage_range_of_lines.gostaged.gostaged_without_hooks.gounstaged.go
config
conflicts
custom_commands
basic_cmd_at_runtime.gobasic_cmd_from_config.gocomplex_cmd_at_runtime.goform_prompts.gomenu_from_command.gomenu_from_commands_output.gomultiple_prompts.goomit_from_history.go
diff
file
dir_with_untracked_file.godiscard_changes.godiscard_staged_changes.gogitignore.goremember_commit_message_after_fail.go
filter_by_path
interactive_rebase
advanced_interactive_rebase.goamend_first_commit.goamend_fixup_commit.goamend_head_commit_during_rebase.goamend_merge.goamend_non_head_commit_during_rebase.godrop_todo_commit_with_update_ref.godrop_todo_commit_with_update_ref_show_branch_heads.goedit_first_commit.goedit_non_todo_commit_during_rebase.gofixup_first_commit.gofixup_second_commit.gomove.gomove_in_rebase.gorebase.goreword_first_commit.goreword_last_commit.goreword_you_are_here_commit.goreword_you_are_here_commit_with_editor.gosquash_down_first_commit.gosquash_down_second_commit.gosquash_fixups_above_first_commit.goswap_in_rebase_with_conflict.goswap_with_conflict.go
misc
patch_building
apply.goapply_in_reverse.goapply_in_reverse_with_conflict.gocopy_patch_to_clipboard.gomove_to_earlier_commit.gomove_to_earlier_commit_no_keep_empty.gomove_to_index.gomove_to_index_part_of_adjacent_added_lines.gomove_to_index_partial.gomove_to_index_with_conflict.gomove_to_later_commit.gomove_to_later_commit_partial_hunk.gomove_to_new_commit.gomove_to_new_commit_partial_hunk.goremove_from_commit.goreset_with_escape.goselect_all_files.gospecific_selection.gostart_new_patch.go
reflog
shared
staging
stash
apply.goapply_patch.gocreate_branch.godrop.gopop.gorename.gostash.gostash_all.gostash_and_keep_index.gostash_including_untracked_files.gostash_staged.gostash_unstaged.go
submodule
sync
fetch_prune.goforce_push.goforce_push_multiple_matching.goforce_push_multiple_upstream.gopull.gopull_and_set_upstream.gopull_merge.gopull_merge_conflict.gopull_rebase.gopull_rebase_conflict.gopull_rebase_interactive_conflict.gopull_rebase_interactive_conflict_drop.gopush.gopush_and_auto_set_upstream.gopush_and_set_upstream.gopush_follow_tags.gopush_no_follow_tags.gopush_tag.gopush_with_credential_prompt.gorename_branch_and_pull.go
tag
test_list.goui
undo
updates
@ -20,14 +20,13 @@ func TestFileGetStatusFiles(t *testing.T) {
|
||||
{
|
||||
"No files found",
|
||||
oscommands.NewFakeRunner(t).
|
||||
Expect(`git status --untracked-files=yes --porcelain -z`, "", nil),
|
||||
ExpectGitArgs([]string{"status", "--untracked-files=yes", "--porcelain", "-z"}, "", nil),
|
||||
[]*models.File{},
|
||||
},
|
||||
{
|
||||
"Several files found",
|
||||
oscommands.NewFakeRunner(t).
|
||||
Expect(
|
||||
`git status --untracked-files=yes --porcelain -z`,
|
||||
ExpectGitArgs([]string{"status", "--untracked-files=yes", "--porcelain", "-z"},
|
||||
"MM file1.txt\x00A file3.txt\x00AM file2.txt\x00?? file4.txt\x00UU file5.txt",
|
||||
nil,
|
||||
),
|
||||
@ -102,7 +101,7 @@ func TestFileGetStatusFiles(t *testing.T) {
|
||||
{
|
||||
"File with new line char",
|
||||
oscommands.NewFakeRunner(t).
|
||||
Expect(`git status --untracked-files=yes --porcelain -z`, "MM a\nb.txt", nil),
|
||||
ExpectGitArgs([]string{"status", "--untracked-files=yes", "--porcelain", "-z"}, "MM a\nb.txt", nil),
|
||||
[]*models.File{
|
||||
{
|
||||
Name: "a\nb.txt",
|
||||
@ -122,8 +121,7 @@ func TestFileGetStatusFiles(t *testing.T) {
|
||||
{
|
||||
"Renamed files",
|
||||
oscommands.NewFakeRunner(t).
|
||||
Expect(
|
||||
`git status --untracked-files=yes --porcelain -z`,
|
||||
ExpectGitArgs([]string{"status", "--untracked-files=yes", "--porcelain", "-z"},
|
||||
"R after1.txt\x00before1.txt\x00RM after2.txt\x00before2.txt",
|
||||
nil,
|
||||
),
|
||||
@ -161,8 +159,7 @@ func TestFileGetStatusFiles(t *testing.T) {
|
||||
{
|
||||
"File with arrow in name",
|
||||
oscommands.NewFakeRunner(t).
|
||||
Expect(
|
||||
`git status --untracked-files=yes --porcelain -z`,
|
||||
ExpectGitArgs([]string{"status", "--untracked-files=yes", "--porcelain", "-z"},
|
||||
`?? a -> b.txt`,
|
||||
nil,
|
||||
),
|
||||
|
Reference in New Issue
Block a user