Skip to content

Commit af4cb03

Browse files
authored
Merge pull request #50 from mrwoof/fix_description_file_flag
Fix --description-file validation
2 parents 024bc3a + 84a9540 commit af4cb03

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ pkg
33
bin
44
dist
55
git-open-pull
6+
.claude/

git-open-pull.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"flag"
66
"fmt"
7-
"io/ioutil"
87
"log"
98
"os"
109
"os/exec"
@@ -107,13 +106,18 @@ func main() {
107106

108107
var descriptionString string
109108
if *description != "" {
110-
fileContent, err := ioutil.ReadFile(*description)
109+
fileContent, err := os.ReadFile(*description)
111110
if err != nil {
112-
log.Fatal(err)
111+
log.Fatalf("error reading description file: %v", err)
113112
}
114113
descriptionString = string(fileContent)
115114
}
116115

116+
// Validate flag combinations
117+
if !*interactive && *description != "" && *title == "" {
118+
log.Fatal("--title is required when using --description-file with --interactive=false")
119+
}
120+
117121
branch, err := GitFeatureBranch(ctx)
118122
if err != nil {
119123
log.Fatal(err)
@@ -250,7 +254,7 @@ func main() {
250254

251255
if settings.Callback != "" {
252256
// fetch the json of the current issue
253-
tempFile, err := ioutil.TempFile("", fmt.Sprintf("issue-%d", issueNumber))
257+
tempFile, err := os.CreateTemp("", fmt.Sprintf("issue-%d", issueNumber))
254258
if err != nil {
255259
log.Fatal(err)
256260
}

issues.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ func PopulateIssueInteractive(ctx context.Context, client *github.Client, settin
158158
cmd := exec.CommandContext(ctx, settings.PreProcess, tempFile.Name())
159159
out, err := cmd.CombinedOutput()
160160
if err != nil {
161-
log.Printf("error running pre process template: %s:\n %s", settings.PreProcess, out)
161+
log.Printf("error running pre process template: %s\n error: %v\n output: %s", settings.PreProcess, err, out)
162162
return nil, err
163163
}
164164
}
@@ -182,7 +182,7 @@ func PopulateIssueInteractive(ctx context.Context, client *github.Client, settin
182182
cmd = exec.CommandContext(ctx, settings.PostProcess, tempFile.Name())
183183
out, err := cmd.CombinedOutput()
184184
if err != nil {
185-
log.Printf("error running post process template: %s:\n %s", settings.PostProcess, out)
185+
log.Printf("error running post process template: %s\n error: %v\n output: %s", settings.PostProcess, err, out)
186186
return nil, err
187187
}
188188
}

0 commit comments

Comments
 (0)