Skip to content

Commit

Permalink
Fix TS codegen outputting optional context variables (#421)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidSGK authored Jun 25, 2024
1 parent 7f9c6b3 commit f68620d
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/lekko/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/gen/ts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/gitcli/gitcli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion pkg/repo/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/sync/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit f68620d

Please sign in to comment.