From fcc62148e183ed94c6d99b795887729b80dc22db Mon Sep 17 00:00:00 2001 From: Eric Fritz Date: Thu, 7 May 2020 11:36:49 -0500 Subject: [PATCH] Add flag to ignore lsif upload failures. --- cmd/src/lsif_upload.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cmd/src/lsif_upload.go b/cmd/src/lsif_upload.go index 6ce1cab0a1..0a434e01be 100644 --- a/cmd/src/lsif_upload.go +++ b/cmd/src/lsif_upload.go @@ -67,6 +67,8 @@ Examples: 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).`) openFlag = flagSet.Bool("open", false, `Open the LSIF upload page in your browser.`) apiFlags = newAPIFlags(flagSet) + + ignoreUploadFailures = flagSet.Bool("ignore-upload-failure", false, `Exit with status code zero on upload failure.`) ) handler := func(args []string) error { @@ -209,6 +211,10 @@ Examples: // Perform the request. resp, err := http.DefaultClient.Do(req) if err != nil { + if *ignoreUploadFailures { + fmt.Printf("error: %s\n", err) + return nil + } return err } defer resp.Body.Close() @@ -236,6 +242,11 @@ Examples: fmt.Println("See https://github.com/sourcegraph/src-cli#authentication") fmt.Println("") } + + if resp.StatusCode == http.StatusInternalServerError && *ignoreUploadFailures { + fmt.Printf("error: %s\n\n%s", resp.Status, body) + return nil + } return fmt.Errorf("error: %s\n\n%s", resp.Status, body) }