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 2018/06/08 19:59:16 UTC

[GitHub] ccollins476ad closed pull request #174: Fix `install -f` for non-master repo commits

ccollins476ad closed pull request #174: Fix `install -f` for non-master repo commits
URL: https://github.com/apache/mynewt-newt/pull/174
 
 
   

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/install/install.go b/newt/install/install.go
index 4f4eb666..1ed89f5f 100644
--- a/newt/install/install.go
+++ b/newt/install/install.go
@@ -729,8 +729,9 @@ func (inst *Installer) Install(
 	// For a forced install, delete all existing repos.
 	if force {
 		for _, r := range repos {
-			// Don't delete the local project directory!
-			if !r.IsLocal() {
+			// Don't delete the local project directory!  And don't delete a
+			// repo that was just cloned during this invocation of newt.
+			if !r.IsLocal() && !r.IsNewlyCloned() {
 				util.StatusMessage(util.VERBOSITY_DEFAULT,
 					"Removing old copy of \"%s\" (%s)\n", r.Name(), r.Path())
 				os.RemoveAll(r.Path())
diff --git a/newt/repo/repo.go b/newt/repo/repo.go
index 2f77a336..ce0cff3d 100644
--- a/newt/repo/repo.go
+++ b/newt/repo/repo.go
@@ -222,17 +222,15 @@ func (r *Repo) checkExists() bool {
 }
 
 func (r *Repo) updateRepo(commit string) error {
-	err := r.downloader.UpdateRepo(r.Path(), commit)
-	if err != nil {
-		// If the update failed because the repo directory has been deleted,
-		// clone the repo again.
-		if util.IsNotExist(err) {
-			err = r.downloadRepo(commit)
-		}
-		if err != nil {
-			return util.FmtNewtError(
-				"Error updating \"%s\": %s", r.Name(), err.Error())
-		}
+	// Clone the repo if it doesn't exist.
+	if err := r.ensureExists(); err != nil {
+		return err
+	}
+
+	// Fetch and checkout the specified commit.
+	if err := r.downloader.UpdateRepo(r.Path(), commit); err != nil {
+		return util.FmtNewtError(
+			"Error updating \"%s\": %s", r.Name(), err.Error())
 	}
 
 	return nil


 

----------------------------------------------------------------
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