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

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


The following commit(s) were added to refs/heads/master by this push:
     new a2ff7dbd newt/downloader: Invalidate commit cache after git fetch
a2ff7dbd is described below

commit a2ff7dbd841ca66c9b9492d518fe32a9e89f2d2b
Author: Wiktor Kwiatkowski <[email protected]>
AuthorDate: Tue Sep 1 16:34:58 2026 +0200

    newt/downloader: Invalidate commit cache after git fetch
    
    newt upgrade fetched new refs but kept using map from before
    the fetch. Upgrades could be skipped or checkout the wrong commit.
    Invalidate the downloader cache after fetch so the next lookup
    rebuilds it from updated repo.
---
 newt/downloader/downloader.go | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/newt/downloader/downloader.go b/newt/downloader/downloader.go
index 14605f1d..9d647d1f 100644
--- a/newt/downloader/downloader.go
+++ b/newt/downloader/downloader.go
@@ -697,6 +697,11 @@ func (gd *GenericDownloader) CommitSha(path string, commit 
string) (string, erro
        return strings.TrimSpace(string(o)), nil
 }
 
+func (gd *GenericDownloader) invalidateCache() {
+       gd.commits = nil
+       gd.head = ""
+}
+
 // Fetches the downloader's origin remote if it hasn't been fetched yet during
 // this run.
 func (gd *GenericDownloader) cachedFetch(fn func() error) error {
@@ -709,6 +714,7 @@ func (gd *GenericDownloader) cachedFetch(fn func() error) 
error {
        }
 
        gd.fetched = true
+       gd.invalidateCache()
        return nil
 }
 

Reply via email to