1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-28 16:02:01 +03: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:
Jesse Duffield
2023-05-21 17:00:29 +10:00
parent 70e473b25d
commit 63dc07fded
221 changed files with 1050 additions and 885 deletions

View File

@ -7,7 +7,7 @@ import (
var Amend = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Amends the last commit from the files panel",
ExtraCmdArgs: "",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {

View File

@ -7,7 +7,7 @@ import (
var Commit = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Staging a couple files and committing",
ExtraCmdArgs: "",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {

View File

@ -7,7 +7,7 @@ import (
var CommitMultiline = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Commit with a multi-line commit message",
ExtraCmdArgs: "",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {

View File

@ -7,7 +7,7 @@ import (
var CommitWipWithPrefix = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Commit with skip hook and config commitPrefix is defined. Prefix is ignored when creating WIP commits.",
ExtraCmdArgs: "",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(testConfig *config.AppConfig) {
testConfig.UserConfig.Git.CommitPrefixes = map[string]config.CommitPrefixConfig{"repo": {Pattern: "^\\w+\\/(\\w+-\\w+).*", Replace: "[$1]: "}}

View File

@ -7,7 +7,7 @@ import (
var CommitWithPrefix = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Commit with defined config commitPrefix",
ExtraCmdArgs: "",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(testConfig *config.AppConfig) {
testConfig.UserConfig.Git.CommitPrefixes = map[string]config.CommitPrefixConfig{"repo": {Pattern: "^\\w+\\/(\\w+-\\w+).*", Replace: "[$1]: "}}

View File

@ -7,7 +7,7 @@ import (
var CreateTag = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Create a new tag on a commit",
ExtraCmdArgs: "",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {

View File

@ -7,7 +7,7 @@ import (
var DiscardOldFileChange = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Discarding a single file from an old commit (does rebase in background to remove the file but retain the other one)",
ExtraCmdArgs: "",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {

View File

@ -7,7 +7,7 @@ import (
var History = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Cycling through commit message history in the commit message panel",
ExtraCmdArgs: "",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {

View File

@ -7,7 +7,7 @@ import (
var HistoryComplex = NewIntegrationTest(NewIntegrationTestArgs{
Description: "More complex flow for cycling commit message history",
ExtraCmdArgs: "",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {

View File

@ -7,7 +7,7 @@ import (
var NewBranch = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Creating a new branch from a commit",
ExtraCmdArgs: "",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {

View File

@ -7,7 +7,7 @@ import (
var ResetAuthor = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Reset author on a commit",
ExtraCmdArgs: "",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {

View File

@ -7,7 +7,7 @@ import (
var Revert = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Reverts a commit",
ExtraCmdArgs: "",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {

View File

@ -8,7 +8,7 @@ import (
var RevertMerge = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Reverts a merge commit and chooses to revert to the parent commit",
ExtraCmdArgs: "",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {

View File

@ -7,7 +7,7 @@ import (
var Reword = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Staging a couple files and committing",
ExtraCmdArgs: "",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {

View File

@ -7,7 +7,7 @@ import (
var Search = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Search for a commit",
ExtraCmdArgs: "",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {

View File

@ -7,7 +7,7 @@ import (
var SetAuthor = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Set author on a commit",
ExtraCmdArgs: "",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {

View File

@ -7,7 +7,7 @@ import (
var StageRangeOfLines = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Staging a range of lines",
ExtraCmdArgs: "",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {

View File

@ -7,7 +7,7 @@ import (
var Staged = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Staging a couple files, going in the staged files menu, unstaging a line then committing",
ExtraCmdArgs: "",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {

View File

@ -7,7 +7,7 @@ import (
var StagedWithoutHooks = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Staging a couple files, going in the staged files menu, unstaging a line then committing without pre-commit hooks",
ExtraCmdArgs: "",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {

View File

@ -7,7 +7,7 @@ import (
var Unstaged = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Staging a couple files, going in the unstaged files menu, staging a line and committing",
ExtraCmdArgs: "",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {