Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rerost committed Aug 29, 2024
1 parent a0b4232 commit 66ad729
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
7 changes: 5 additions & 2 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,13 @@ func NewConfig() (Config, error) {
pflag.StringP("check-before-create-issue", "", "", "")

viper.AutomaticEnv()
viper.BindPFlags(pflag.CommandLine)
err := viper.BindPFlags(pflag.CommandLine)
if err != nil {
return Config{}, errors.WithStack(err)
}

var cfg Config
pflag.Parse()
err := viper.Unmarshal(&cfg)
err = viper.Unmarshal(&cfg)
return cfg, errors.WithStack(err)
}
2 changes: 1 addition & 1 deletion cmd/schedule/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func NewApplyCommand(ctx context.Context, templateFilePath string, srv schedule.
RunE: func(_ *cobra.Command, args []string) error {
b, err := os.ReadFile(templateFilePath)
if err != nil {
errors.WithStack(err)
return errors.WithStack(err)
}

templateFile := string(b)
Expand Down
2 changes: 1 addition & 1 deletion cmd/schedule/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func NewRenderCommand(ctx context.Context, templateFilePath string, srv schedule
zap.L().Debug("template path", zap.String("templateFilePath", templateFilePath))
b, err := os.ReadFile(templateFilePath)
if err != nil {
errors.WithStack(err)
return errors.WithStack(err)
}

templateFile := string(b)
Expand Down
9 changes: 6 additions & 3 deletions domain/issue/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ func (is *issueServiceImpl) render(ctx context.Context, templateIssueURL string)
if err != nil {
return types.Issue{}, errors.Wrap(err, "Failed to render title")
}
title := string(tw.Bytes())
title := tw.String()

bw := bytes.NewBufferString("")
err = bodyTmpl.Execute(bw, TemplateData{CurrentTime: is.ct, LastIssue: lastIssue, AddDay: func(d int) time.Time { return is.ct.AddDate(0, 0, d) }})
if err != nil {
return types.Issue{}, errors.Wrap(err, "Failed to render body")
}
body := string(bw.Bytes())
body := bw.String()

if lastIssue.URL == nil {
return types.Issue{}, errors.New("Invalid last issue passed(empty URL)")
Expand Down Expand Up @@ -126,7 +126,10 @@ func (is *issueServiceImpl) Create(ctx context.Context, templateURL string) (typ
if err != nil {
return types.Issue{}, errors.WithStack(err)
}
f.Chmod(0755)
err = f.Chmod(0755)
if err != nil {
return types.Issue{}, errors.WithStack(err)
}
f.Close()

out, err := exec.Command("sh", f.Name()).Output()
Expand Down
1 change: 0 additions & 1 deletion repo/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ func (ir *issueRepositoryImpl) FindLastIssue(ctx context.Context, templateIssue
var (
// State
closed = "closed"
open = "open"
)

func (ir *issueRepositoryImpl) CloseByURL(ctx context.Context, issueURL string) error {
Expand Down

0 comments on commit 66ad729

Please sign in to comment.