This is an automated email from the ASF dual-hosted git repository.

utzig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git

commit 403de363933b868c7d959567720cb0b0fd6441b2
Author: Fabio Utzig <ut...@apache.org>
AuthorDate: Thu Mar 5 08:49:07 2020 -0300

    Remove mcuboot submodule hack
    
    After the conditional submodule feature added with
    905c71ce407f94da1f6812dd6b24cda885336548, the mcuboot repo was updated
    to inform that Mynewt does not required cloning of submodules; the hack
    is not required anymore.
    
    Signed-off-by: Fabio Utzig <ut...@apache.org>
---
 newt/downloader/downloader.go | 68 ++-----------------------------------------
 1 file changed, 2 insertions(+), 66 deletions(-)

diff --git a/newt/downloader/downloader.go b/newt/downloader/downloader.go
index 43f1f02..474309d 100644
--- a/newt/downloader/downloader.go
+++ b/newt/downloader/downloader.go
@@ -372,58 +372,6 @@ func untrackedFilesFromCheckoutErr(err error) []string {
        return files
 }
 
-// applyMcubootPreHack attempts to clean up the mcuboot repo so that the
-// subsequent checkout operation will succeed.  This hack is required because a
-// directory in the mcuboot repo was replaced with a submodule.  Git is unable
-// to transition from a post-replace commit to a pre-replace commit because
-// some files in the submodule used to exist in the mcuboot repo itself.  If
-// this issue is detected, this function deletes the submodule directory so
-// that the checkout operation can be attempted again.
-func applyMcubootPreHack(repoDir string, err error) error {
-       if !strings.HasSuffix(repoDir, "repos/mcuboot") {
-               // Not the mcuboot repo.
-               return err
-       }
-
-       // Check for an "untracked files" error.
-       files := untrackedFilesFromCheckoutErr(err)
-       if len(files) == 0 {
-               // Not a hackable error.
-               return err
-       }
-
-       for _, file := range files {
-               if !strings.HasPrefix(file, "ext/mbedtls") {
-                       return err
-               }
-       }
-
-       path := repoDir + "/ext/mbedtls"
-       log.Debugf("applying mcuboot hack: removing %s", path)
-       os.RemoveAll(path)
-       return nil
-}
-
-// applyMcubootPostHack attempts to clean up the mcuboot repo so that the
-// subsequent checkout operation will succeed.  This hack is required because a
-// directory in the mcuboot repo was replaced with a submodule.  This hack
-// should be applied after a successful checkout from a pre-replace commit to a
-// post-replace commit.  This function deletes an orphan directory left behind
-// by the checkout operation.
-func applyMcubootPostHack(repoDir string, output string) {
-       if !strings.HasSuffix(repoDir, "repos/mcuboot") {
-               // Not the mcuboot repo.
-               return
-       }
-
-       // Check for a "unable to rmdir" warning (pre- to post- submodule move).
-       if strings.Contains(output, "unable to rmdir 
'sim/mcuboot-sys/mbedtls'") {
-               path := repoDir + "/sim/mcuboot-sys/mbedtls"
-               log.Debugf("applying mcuboot hack: removing %s", path)
-               os.RemoveAll(path)
-       }
-}
-
 func (gd *GenericDownloader) Checkout(repoDir string, commit string) error {
        // Get the hash corresponding to the commit in case the caller 
specified a
        // branch or tag.  We always want to check out a hash and end up in a
@@ -439,20 +387,8 @@ func (gd *GenericDownloader) Checkout(repoDir string, 
commit string) error {
                hash,
        }
 
-       o, err := executeGitCommand(repoDir, cmd, true)
-       if err != nil {
-               if err := applyMcubootPreHack(repoDir, err); err != nil {
-                       return err
-               }
-
-               if _, err := executeGitCommand(repoDir, cmd, true); err != nil {
-                       return err
-               }
-       } else {
-               applyMcubootPostHack(repoDir, string(o))
-       }
-
-       return nil
+       _, err = executeGitCommand(repoDir, cmd, true)
+       return err
 }
 
 // Update one submodule tree in a repo (under path)

Reply via email to