You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2017/11/28 19:32:29 UTC

[GitHub] ccollins476ad closed pull request #112: Abort operation when git clone fails

ccollins476ad closed pull request #112: Abort operation when git clone fails
URL: https://github.com/apache/mynewt-newt/pull/112
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/newt/downloader/downloader.go b/newt/downloader/downloader.go
index 8475fdf..e4ccf07 100644
--- a/newt/downloader/downloader.go
+++ b/newt/downloader/downloader.go
@@ -669,6 +669,11 @@ func NewLocalDownloader() *LocalDownloader {
 	return &LocalDownloader{}
 }
 
+func loadError(format string, args ...interface{}) error {
+	return util.NewNewtError(
+		"error loading project.yml: " + fmt.Sprintf(format, args...))
+}
+
 func LoadDownloader(repoName string, repoVars map[string]string) (
 	Downloader, error) {
 
@@ -707,6 +712,10 @@ func LoadDownloader(repoName string, repoVars map[string]string) (
 	case "git":
 		gd := NewGitDownloader()
 		gd.Url = repoVars["url"]
+		if gd.Url == "" {
+			return nil, loadError("repo \"%s\" missing required field \"url\"",
+				repoName)
+		}
 		return gd, nil
 
 	case "local":
@@ -715,7 +724,6 @@ func LoadDownloader(repoName string, repoVars map[string]string) (
 		return ld, nil
 
 	default:
-		return nil, util.FmtNewtError("Invalid repository type: %s",
-			repoVars["type"])
+		return nil, loadError("invalid repository type: %s", repoVars["type"])
 	}
 }
diff --git a/newt/repo/repo.go b/newt/repo/repo.go
index bea592e..6a05c69 100644
--- a/newt/repo/repo.go
+++ b/newt/repo/repo.go
@@ -441,7 +441,7 @@ func (r *Repo) downloadRepo(branchName string) error {
 
 	// Download the git repo, returns the git repo, checked out to that branch
 	if err := dl.DownloadRepo(branchName, tmpdir); err != nil {
-		return util.FmtNewtError("Error downloading repository %s, : %s",
+		return util.FmtNewtError("Error downloading repository %s: %s",
 			r.Name(), err.Error())
 	}
 
@@ -657,7 +657,9 @@ func (r *Repo) downloadRepositoryYml() error {
 
 	// Clone the repo if it doesn't exist.
 	if util.NodeNotExist(r.localPath) {
-		r.downloadRepo("master")
+		if err := r.downloadRepo("master"); err != nil {
+			return err
+		}
 	}
 
 	cpath := r.repoFilePath()


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services