From 84a95406e5d71c49fbe63dcaedabd68f59ef95ff Mon Sep 17 00:00:00 2001 From: Michael Richman Date: Fri, 5 Dec 2025 06:01:00 +0000 Subject: [PATCH] fix --description-file validation and improve error messages --- .gitignore | 1 + git-open-pull.go | 12 ++++++++---- issues.go | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 7f52759..5742a95 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ pkg bin dist git-open-pull +.claude/ diff --git a/git-open-pull.go b/git-open-pull.go index 8b62909..32cdb13 100644 --- a/git-open-pull.go +++ b/git-open-pull.go @@ -4,7 +4,6 @@ import ( "context" "flag" "fmt" - "io/ioutil" "log" "os" "os/exec" @@ -107,13 +106,18 @@ func main() { var descriptionString string if *description != "" { - fileContent, err := ioutil.ReadFile(*description) + fileContent, err := os.ReadFile(*description) if err != nil { - log.Fatal(err) + log.Fatalf("error reading description file: %v", err) } descriptionString = string(fileContent) } + // Validate flag combinations + if !*interactive && *description != "" && *title == "" { + log.Fatal("--title is required when using --description-file with --interactive=false") + } + branch, err := GitFeatureBranch(ctx) if err != nil { log.Fatal(err) @@ -250,7 +254,7 @@ func main() { if settings.Callback != "" { // fetch the json of the current issue - tempFile, err := ioutil.TempFile("", fmt.Sprintf("issue-%d", issueNumber)) + tempFile, err := os.CreateTemp("", fmt.Sprintf("issue-%d", issueNumber)) if err != nil { log.Fatal(err) } diff --git a/issues.go b/issues.go index 61c649f..9649590 100644 --- a/issues.go +++ b/issues.go @@ -158,7 +158,7 @@ func PopulateIssueInteractive(ctx context.Context, client *github.Client, settin cmd := exec.CommandContext(ctx, settings.PreProcess, tempFile.Name()) out, err := cmd.CombinedOutput() if err != nil { - log.Printf("error running pre process template: %s:\n %s", settings.PreProcess, out) + log.Printf("error running pre process template: %s\n error: %v\n output: %s", settings.PreProcess, err, out) return nil, err } } @@ -182,7 +182,7 @@ func PopulateIssueInteractive(ctx context.Context, client *github.Client, settin cmd = exec.CommandContext(ctx, settings.PostProcess, tempFile.Name()) out, err := cmd.CombinedOutput() if err != nil { - log.Printf("error running post process template: %s:\n %s", settings.PostProcess, out) + log.Printf("error running post process template: %s\n error: %v\n output: %s", settings.PostProcess, err, out) return nil, err } }