From f68620dbc4ed7124e722aed32a1cc471c755d705 Mon Sep 17 00:00:00 2001 From: David Kang Date: Tue, 25 Jun 2024 14:43:59 -0700 Subject: [PATCH] Fix TS codegen outputting optional context variables (#421) --- cmd/lekko/repo.go | 2 +- pkg/gen/ts.go | 2 +- pkg/gitcli/gitcli.go | 4 ++-- pkg/repo/cmd.go | 3 ++- pkg/sync/push.go | 3 +-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cmd/lekko/repo.go b/cmd/lekko/repo.go index bb461b66..da17d993 100644 --- a/cmd/lekko/repo.go +++ b/cmd/lekko/repo.go @@ -458,7 +458,7 @@ func pullCmd() *cobra.Command { return errors.New("No remote found, please finish setup instructions") } fmt.Printf("Pulling from %s\n", remotes[0].Config().URLs[0]) - try.To(gitcli.Pull(repoPath)) + try.To1(gitcli.Pull(repoPath)) newHead := try.To1(gitRepo.Head()) lekkoPath := dot.LekkoPath diff --git a/pkg/gen/ts.go b/pkg/gen/ts.go index e560626c..161338a4 100644 --- a/pkg/gen/ts.go +++ b/pkg/gen/ts.go @@ -254,7 +254,7 @@ func GenTS(ctx context.Context, repoPath, ns string, getWriter func() (io.Writer for i := 0; i < d.Fields().Len(); i++ { f := d.Fields().Get(i) t := FieldDescriptorToTS(f) - fields = append(fields, fmt.Sprintf("%s?: %s;", strcase.ToLowerCamel(f.TextName()), t)) + fields = append(fields, fmt.Sprintf("%s: %s;", strcase.ToLowerCamel(f.TextName()), t)) varNames = append(varNames, strcase.ToLowerCamel(f.TextName())) } diff --git a/pkg/gitcli/gitcli.go b/pkg/gitcli/gitcli.go index ef4f23bb..fd31a056 100644 --- a/pkg/gitcli/gitcli.go +++ b/pkg/gitcli/gitcli.go @@ -21,10 +21,10 @@ func Clone(url, path string) ([]byte, error) { return cmd.CombinedOutput() } -func Pull(path string) error { +func Pull(path string) ([]byte, error) { cmd := exec.Command("git", "pull") cmd.Dir = path - return cmd.Run() + return cmd.CombinedOutput() } func Push(path string) ([]byte, error) { diff --git a/pkg/repo/cmd.go b/pkg/repo/cmd.go index e671d4d0..01cf822c 100644 --- a/pkg/repo/cmd.go +++ b/pkg/repo/cmd.go @@ -189,7 +189,8 @@ func PrepareGithubRepo() (string, error) { if err != nil { return "", errors.Wrap(err, "checkout main") } - if err := gitcli.Pull(repoPath); err != nil { + if pullOut, err := gitcli.Pull(repoPath); err != nil { + fmt.Println(string(pullOut)) return "", errors.Wrap(err, "pull") } } diff --git a/pkg/sync/push.go b/pkg/sync/push.go index 71b71b46..08af4f46 100644 --- a/pkg/sync/push.go +++ b/pkg/sync/push.go @@ -62,8 +62,7 @@ func Push(ctx context.Context, commitMessage string, force bool, dot *dotlekko.D if err != nil { return errors.Wrap(err, "reset and clean") } - err = gitcli.Pull(repoPath) - if err != nil { + if _, err = gitcli.Pull(repoPath); err != nil { return errors.Wrap(err, "pull from GitHub") } head, err := gitRepo.Head()