Skip to content

Commit

Permalink
feat(upload): add title support for managed projects
Browse files Browse the repository at this point in the history
  • Loading branch information
xizhao committed Mar 6, 2018
1 parent 08e3f61 commit 9bd1acc
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion cmd/fossa/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io/ioutil"
"net/http"
"net/url"
"path/filepath"
"strings"

logging "github.com/op/go-logging"
Expand Down Expand Up @@ -142,6 +143,10 @@ func doUpload(conf config.CLIConfig, results []normalizedModule) (string, error)
analysisLogger.Fatal("Could not infer revision name from `git` remote named `origin`. To submit a custom project, set Fetcher to `custom` in `.fossa.yml`")
}

if len(results) == 0 {
analysisLogger.Fatal("No results to upload")
}

// Re-marshal into build data
buildData, err := json.Marshal(results)
if err != nil {
Expand All @@ -152,7 +157,12 @@ func doUpload(conf config.CLIConfig, results []normalizedModule) (string, error)

fossaEndpoint := "/api/builds/custom?locator=" + url.QueryEscape(config.MakeLocator(conf.Fetcher, conf.Project, conf.Revision)) + "&v=" + version
if conf.Fetcher == "custom" {
fossaEndpoint += "&managedBuild=true"
defaultProjectTitle := results[0].Name
cwd, _ := filepath.Abs(".")
if cwd != "" {
defaultProjectTitle = filepath.Base(cwd)
}
fossaEndpoint += fmt.Sprintf("&managedBuild=true&title=%s", url.PathEscape(defaultProjectTitle))
}

postRef, _ := url.Parse(fossaEndpoint)
Expand Down

0 comments on commit 9bd1acc

Please sign in to comment.