From 596a21b09a0b52245852b6e18ff00329a244be27 Mon Sep 17 00:00:00 2001 From: Filip Krayem Date: Sun, 2 Jul 2023 14:46:37 +0200 Subject: [PATCH 1/8] feat: Add ability to configure repository clone directory --- cmd/cmd-print.go | 3 ++ cmd/cmd-run.go | 3 ++ internal/multigitter/print.go | 5 ++- internal/multigitter/run.go | 7 ++-- internal/multigitter/shared.go | 73 ++++++++++++++++++++++++++++++++++ tests/repo_helper_test.go | 30 ++++++++++++-- tests/table_test.go | 43 ++++++++++++++++++-- 7 files changed, 153 insertions(+), 11 deletions(-) diff --git a/cmd/cmd-print.go b/cmd/cmd-print.go index 1314e2a6..c275e91e 100755 --- a/cmd/cmd-print.go +++ b/cmd/cmd-print.go @@ -34,6 +34,7 @@ func PrintCmd() *cobra.Command { cmd.Flags().IntP("concurrent", "C", 1, "The maximum number of concurrent runs.") cmd.Flags().StringP("error-output", "E", "-", `The file that the output of the script should be outputted to. "-" means stderr.`) + cmd.Flags().StringP("clone-dir", "", "", "The temporary directory where the repositories will be cloned. The directory cannot be inside another git repository. If not set, the default os temporary directory will be used.") configureGit(cmd) configurePlatform(cmd) configureLogging(cmd, "") @@ -49,6 +50,7 @@ func printCMD(cmd *cobra.Command, _ []string) error { concurrent, _ := flag.GetInt("concurrent") strOutput, _ := flag.GetString("output") strErrOutput, _ := flag.GetString("error-output") + cloneDir, _ := flag.GetString("clone-dir") if concurrent < 1 { return errors.New("concurrent runs can't be less than one") @@ -101,6 +103,7 @@ func printCMD(cmd *cobra.Command, _ []string) error { Stderr: errOutput, Concurrent: concurrent, + CloneDir: cloneDir, CreateGit: gitCreator, } diff --git a/cmd/cmd-run.go b/cmd/cmd-run.go index 031eb335..8a5a4713 100755 --- a/cmd/cmd-run.go +++ b/cmd/cmd-run.go @@ -62,6 +62,7 @@ Available values: cmd.Flags().StringSliceP("labels", "", nil, "Labels to be added to any created pull request.") cmd.Flags().StringP("author-name", "", "", "Name of the committer. If not set, the global git config setting will be used.") cmd.Flags().StringP("author-email", "", "", "Email of the committer. If not set, the global git config setting will be used.") + cmd.Flags().StringP("clone-dir", "", "", "The temporary directory where the repositories will be cloned. The directory cannot be inside another git repository. If not set, the default os temporary directory will be used.") configureGit(cmd) configurePlatform(cmd) configureRunPlatform(cmd, true) @@ -98,6 +99,7 @@ func run(cmd *cobra.Command, _ []string) error { assignees, _ := flag.GetStringSlice("assignees") draft, _ := flag.GetBool("draft") labels, _ := flag.GetStringSlice("labels") + cloneDir, _ := flag.GetString("clone-dir") if concurrent < 1 { return errors.New("concurrent runs can't be less than one") @@ -204,6 +206,7 @@ func run(cmd *cobra.Command, _ []string) error { ConflictStrategy: conflictStrategy, Draft: draft, Labels: labels, + CloneDir: cloneDir, Concurrent: concurrent, diff --git a/internal/multigitter/print.go b/internal/multigitter/print.go index 8be890f2..740e6680 100755 --- a/internal/multigitter/print.go +++ b/internal/multigitter/print.go @@ -21,6 +21,7 @@ type Printer struct { Stderr io.Writer Concurrent int + CloneDir string CreateGit func(dir string) Git } @@ -66,11 +67,11 @@ func (r Printer) runSingleRepo(ctx context.Context, repo scm.Repository) error { log := log.WithField("repo", repo.FullName()) log.Info("Cloning and running script") - tmpDir, err := os.MkdirTemp(os.TempDir(), "multi-git-changer-") + tmpDir, err := CreateTempDir(r.CloneDir) + defer os.RemoveAll(tmpDir) if err != nil { return err } - defer os.RemoveAll(tmpDir) sourceController := r.CreateGit(tmpDir) diff --git a/internal/multigitter/run.go b/internal/multigitter/run.go index 072b6df5..d9053c04 100755 --- a/internal/multigitter/run.go +++ b/internal/multigitter/run.go @@ -65,7 +65,8 @@ type Runner struct { Draft bool // If set, creates Pull Requests as draft - Labels []string // Labels to be added to the pull request + Labels []string // Labels to be added to the pull request + CloneDir string // Directory to clone repositories to Interactive bool // If set, interactive mode is activated and the user will be asked to verify every change @@ -201,11 +202,11 @@ func (r *Runner) runSingleRepo(ctx context.Context, repo scm.Repository) (scm.Pu log := log.WithField("repo", repo.FullName()) log.Info("Cloning and running script") - tmpDir, err := os.MkdirTemp(os.TempDir(), "multi-git-changer-") + tmpDir, err := CreateTempDir(r.CloneDir) + defer os.RemoveAll(tmpDir) if err != nil { return nil, err } - defer os.RemoveAll(tmpDir) sourceController := r.CreateGit(tmpDir) diff --git a/internal/multigitter/shared.go b/internal/multigitter/shared.go index d05b5f76..618b97b2 100644 --- a/internal/multigitter/shared.go +++ b/internal/multigitter/shared.go @@ -3,6 +3,9 @@ package multigitter import ( "context" "fmt" + "os" + "path/filepath" + "strings" "syscall" "github.com/lindell/multi-gitter/internal/git" @@ -70,3 +73,73 @@ func ParseConflictStrategy(str string) (ConflictStrategy, error) { return ConflictStrategyReplace, nil } } + +// CreateTempDir creates a temporary directory in the given directory. +// If the given directory is an empty string, it will use the os.TempDir() +func CreateTempDir(cloneDir string) (string, error) { + if cloneDir == "" { + cloneDir = os.TempDir() + } + + absDir, err := createAbsolutePath(cloneDir) + if err != nil { + return "", err + } + + err = createDirectoryIfDoesntExist(absDir) + if err != nil { + return "", err + } + + tmpDir, err := os.MkdirTemp(absDir, "multi-git-changer-") + if err != nil { + return "", err + } + + return tmpDir, nil +} + +func createDirectoryIfDoesntExist(directoryPath string) error { + // Check if the directory exists + if _, err := os.Stat(directoryPath); os.IsNotExist(err) { + // Create the directory + err := os.MkdirAll(directoryPath, os.ModePerm) + if err != nil { + return err + } + return nil + } + + return nil +} + +func createAbsolutePath(path string) (string, error) { + // Handle empty path + if path == "" { + return os.TempDir(), nil + } + + // Check if it is an absolute path + if filepath.IsAbs(path) { + return path, nil + } + + // Handle ~ to root directory + if strings.HasPrefix(path, "~/") { + homeDir, err := os.UserHomeDir() + if err != nil { + return "", err + } + path = filepath.Join(homeDir, path[2:]) + return path, nil + } + + workingDir, err := os.Getwd() + if err != nil { + return "", err + } + + absPath := filepath.Join(workingDir, path) + + return absPath, nil +} diff --git a/tests/repo_helper_test.go b/tests/repo_helper_test.go index 8968d3fd..10f025da 100644 --- a/tests/repo_helper_test.go +++ b/tests/repo_helper_test.go @@ -11,6 +11,7 @@ import ( git "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/plumbing" "github.com/go-git/go-git/v5/plumbing/object" + "github.com/lindell/multi-gitter/internal/multigitter" "github.com/lindell/multi-gitter/tests/vcmock" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -19,7 +20,7 @@ import ( const fileName = "test.txt" func createRepo(t *testing.T, ownerName string, repoName string, dataInFile string) vcmock.Repository { - tmpDir, err := createDummyRepo(dataInFile) + tmpDir, err := createDummyRepo(dataInFile, os.TempDir()) require.NoError(t, err) return vcmock.Repository{ @@ -29,8 +30,22 @@ func createRepo(t *testing.T, ownerName string, repoName string, dataInFile stri } } -func createDummyRepo(dataInFile string) (string, error) { - tmpDir, err := os.MkdirTemp(os.TempDir(), "multi-git-test-*.git") +func createRepoWithCloneDir(t *testing.T, ownerName string, repoName string, dataInFile string, dir string) vcmock.Repository { + dir, err := multigitter.CreateTempDir(dir) + require.NoError(t, err) + + tmpDir, err := createDummyRepo(dataInFile, dir) + require.NoError(t, err) + + return vcmock.Repository{ + OwnerName: ownerName, + RepoName: repoName, + Path: tmpDir, + } +} + +func createDummyRepo(dataInFile string, dir string) (string, error) { + tmpDir, err := os.MkdirTemp(dir, "multi-git-test-*.git") if err != nil { return "", err } @@ -178,3 +193,12 @@ func fileExist(t *testing.T, basePath string, fn string) bool { func normalizePath(path string) string { return strings.ReplaceAll(filepath.ToSlash(path), " ", "\\ ") } + +func indexOf(arr []string, target string) int { + for i, element := range arr { + if element == target { + return i + } + } + return -1 +} diff --git a/tests/table_test.go b/tests/table_test.go index 23e5b3ce..90823d2c 100644 --- a/tests/table_test.go +++ b/tests/table_test.go @@ -11,6 +11,7 @@ import ( "time" "github.com/lindell/multi-gitter/cmd" + "github.com/lindell/multi-gitter/internal/multigitter" "github.com/lindell/multi-gitter/internal/scm" "github.com/lindell/multi-gitter/tests/vcmock" "github.com/stretchr/testify/assert" @@ -980,6 +981,33 @@ Repositories with a successful run: assert.Equal(t, "Both the feature branch and base branch was named master, if you intended to push directly into the base branch, please use the `skip-pr` option:\n owner/should-not-change\n", runData.out) }, }, + { + name: "custom clone dir", + vcCreate: func(t *testing.T) *vcmock.VersionController { + return &vcmock.VersionController{ + Repositories: []vcmock.Repository{ + createRepoWithCloneDir(t, "owner", "should-change", "i like apples", "~/tmp-test"), + }, + } + }, + args: []string{ + "run", + "--author-name", "Test Author", + "--author-email", "test@example.com", + "-B", "clone-dir-branch-name", + "-m", "clone dir message", + "--clone-dir", "~/tmp-test", + changerBinaryPath, + }, + verify: func(t *testing.T, vcMock *vcmock.VersionController, runData runData) { + require.Len(t, vcMock.PullRequests, 1) + homeDir, err := os.UserHomeDir() + require.NoError(t, err) + + path := filepath.Join(homeDir, "tmp-test") + assert.Contains(t, vcMock.Repositories[0].Path, path) + }, + }, } for _, gitBackend := range gitBackends { @@ -990,18 +1018,27 @@ Repositories with a successful run: } t.Run(fmt.Sprintf("%s_%s", gitBackend, test.name), func(t *testing.T) { + dir := os.TempDir() + cloneDirFlagIndex := indexOf(test.args, "--clone-dir") + if cloneDirFlagIndex != -1 { + dir = test.args[cloneDirFlagIndex+1] + } + + tempDir, err := multigitter.CreateTempDir(dir) + require.NoError(t, err) + // Skip some tests depending on the values in skipTypes if skipOverlap(skipTypes, test.skipTypes) { t.SkipNow() } - logFile, err := os.CreateTemp(os.TempDir(), "multi-gitter-test-log") + logFile, err := os.CreateTemp(tempDir, "multi-gitter-test-log") require.NoError(t, err) defer os.Remove(logFile.Name()) - outFile, err := os.CreateTemp(os.TempDir(), "multi-gitter-test-output") + outFile, err := os.CreateTemp(tempDir, "multi-gitter-test-output") require.NoError(t, err) - // defer os.Remove(outFile.Name()) + defer os.Remove(outFile.Name()) vc := test.vcCreate(t) defer vc.Clean() From cd23524e994e943c120a9ae31b3c69cd6619d6c3 Mon Sep 17 00:00:00 2001 From: Filip Krayem Date: Thu, 13 Jul 2023 10:02:41 +0200 Subject: [PATCH 2/8] code review changes --- cmd/cmd-print.go | 2 +- cmd/cmd-run.go | 2 +- internal/multigitter/shared.go | 47 +++++++++++----------------------- tests/repo_helper_test.go | 24 ----------------- tests/table_test.go | 25 +++++------------- 5 files changed, 23 insertions(+), 77 deletions(-) diff --git a/cmd/cmd-print.go b/cmd/cmd-print.go index c275e91e..6a78230e 100755 --- a/cmd/cmd-print.go +++ b/cmd/cmd-print.go @@ -34,7 +34,7 @@ func PrintCmd() *cobra.Command { cmd.Flags().IntP("concurrent", "C", 1, "The maximum number of concurrent runs.") cmd.Flags().StringP("error-output", "E", "-", `The file that the output of the script should be outputted to. "-" means stderr.`) - cmd.Flags().StringP("clone-dir", "", "", "The temporary directory where the repositories will be cloned. The directory cannot be inside another git repository. If not set, the default os temporary directory will be used.") + cmd.Flags().StringP("clone-dir", "", "", "The temporary directory where the repositories will be cloned. If not set, the default os temporary directory will be used.") configureGit(cmd) configurePlatform(cmd) configureLogging(cmd, "") diff --git a/cmd/cmd-run.go b/cmd/cmd-run.go index 8a5a4713..e950e640 100755 --- a/cmd/cmd-run.go +++ b/cmd/cmd-run.go @@ -62,7 +62,7 @@ Available values: cmd.Flags().StringSliceP("labels", "", nil, "Labels to be added to any created pull request.") cmd.Flags().StringP("author-name", "", "", "Name of the committer. If not set, the global git config setting will be used.") cmd.Flags().StringP("author-email", "", "", "Email of the committer. If not set, the global git config setting will be used.") - cmd.Flags().StringP("clone-dir", "", "", "The temporary directory where the repositories will be cloned. The directory cannot be inside another git repository. If not set, the default os temporary directory will be used.") + cmd.Flags().StringP("clone-dir", "", "", "The temporary directory where the repositories will be cloned. If not set, the default os temporary directory will be used.") configureGit(cmd) configurePlatform(cmd) configureRunPlatform(cmd, true) diff --git a/internal/multigitter/shared.go b/internal/multigitter/shared.go index 618b97b2..413e60cf 100644 --- a/internal/multigitter/shared.go +++ b/internal/multigitter/shared.go @@ -5,7 +5,6 @@ import ( "fmt" "os" "path/filepath" - "strings" "syscall" "github.com/lindell/multi-gitter/internal/git" @@ -81,7 +80,7 @@ func CreateTempDir(cloneDir string) (string, error) { cloneDir = os.TempDir() } - absDir, err := createAbsolutePath(cloneDir) + absDir, err := makeAbsolutePath(cloneDir) if err != nil { return "", err } @@ -101,45 +100,29 @@ func CreateTempDir(cloneDir string) (string, error) { func createDirectoryIfDoesntExist(directoryPath string) error { // Check if the directory exists - if _, err := os.Stat(directoryPath); os.IsNotExist(err) { - // Create the directory - err := os.MkdirAll(directoryPath, os.ModePerm) - if err != nil { - return err - } + if _, err := os.Stat(directoryPath); !os.IsNotExist(err) { return nil } - return nil -} - -func createAbsolutePath(path string) (string, error) { - // Handle empty path - if path == "" { - return os.TempDir(), nil - } - - // Check if it is an absolute path - if filepath.IsAbs(path) { - return path, nil + // Create the directory + err := os.MkdirAll(directoryPath, os.ModePerm) + if err != nil { + return err } - // Handle ~ to root directory - if strings.HasPrefix(path, "~/") { - homeDir, err := os.UserHomeDir() - if err != nil { - return "", err - } - path = filepath.Join(homeDir, path[2:]) - return path, nil - } + return nil +} +// CreateAbsolutePath creates an absolute path from a relative path +func makeAbsolutePath(path string) (string, error) { workingDir, err := os.Getwd() if err != nil { - return "", err + return "", errors.Wrap(err, "could not get the working directory") } - absPath := filepath.Join(workingDir, path) + if !filepath.IsAbs(path) { + return filepath.Join(workingDir, path), nil + } - return absPath, nil + return path, nil } diff --git a/tests/repo_helper_test.go b/tests/repo_helper_test.go index 10f025da..64e13d11 100644 --- a/tests/repo_helper_test.go +++ b/tests/repo_helper_test.go @@ -11,7 +11,6 @@ import ( git "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/plumbing" "github.com/go-git/go-git/v5/plumbing/object" - "github.com/lindell/multi-gitter/internal/multigitter" "github.com/lindell/multi-gitter/tests/vcmock" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -30,20 +29,6 @@ func createRepo(t *testing.T, ownerName string, repoName string, dataInFile stri } } -func createRepoWithCloneDir(t *testing.T, ownerName string, repoName string, dataInFile string, dir string) vcmock.Repository { - dir, err := multigitter.CreateTempDir(dir) - require.NoError(t, err) - - tmpDir, err := createDummyRepo(dataInFile, dir) - require.NoError(t, err) - - return vcmock.Repository{ - OwnerName: ownerName, - RepoName: repoName, - Path: tmpDir, - } -} - func createDummyRepo(dataInFile string, dir string) (string, error) { tmpDir, err := os.MkdirTemp(dir, "multi-git-test-*.git") if err != nil { @@ -193,12 +178,3 @@ func fileExist(t *testing.T, basePath string, fn string) bool { func normalizePath(path string) string { return strings.ReplaceAll(filepath.ToSlash(path), " ", "\\ ") } - -func indexOf(arr []string, target string) int { - for i, element := range arr { - if element == target { - return i - } - } - return -1 -} diff --git a/tests/table_test.go b/tests/table_test.go index 90823d2c..bdae93a6 100644 --- a/tests/table_test.go +++ b/tests/table_test.go @@ -11,7 +11,6 @@ import ( "time" "github.com/lindell/multi-gitter/cmd" - "github.com/lindell/multi-gitter/internal/multigitter" "github.com/lindell/multi-gitter/internal/scm" "github.com/lindell/multi-gitter/tests/vcmock" "github.com/stretchr/testify/assert" @@ -986,7 +985,7 @@ Repositories with a successful run: vcCreate: func(t *testing.T) *vcmock.VersionController { return &vcmock.VersionController{ Repositories: []vcmock.Repository{ - createRepoWithCloneDir(t, "owner", "should-change", "i like apples", "~/tmp-test"), + createRepo(t, "owner", "should-change", "i like apples"), }, } }, @@ -996,16 +995,12 @@ Repositories with a successful run: "--author-email", "test@example.com", "-B", "clone-dir-branch-name", "-m", "clone dir message", - "--clone-dir", "~/tmp-test", + "--clone-dir", "./tmp-test", changerBinaryPath, }, verify: func(t *testing.T, vcMock *vcmock.VersionController, runData runData) { require.Len(t, vcMock.PullRequests, 1) - homeDir, err := os.UserHomeDir() - require.NoError(t, err) - - path := filepath.Join(homeDir, "tmp-test") - assert.Contains(t, vcMock.Repositories[0].Path, path) + assert.True(t, fileExist(t, workingDir, "tmp-test")) }, }, } @@ -1018,29 +1013,21 @@ Repositories with a successful run: } t.Run(fmt.Sprintf("%s_%s", gitBackend, test.name), func(t *testing.T) { - dir := os.TempDir() - cloneDirFlagIndex := indexOf(test.args, "--clone-dir") - if cloneDirFlagIndex != -1 { - dir = test.args[cloneDirFlagIndex+1] - } - - tempDir, err := multigitter.CreateTempDir(dir) - require.NoError(t, err) - // Skip some tests depending on the values in skipTypes if skipOverlap(skipTypes, test.skipTypes) { t.SkipNow() } - logFile, err := os.CreateTemp(tempDir, "multi-gitter-test-log") + logFile, err := os.CreateTemp(os.TempDir(), "multi-gitter-test-log") require.NoError(t, err) defer os.Remove(logFile.Name()) - outFile, err := os.CreateTemp(tempDir, "multi-gitter-test-output") + outFile, err := os.CreateTemp(os.TempDir(), "multi-gitter-test-output") require.NoError(t, err) defer os.Remove(outFile.Name()) vc := test.vcCreate(t) + defer vc.Clean() cmd.OverrideVersionController = vc From 1d651dc73d9eb33745157e6402d8f7e1d8e39db7 Mon Sep 17 00:00:00 2001 From: Filip Krayem Date: Wed, 19 Jul 2023 22:50:17 +0200 Subject: [PATCH 3/8] add clone dir to logs and check it in test --- internal/multigitter/print.go | 4 +++- internal/multigitter/run.go | 4 +++- internal/multigitter/shared.go | 6 +++--- tests/table_test.go | 1 + 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/internal/multigitter/print.go b/internal/multigitter/print.go index 740e6680..3139f73b 100755 --- a/internal/multigitter/print.go +++ b/internal/multigitter/print.go @@ -67,7 +67,9 @@ func (r Printer) runSingleRepo(ctx context.Context, repo scm.Repository) error { log := log.WithField("repo", repo.FullName()) log.Info("Cloning and running script") - tmpDir, err := CreateTempDir(r.CloneDir) + tmpDir, err := createTempDir(r.CloneDir) + log.Info("Cloning into directory ", tmpDir) + defer os.RemoveAll(tmpDir) if err != nil { return err diff --git a/internal/multigitter/run.go b/internal/multigitter/run.go index d9053c04..4d1c54db 100755 --- a/internal/multigitter/run.go +++ b/internal/multigitter/run.go @@ -202,7 +202,9 @@ func (r *Runner) runSingleRepo(ctx context.Context, repo scm.Repository) (scm.Pu log := log.WithField("repo", repo.FullName()) log.Info("Cloning and running script") - tmpDir, err := CreateTempDir(r.CloneDir) + tmpDir, err := createTempDir(r.CloneDir) + log.Info("Cloning into directory ", tmpDir) + defer os.RemoveAll(tmpDir) if err != nil { return nil, err diff --git a/internal/multigitter/shared.go b/internal/multigitter/shared.go index 413e60cf..fbbad4f8 100644 --- a/internal/multigitter/shared.go +++ b/internal/multigitter/shared.go @@ -73,9 +73,9 @@ func ParseConflictStrategy(str string) (ConflictStrategy, error) { } } -// CreateTempDir creates a temporary directory in the given directory. +// createTempDir creates a temporary directory in the given directory. // If the given directory is an empty string, it will use the os.TempDir() -func CreateTempDir(cloneDir string) (string, error) { +func createTempDir(cloneDir string) (string, error) { if cloneDir == "" { cloneDir = os.TempDir() } @@ -113,7 +113,7 @@ func createDirectoryIfDoesntExist(directoryPath string) error { return nil } -// CreateAbsolutePath creates an absolute path from a relative path +// makeAbsolutePath creates an absolute path from a relative path func makeAbsolutePath(path string) (string, error) { workingDir, err := os.Getwd() if err != nil { diff --git a/tests/table_test.go b/tests/table_test.go index bdae93a6..ba2eb3ff 100644 --- a/tests/table_test.go +++ b/tests/table_test.go @@ -1001,6 +1001,7 @@ Repositories with a successful run: verify: func(t *testing.T, vcMock *vcmock.VersionController, runData runData) { require.Len(t, vcMock.PullRequests, 1) assert.True(t, fileExist(t, workingDir, "tmp-test")) + assert.Contains(t, runData.logOut, normalizePath(filepath.Join(workingDir, "tmp-test/"))) }, }, } From ded3aa77fc0e285450070bc09159d7e9c16a6f89 Mon Sep 17 00:00:00 2001 From: Filip Krayem Date: Wed, 19 Jul 2023 23:03:14 +0200 Subject: [PATCH 4/8] normalize path when logging clone dir location --- internal/multigitter/print.go | 2 +- internal/multigitter/run.go | 2 +- internal/multigitter/shared.go | 5 +++++ tests/print_test.go | 6 ++++-- tests/repo_helper_test.go | 5 ----- tests/story_test.go | 21 ++++++++++++++------- tests/table_test.go | 13 +++++++------ 7 files changed, 32 insertions(+), 22 deletions(-) diff --git a/internal/multigitter/print.go b/internal/multigitter/print.go index 3139f73b..b660cb9c 100755 --- a/internal/multigitter/print.go +++ b/internal/multigitter/print.go @@ -68,7 +68,7 @@ func (r Printer) runSingleRepo(ctx context.Context, repo scm.Repository) error { log.Info("Cloning and running script") tmpDir, err := createTempDir(r.CloneDir) - log.Info("Cloning into directory ", tmpDir) + log.Info("Cloning into directory ", NormalizePath(tmpDir)) defer os.RemoveAll(tmpDir) if err != nil { diff --git a/internal/multigitter/run.go b/internal/multigitter/run.go index 4d1c54db..6873f57b 100755 --- a/internal/multigitter/run.go +++ b/internal/multigitter/run.go @@ -203,7 +203,7 @@ func (r *Runner) runSingleRepo(ctx context.Context, repo scm.Repository) (scm.Pu log.Info("Cloning and running script") tmpDir, err := createTempDir(r.CloneDir) - log.Info("Cloning into directory ", tmpDir) + log.Info("Cloning into directory ", NormalizePath(tmpDir)) defer os.RemoveAll(tmpDir) if err != nil { diff --git a/internal/multigitter/shared.go b/internal/multigitter/shared.go index fbbad4f8..3af9a5d6 100644 --- a/internal/multigitter/shared.go +++ b/internal/multigitter/shared.go @@ -5,6 +5,7 @@ import ( "fmt" "os" "path/filepath" + "strings" "syscall" "github.com/lindell/multi-gitter/internal/git" @@ -126,3 +127,7 @@ func makeAbsolutePath(path string) (string, error) { return path, nil } + +func NormalizePath(path string) string { + return strings.ReplaceAll(filepath.ToSlash(path), " ", "\\ ") +} diff --git a/tests/print_test.go b/tests/print_test.go index 109d52cc..6e4914ad 100644 --- a/tests/print_test.go +++ b/tests/print_test.go @@ -7,6 +7,7 @@ import ( "testing" "github.com/lindell/multi-gitter/cmd" + "github.com/lindell/multi-gitter/internal/multigitter" "github.com/lindell/multi-gitter/tests/vcmock" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -35,11 +36,12 @@ func TestPrint(t *testing.T) { errOutFile := filepath.Join(tmpDir, "err-out.txt") command := cmd.RootCmd() - command.SetArgs([]string{"print", + command.SetArgs([]string{ + "print", "--log-file", filepath.ToSlash(runLogFile), "--output", filepath.ToSlash(outFile), "--error-output", filepath.ToSlash(errOutFile), - fmt.Sprintf(`go run %s`, normalizePath(filepath.Join(workingDir, "scripts/printer/main.go"))), + fmt.Sprintf(`go run %s`, multigitter.NormalizePath(filepath.Join(workingDir, "scripts/printer/main.go"))), }) err = command.Execute() assert.NoError(t, err) diff --git a/tests/repo_helper_test.go b/tests/repo_helper_test.go index 64e13d11..355fe4bb 100644 --- a/tests/repo_helper_test.go +++ b/tests/repo_helper_test.go @@ -4,7 +4,6 @@ import ( "fmt" "os" "path/filepath" - "strings" "testing" "time" @@ -174,7 +173,3 @@ func fileExist(t *testing.T, basePath string, fn string) bool { require.NoError(t, err) return true } - -func normalizePath(path string) string { - return strings.ReplaceAll(filepath.ToSlash(path), " ", "\\ ") -} diff --git a/tests/story_test.go b/tests/story_test.go index 818f2448..f8ac3816 100644 --- a/tests/story_test.go +++ b/tests/story_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/lindell/multi-gitter/cmd" + "github.com/lindell/multi-gitter/internal/multigitter" "github.com/lindell/multi-gitter/internal/scm" "github.com/lindell/multi-gitter/tests/vcmock" "github.com/stretchr/testify/assert" @@ -25,7 +26,7 @@ func TestStory(t *testing.T) { workingDir, err := os.Getwd() assert.NoError(t, err) - changerBinaryPath := normalizePath(filepath.Join(workingDir, changerBinaryPath)) + changerBinaryPath := multigitter.NormalizePath(filepath.Join(workingDir, changerBinaryPath)) changeRepo := createRepo(t, "owner", "should-change", "i like apples") changeRepo2 := createRepo(t, "owner", "should-change-2", "i like my apple") @@ -37,7 +38,8 @@ func TestStory(t *testing.T) { runOutFile := filepath.Join(tmpDir, "run-log.txt") command := cmd.RootCmd() - command.SetArgs([]string{"run", + command.SetArgs([]string{ + "run", "--output", runOutFile, "--author-name", "Test Author", "--author-email", "test@example.com", @@ -75,7 +77,8 @@ Repositories with a successful run: statusOutFile := filepath.Join(tmpDir, "status-log.txt") command = cmd.RootCmd() - command.SetArgs([]string{"status", + command.SetArgs([]string{ + "status", "--output", statusOutFile, "-B", "custom-branch-name", }) @@ -96,7 +99,8 @@ Repositories with a successful run: mergeLogFile := filepath.Join(tmpDir, "merge-log.txt") command = cmd.RootCmd() - command.SetArgs([]string{"merge", + command.SetArgs([]string{ + "merge", "--log-file", mergeLogFile, "-B", "custom-branch-name", }) @@ -115,7 +119,8 @@ Repositories with a successful run: afterMergeStatusOutFile := filepath.Join(tmpDir, "after-merge-status-log.txt") command = cmd.RootCmd() - command.SetArgs([]string{"status", + command.SetArgs([]string{ + "status", "--output", afterMergeStatusOutFile, "-B", "custom-branch-name", }) @@ -133,7 +138,8 @@ Repositories with a successful run: closeLogFile := filepath.Join(tmpDir, "close-log.txt") command = cmd.RootCmd() - command.SetArgs([]string{"close", + command.SetArgs([]string{ + "close", "--log-file", closeLogFile, "-B", "custom-branch-name", }) @@ -152,7 +158,8 @@ Repositories with a successful run: afterCloseStatusOutFile := filepath.Join(tmpDir, "after-close-status-log.txt") command = cmd.RootCmd() - command.SetArgs([]string{"status", + command.SetArgs([]string{ + "status", "--output", afterCloseStatusOutFile, "-B", "custom-branch-name", }) diff --git a/tests/table_test.go b/tests/table_test.go index ba2eb3ff..a7c16e72 100644 --- a/tests/table_test.go +++ b/tests/table_test.go @@ -11,6 +11,7 @@ import ( "time" "github.com/lindell/multi-gitter/cmd" + "github.com/lindell/multi-gitter/internal/multigitter" "github.com/lindell/multi-gitter/internal/scm" "github.com/lindell/multi-gitter/tests/vcmock" "github.com/stretchr/testify/assert" @@ -72,7 +73,7 @@ func TestTable(t *testing.T) { workingDir, err := os.Getwd() assert.NoError(t, err) - changerBinaryPath := normalizePath(filepath.Join(workingDir, changerBinaryPath)) + changerBinaryPath := multigitter.NormalizePath(filepath.Join(workingDir, changerBinaryPath)) tests := []struct { name string @@ -135,7 +136,7 @@ func TestTable(t *testing.T) { "--author-email", "test@example.com", "-B", "custom-branch-name", "-m", "custom message", - fmt.Sprintf("go run %s", normalizePath(filepath.Join(workingDir, "scripts/changer/main.go"))), + fmt.Sprintf("go run %s", multigitter.NormalizePath(filepath.Join(workingDir, "scripts/changer/main.go"))), }, verify: func(t *testing.T, vcMock *vcmock.VersionController, runData runData) { require.Len(t, vcMock.PullRequests, 1) @@ -573,7 +574,7 @@ Repositories with a successful run: "--author-email", "test@example.com", "-B", "custom-branch-name", "-m", "custom message", - fmt.Sprintf("go run %s -filenames node_modules/react/README.md,src/index.js -data test", normalizePath(filepath.Join(workingDir, "scripts/adder/main.go"))), + fmt.Sprintf("go run %s -filenames node_modules/react/README.md,src/index.js -data test", multigitter.NormalizePath(filepath.Join(workingDir, "scripts/adder/main.go"))), }, verify: func(t *testing.T, vcMock *vcmock.VersionController, runData runData) { require.Len(t, vcMock.PullRequests, 1) @@ -600,7 +601,7 @@ Repositories with a successful run: "--author-email", "test@example.com", "-B", "custom-branch-name", "-m", "custom message", - fmt.Sprintf("go run %s -filenames node_modules/react/README.md,src/index.js -data test", normalizePath(filepath.Join(workingDir, "scripts/adder/main.go"))), + fmt.Sprintf("go run %s -filenames node_modules/react/README.md,src/index.js -data test", multigitter.NormalizePath(filepath.Join(workingDir, "scripts/adder/main.go"))), }, verify: func(t *testing.T, vcMock *vcmock.VersionController, runData runData) { require.Len(t, vcMock.PullRequests, 1) @@ -947,7 +948,7 @@ Repositories with a successful run: "--author-email", "test@example.com", "-B", "custom-branch-name", "-m", "custom message", - fmt.Sprintf("go run %s", normalizePath(filepath.Join(workingDir, "scripts/remover/main.go"))), + fmt.Sprintf("go run %s", multigitter.NormalizePath(filepath.Join(workingDir, "scripts/remover/main.go"))), }, verify: func(t *testing.T, vcMock *vcmock.VersionController, runData runData) { require.Len(t, vcMock.PullRequests, 1) @@ -1001,7 +1002,7 @@ Repositories with a successful run: verify: func(t *testing.T, vcMock *vcmock.VersionController, runData runData) { require.Len(t, vcMock.PullRequests, 1) assert.True(t, fileExist(t, workingDir, "tmp-test")) - assert.Contains(t, runData.logOut, normalizePath(filepath.Join(workingDir, "tmp-test/"))) + assert.Contains(t, runData.logOut, multigitter.NormalizePath(filepath.Join(workingDir, "tmp-test/"))) }, }, } From 1b6f96e8ca45f7af1d56d055119889a75cba48a5 Mon Sep 17 00:00:00 2001 From: Filip Krayem Date: Mon, 24 Jul 2023 18:59:42 +0200 Subject: [PATCH 5/8] add tests from @lindell --- internal/multigitter/print.go | 2 -- internal/multigitter/run.go | 2 -- internal/multigitter/shared.go | 7 +--- tests/print_test.go | 3 +- tests/repo_helper_test.go | 5 +++ tests/scripts/pwd/main.go | 17 +++++++++ tests/story_test.go | 3 +- tests/table_test.go | 64 ++++++++++++++++++++++++++++------ 8 files changed, 79 insertions(+), 24 deletions(-) create mode 100644 tests/scripts/pwd/main.go diff --git a/internal/multigitter/print.go b/internal/multigitter/print.go index b660cb9c..628f6061 100755 --- a/internal/multigitter/print.go +++ b/internal/multigitter/print.go @@ -66,9 +66,7 @@ func (r Printer) runSingleRepo(ctx context.Context, repo scm.Repository) error { log := log.WithField("repo", repo.FullName()) log.Info("Cloning and running script") - tmpDir, err := createTempDir(r.CloneDir) - log.Info("Cloning into directory ", NormalizePath(tmpDir)) defer os.RemoveAll(tmpDir) if err != nil { diff --git a/internal/multigitter/run.go b/internal/multigitter/run.go index 6873f57b..abe877df 100755 --- a/internal/multigitter/run.go +++ b/internal/multigitter/run.go @@ -201,9 +201,7 @@ func (r *Runner) runSingleRepo(ctx context.Context, repo scm.Repository) (scm.Pu log := log.WithField("repo", repo.FullName()) log.Info("Cloning and running script") - tmpDir, err := createTempDir(r.CloneDir) - log.Info("Cloning into directory ", NormalizePath(tmpDir)) defer os.RemoveAll(tmpDir) if err != nil { diff --git a/internal/multigitter/shared.go b/internal/multigitter/shared.go index 3af9a5d6..d3f9b400 100644 --- a/internal/multigitter/shared.go +++ b/internal/multigitter/shared.go @@ -5,7 +5,6 @@ import ( "fmt" "os" "path/filepath" - "strings" "syscall" "github.com/lindell/multi-gitter/internal/git" @@ -106,7 +105,7 @@ func createDirectoryIfDoesntExist(directoryPath string) error { } // Create the directory - err := os.MkdirAll(directoryPath, os.ModePerm) + err := os.MkdirAll(directoryPath, 0600) if err != nil { return err } @@ -127,7 +126,3 @@ func makeAbsolutePath(path string) (string, error) { return path, nil } - -func NormalizePath(path string) string { - return strings.ReplaceAll(filepath.ToSlash(path), " ", "\\ ") -} diff --git a/tests/print_test.go b/tests/print_test.go index 6e4914ad..d1e546af 100644 --- a/tests/print_test.go +++ b/tests/print_test.go @@ -7,7 +7,6 @@ import ( "testing" "github.com/lindell/multi-gitter/cmd" - "github.com/lindell/multi-gitter/internal/multigitter" "github.com/lindell/multi-gitter/tests/vcmock" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -41,7 +40,7 @@ func TestPrint(t *testing.T) { "--log-file", filepath.ToSlash(runLogFile), "--output", filepath.ToSlash(outFile), "--error-output", filepath.ToSlash(errOutFile), - fmt.Sprintf(`go run %s`, multigitter.NormalizePath(filepath.Join(workingDir, "scripts/printer/main.go"))), + fmt.Sprintf(`go run %s`, normalizePath(filepath.Join(workingDir, "scripts/printer/main.go"))), }) err = command.Execute() assert.NoError(t, err) diff --git a/tests/repo_helper_test.go b/tests/repo_helper_test.go index 355fe4bb..64e13d11 100644 --- a/tests/repo_helper_test.go +++ b/tests/repo_helper_test.go @@ -4,6 +4,7 @@ import ( "fmt" "os" "path/filepath" + "strings" "testing" "time" @@ -173,3 +174,7 @@ func fileExist(t *testing.T, basePath string, fn string) bool { require.NoError(t, err) return true } + +func normalizePath(path string) string { + return strings.ReplaceAll(filepath.ToSlash(path), " ", "\\ ") +} diff --git a/tests/scripts/pwd/main.go b/tests/scripts/pwd/main.go new file mode 100644 index 00000000..020d1f2d --- /dev/null +++ b/tests/scripts/pwd/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" +) + +func main() { + path, _ := os.Getwd() + fmt.Println("Current path:", path) + err := os.WriteFile("pwd.txt", []byte(path), 0600) + if err != nil { + fmt.Println("Could not write to pwd.txt:", err) + return + } + fmt.Println("Wrote to pwd.txt") +} diff --git a/tests/story_test.go b/tests/story_test.go index f8ac3816..0cfb97b4 100644 --- a/tests/story_test.go +++ b/tests/story_test.go @@ -6,7 +6,6 @@ import ( "testing" "github.com/lindell/multi-gitter/cmd" - "github.com/lindell/multi-gitter/internal/multigitter" "github.com/lindell/multi-gitter/internal/scm" "github.com/lindell/multi-gitter/tests/vcmock" "github.com/stretchr/testify/assert" @@ -26,7 +25,7 @@ func TestStory(t *testing.T) { workingDir, err := os.Getwd() assert.NoError(t, err) - changerBinaryPath := multigitter.NormalizePath(filepath.Join(workingDir, changerBinaryPath)) + changerBinaryPath := normalizePath(filepath.Join(workingDir, changerBinaryPath)) changeRepo := createRepo(t, "owner", "should-change", "i like apples") changeRepo2 := createRepo(t, "owner", "should-change-2", "i like my apple") diff --git a/tests/table_test.go b/tests/table_test.go index a7c16e72..4e9d6c0a 100644 --- a/tests/table_test.go +++ b/tests/table_test.go @@ -6,12 +6,12 @@ import ( "io" "os" "path/filepath" + "runtime" "strings" "testing" "time" "github.com/lindell/multi-gitter/cmd" - "github.com/lindell/multi-gitter/internal/multigitter" "github.com/lindell/multi-gitter/internal/scm" "github.com/lindell/multi-gitter/tests/vcmock" "github.com/stretchr/testify/assert" @@ -73,7 +73,7 @@ func TestTable(t *testing.T) { workingDir, err := os.Getwd() assert.NoError(t, err) - changerBinaryPath := multigitter.NormalizePath(filepath.Join(workingDir, changerBinaryPath)) + changerBinaryPath := normalizePath(filepath.Join(workingDir, changerBinaryPath)) tests := []struct { name string @@ -136,7 +136,7 @@ func TestTable(t *testing.T) { "--author-email", "test@example.com", "-B", "custom-branch-name", "-m", "custom message", - fmt.Sprintf("go run %s", multigitter.NormalizePath(filepath.Join(workingDir, "scripts/changer/main.go"))), + fmt.Sprintf("go run %s", normalizePath(filepath.Join(workingDir, "scripts/changer/main.go"))), }, verify: func(t *testing.T, vcMock *vcmock.VersionController, runData runData) { require.Len(t, vcMock.PullRequests, 1) @@ -574,7 +574,7 @@ Repositories with a successful run: "--author-email", "test@example.com", "-B", "custom-branch-name", "-m", "custom message", - fmt.Sprintf("go run %s -filenames node_modules/react/README.md,src/index.js -data test", multigitter.NormalizePath(filepath.Join(workingDir, "scripts/adder/main.go"))), + fmt.Sprintf("go run %s -filenames node_modules/react/README.md,src/index.js -data test", normalizePath(filepath.Join(workingDir, "scripts/adder/main.go"))), }, verify: func(t *testing.T, vcMock *vcmock.VersionController, runData runData) { require.Len(t, vcMock.PullRequests, 1) @@ -601,7 +601,7 @@ Repositories with a successful run: "--author-email", "test@example.com", "-B", "custom-branch-name", "-m", "custom message", - fmt.Sprintf("go run %s -filenames node_modules/react/README.md,src/index.js -data test", multigitter.NormalizePath(filepath.Join(workingDir, "scripts/adder/main.go"))), + fmt.Sprintf("go run %s -filenames node_modules/react/README.md,src/index.js -data test", normalizePath(filepath.Join(workingDir, "scripts/adder/main.go"))), }, verify: func(t *testing.T, vcMock *vcmock.VersionController, runData runData) { require.Len(t, vcMock.PullRequests, 1) @@ -948,7 +948,7 @@ Repositories with a successful run: "--author-email", "test@example.com", "-B", "custom-branch-name", "-m", "custom message", - fmt.Sprintf("go run %s", multigitter.NormalizePath(filepath.Join(workingDir, "scripts/remover/main.go"))), + fmt.Sprintf("go run %s", normalizePath(filepath.Join(workingDir, "scripts/remover/main.go"))), }, verify: func(t *testing.T, vcMock *vcmock.VersionController, runData runData) { require.Len(t, vcMock.PullRequests, 1) @@ -982,7 +982,7 @@ Repositories with a successful run: }, }, { - name: "custom clone dir", + name: "custom clone dir with relative path", vcCreate: func(t *testing.T) *vcmock.VersionController { return &vcmock.VersionController{ Repositories: []vcmock.Repository{ @@ -997,12 +997,55 @@ Repositories with a successful run: "-B", "clone-dir-branch-name", "-m", "clone dir message", "--clone-dir", "./tmp-test", - changerBinaryPath, + fmt.Sprintf("go run %s", normalizePath(filepath.Join(workingDir, "scripts/pwd/main.go"))), + }, + verify: func(t *testing.T, vcMock *vcmock.VersionController, runData runData) { + require.Len(t, vcMock.PullRequests, 1) + expectedPath := filepath.Join(workingDir, "tmp-test") + + // Check the path in the logs + assert.Contains(t, runData.logOut, "Current path: "+strings.ReplaceAll(expectedPath, `\`, `\\`)) + + // Check the path in + changeBranch(t, vcMock.Repositories[0].Path, "clone-dir-branch-name", false) + pathInFile := readFile(t, vcMock.Repositories[0].Path, "pwd.txt") + assert.True(t, strings.HasPrefix(pathInFile, expectedPath)) + }, + }, + { + name: "custom clone dir with absolute path", + vcCreate: func(t *testing.T) *vcmock.VersionController { + return &vcmock.VersionController{ + Repositories: []vcmock.Repository{ + createRepo(t, "owner", "should-change", "i like apples"), + }, + } + }, + args: []string{ + "run", + "--author-name", "Test Author", + "--author-email", "test@example.com", + "-B", "clone-dir-branch-name", + "-m", "clone dir message", + "--clone-dir", filepath.Join(os.TempDir(), "tmp-test"), + fmt.Sprintf("go run %s", normalizePath(filepath.Join(workingDir, "scripts/pwd/main.go"))), }, verify: func(t *testing.T, vcMock *vcmock.VersionController, runData runData) { require.Len(t, vcMock.PullRequests, 1) - assert.True(t, fileExist(t, workingDir, "tmp-test")) - assert.Contains(t, runData.logOut, multigitter.NormalizePath(filepath.Join(workingDir, "tmp-test/"))) + + tmpDir := os.TempDir() + // Fix for MacOS (darwin) where the tmp directory is aliased under two different directories + if runtime.GOOS == "darwin" { + tmpDir = filepath.Join("/private", tmpDir) + } + + expectedPath := filepath.Join(tmpDir, "tmp-test") + + assert.Contains(t, runData.logOut, "Current path: "+strings.ReplaceAll(expectedPath, `\`, `\\`)) + + changeBranch(t, vcMock.Repositories[0].Path, "clone-dir-branch-name", false) + pathInFile := readFile(t, vcMock.Repositories[0].Path, "pwd.txt") + assert.True(t, strings.HasPrefix(pathInFile, expectedPath)) }, }, } @@ -1071,3 +1114,4 @@ Repositories with a successful run: } } } + From a87f48c6b59ee5464e11c6e97f1d190ff40e13e6 Mon Sep 17 00:00:00 2001 From: Filip Krayem Date: Tue, 1 Aug 2023 09:27:24 +0200 Subject: [PATCH 6/8] commit to re-run actions --- tests/table_test.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/table_test.go b/tests/table_test.go index 4e9d6c0a..c59d3af4 100644 --- a/tests/table_test.go +++ b/tests/table_test.go @@ -1006,7 +1006,6 @@ Repositories with a successful run: // Check the path in the logs assert.Contains(t, runData.logOut, "Current path: "+strings.ReplaceAll(expectedPath, `\`, `\\`)) - // Check the path in changeBranch(t, vcMock.Repositories[0].Path, "clone-dir-branch-name", false) pathInFile := readFile(t, vcMock.Repositories[0].Path, "pwd.txt") assert.True(t, strings.HasPrefix(pathInFile, expectedPath)) @@ -1114,4 +1113,3 @@ Repositories with a successful run: } } } - From b94d727313a2342f3f8cba2e9ce87c0e4f8f0b85 Mon Sep 17 00:00:00 2001 From: Filip Krayem Date: Sat, 12 Aug 2023 10:52:04 +0200 Subject: [PATCH 7/8] make directory with more permissions --- internal/multigitter/shared.go | 2 +- tests/table_test.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/multigitter/shared.go b/internal/multigitter/shared.go index d3f9b400..fde49cf3 100644 --- a/internal/multigitter/shared.go +++ b/internal/multigitter/shared.go @@ -105,7 +105,7 @@ func createDirectoryIfDoesntExist(directoryPath string) error { } // Create the directory - err := os.MkdirAll(directoryPath, 0600) + err := os.MkdirAll(directoryPath, 0700) if err != nil { return err } diff --git a/tests/table_test.go b/tests/table_test.go index c59d3af4..9c42c7ae 100644 --- a/tests/table_test.go +++ b/tests/table_test.go @@ -980,7 +980,8 @@ Repositories with a successful run: require.Len(t, vcMock.PullRequests, 0) assert.Equal(t, "Both the feature branch and base branch was named master, if you intended to push directly into the base branch, please use the `skip-pr` option:\n owner/should-not-change\n", runData.out) }, - }, + }, + { name: "custom clone dir with relative path", vcCreate: func(t *testing.T) *vcmock.VersionController { @@ -1011,6 +1012,7 @@ Repositories with a successful run: assert.True(t, strings.HasPrefix(pathInFile, expectedPath)) }, }, + { name: "custom clone dir with absolute path", vcCreate: func(t *testing.T) *vcmock.VersionController { From 74acd9fb0dde8db091071d5e7bb710519dac6011 Mon Sep 17 00:00:00 2001 From: Johan Lindell Date: Sat, 4 May 2024 08:14:59 +0200 Subject: [PATCH 8/8] gofmt --- cmd/cmd-run.go | 3 +-- tests/table_test.go | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cmd/cmd-run.go b/cmd/cmd-run.go index 480ee06e..4bbaecc9 100755 --- a/cmd/cmd-run.go +++ b/cmd/cmd-run.go @@ -248,8 +248,7 @@ func run(cmd *cobra.Command, _ []string) error { ConflictStrategy: conflictStrategy, Draft: draft, Labels: labels, - CloneDir: cloneDir, - + CloneDir: cloneDir, Concurrent: concurrent, diff --git a/tests/table_test.go b/tests/table_test.go index 0c2a5e46..9e702783 100644 --- a/tests/table_test.go +++ b/tests/table_test.go @@ -1186,7 +1186,7 @@ Repositories with a successful run: require.Len(t, vcMock.PullRequests, 0) assert.Equal(t, "Both the feature branch and base branch was named master, if you intended to push directly into the base branch, please use the `skip-pr` option:\n owner/should-not-change\n", runData.out) }, - }, + }, { name: "custom clone dir with relative path",