Skip to content

Commit 0001a82

Browse files
authored
Add flag to ignore lsif upload failures (#198)
1 parent cb94349 commit 0001a82

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

cmd/src/lsif_upload.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ Examples:
6767
indexerNameFlag = flagSet.String("indexerName", "", `The name of the indexer that generated the dump. This will override the 'toolInfo.name' field in the metadata vertex of the LSIF dump file. This must be supplied if the indexer does not set this field (in which case the upload will fail with an explicit message).`)
6868
openFlag = flagSet.Bool("open", false, `Open the LSIF upload page in your browser.`)
6969
apiFlags = newAPIFlags(flagSet)
70+
71+
ignoreUploadFailures = flagSet.Bool("ignore-upload-failure", false, `Exit with status code zero on upload failure.`)
7072
)
7173

7274
handler := func(args []string) error {
@@ -209,6 +211,10 @@ Examples:
209211
// Perform the request.
210212
resp, err := http.DefaultClient.Do(req)
211213
if err != nil {
214+
if *ignoreUploadFailures {
215+
fmt.Printf("error: %s\n", err)
216+
return nil
217+
}
212218
return err
213219
}
214220
defer resp.Body.Close()
@@ -236,6 +242,11 @@ Examples:
236242
fmt.Println("See https://github.com/sourcegraph/src-cli#authentication")
237243
fmt.Println("")
238244
}
245+
246+
if resp.StatusCode == http.StatusInternalServerError && *ignoreUploadFailures {
247+
fmt.Printf("error: %s\n\n%s", resp.Status, body)
248+
return nil
249+
}
239250
return fmt.Errorf("error: %s\n\n%s", resp.Status, body)
240251
}
241252

0 commit comments

Comments
 (0)