diff --git a/cmd/git-sync/main.go b/cmd/git-sync/main.go index 0cd8a6a02..18db1b9f1 100644 --- a/cmd/git-sync/main.go +++ b/cmd/git-sync/main.go @@ -545,8 +545,7 @@ func addWorktreeAndSwap(ctx context.Context, gitRoot, dest, branch, rev string, // Update submodules // NOTE: this works for repo with or without submodules. if submoduleMode != SubmoduleModeOff { - err = updateSubmodules(ctx, worktreePath, depth, submoduleMode) - if err != nil { + if err := updateSubmodules(ctx, worktreePath, depth, submoduleMode); err != nil { return err } } @@ -586,8 +585,8 @@ func updateSubmodules(ctx context.Context, worktreePath string, depth int, submo updateArgs := submoduleUpdateArgs(depth, submoduleMode) submodulesArgs := append([]string{"submodule", "update", "--init"}, updateArgs...) - _, err := runCommand(ctx, worktreePath, *flGitCmd, submodulesArgs...) - if err != nil { + + if _, err := runCommand(ctx, worktreePath, *flGitCmd, submodulesArgs...); err != nil { return err } @@ -624,8 +623,8 @@ func updateSubmodulesWithRemoteTracking(ctx context.Context, worktreePath string log.V(0).Info("updating submodule with remote tracking", "submoduleName", submoduleName, "submodulePath", submodulePath) submoduleRemoteUpdateArgs := append([]string{"submodule", "update", "--remote"}, updateArgs...) submoduleRemoteUpdateArgs = append(submoduleRemoteUpdateArgs, submodulePath) - _, err = runCommand(ctx, worktreePath, *flGitCmd, submoduleRemoteUpdateArgs...) - if err != nil { + + if _, err = runCommand(ctx, worktreePath, *flGitCmd, submoduleRemoteUpdateArgs...); err != nil { return err } @@ -640,8 +639,7 @@ func updateSubmodulesWithRemoteTracking(ctx context.Context, worktreePath string return nil } -func submoduleUpdateArgs(depth int, submoduleMode string) []string { - args := []string{} +func submoduleUpdateArgs(depth int, submoduleMode string) (args []string) { if submoduleMode == SubmoduleModeRecursive { args = append(args, "--recursive") } @@ -649,7 +647,7 @@ func submoduleUpdateArgs(depth int, submoduleMode string) []string { args = append(args, "--depth", strconv.Itoa(depth)) } - return args + return } func submoduleIsUpToDate(ctx context.Context, worktreePath, submodulePath string) (bool, error) {