Skip to content

Commit 04a0807

Browse files
authored
handle gracefully when digger fails to get local branch (#1621)
1 parent 8bc751c commit 04a0807

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

dgctl/cmd/exec.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func GetSpec(diggerUrl string, authToken string, command string, actor string, p
115115
}
116116

117117
if resp.StatusCode != http.StatusOK {
118-
return nil, fmt.Errorf("unexpected status when reporting a project: %v", resp.StatusCode)
118+
return nil, fmt.Errorf("unexpected status when getting spec: %v", resp.StatusCode)
119119
}
120120

121121
body, err := io.ReadAll(resp.Body)
@@ -188,14 +188,14 @@ var execCmd = &cobra.Command{
188188

189189
defaultBanch, err := getDefaultBranch()
190190
if err != nil {
191-
log.Printf("could not get default branch: %v", err)
192-
os.Exit(1)
191+
log.Printf("could not get default branch, please enter manually:")
192+
fmt.Scanln(&defaultBanch)
193193
}
194194

195195
prBranch, err := getPrBranch()
196196
if err != nil {
197-
log.Printf("could not get pr branch: %v", err)
198-
os.Exit(1)
197+
log.Printf("could not get current branch, please enter manually:")
198+
fmt.Scanln(&prBranch)
199199
}
200200

201201
projectName := execConfig.Project
@@ -219,6 +219,9 @@ var execCmd = &cobra.Command{
219219
}
220220

221221
specBytes, err := GetSpec(diggerHostname, "abc123", command, actor, string(projectMarshalled), string(configMarshalled), repoFullname, defaultBanch, prBranch)
222+
if err != nil {
223+
log.Printf("failed to get spec from backend: %v", err)
224+
}
222225
var spec spec.Spec
223226
err = json.Unmarshal(specBytes, &spec)
224227

0 commit comments

Comments
 (0)