This is an automated email from the ASF dual-hosted git repository.
andk 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 1dc2b53e Skip fetching newly cloned repos
1dc2b53e is described below
commit 1dc2b53e5149705393738040c32dfbe3e257f183
Author: Andrzej Kaczmarek <[email protected]>
AuthorDate: Wed Oct 30 15:53:09 2024 +0100
Skip fetching newly cloned repos
This makes sure we don't fetch repo that has just been cloned.
---
newt/downloader/downloader.go | 40 +++++++++++++++++++++++++++++-----------
newt/repo/repo.go | 7 ++++++-
2 files changed, 35 insertions(+), 12 deletions(-)
diff --git a/newt/downloader/downloader.go b/newt/downloader/downloader.go
index c3a9bc53..bf88e884 100644
--- a/newt/downloader/downloader.go
+++ b/newt/downloader/downloader.go
@@ -110,6 +110,12 @@ type Downloader interface {
// Returns the branch that contains the YAML control files; this option
// allows implementers to override "master" as the main branch.
MainBranch() string
+
+ // Returns formatted string with repo details
+ String() string
+
+ // Returns if repository was already fetched
+ IsFetched() bool
}
type Commit struct {
@@ -814,6 +820,10 @@ func (gd *GenericDownloader) LatestRc(path string,
return bestStr, nil
}
+func (gd *GenericDownloader) IsFetched() bool {
+ return gd.fetched
+}
+
func (gd *GithubDownloader) Fetch(repoDir string) error {
return gd.cachedFetch(func() error {
util.StatusMessage(util.VERBOSITY_VERBOSE, "Fetching repo %s\n",
@@ -921,11 +931,7 @@ func (gd *GithubDownloader) setRemoteAuth(path string)
error {
func (gd *GithubDownloader) Clone(commit string, dstPath string) error {
branch := gd.MainBranch()
- url, publicUrl := gd.remoteUrls()
-
- util.StatusMessage(util.VERBOSITY_DEFAULT,
- "Downloading repository %s (commit: %s) from %s\n",
- gd.Repo, commit, publicUrl)
+ url, _ := gd.remoteUrls()
gp, err := gitPath()
if err != nil {
@@ -960,6 +966,8 @@ func (gd *GithubDownloader) Clone(commit string, dstPath
string) error {
return err
}
+ gd.fetched = true
+
return nil
}
@@ -987,6 +995,12 @@ func (gd *GithubDownloader) MainBranch() string {
}
}
+func (gd *GithubDownloader) String() string {
+ _, publicUrl := gd.remoteUrls()
+
+ return publicUrl
+}
+
func NewGithubDownloader() *GithubDownloader {
return &GithubDownloader{}
}
@@ -1024,9 +1038,6 @@ func (gd *GitDownloader) FetchFile(
func (gd *GitDownloader) Clone(commit string, dstPath string) error {
branch := gd.MainBranch()
- util.StatusMessage(util.VERBOSITY_DEFAULT,
- "Downloading repository %s (commit: %s)\n", gd.Url, commit)
-
gp, err := gitPath()
if err != nil {
return err
@@ -1059,6 +1070,8 @@ func (gd *GitDownloader) Clone(commit string, dstPath
string) error {
return err
}
+ gd.fetched = true
+
return nil
}
@@ -1084,6 +1097,10 @@ func (gd *GitDownloader) MainBranch() string {
}
}
+func (gd *GitDownloader) String() string {
+ return gd.Url
+}
+
func NewGitDownloader() *GitDownloader {
return &GitDownloader{}
}
@@ -1118,9 +1135,6 @@ func (ld *LocalDownloader) Checkout(path string, commit
string) error {
}
func (ld *LocalDownloader) Clone(commit string, dstPath string) error {
- util.StatusMessage(util.VERBOSITY_DEFAULT,
- "Downloading local repository %s\n", ld.Path)
-
if err := util.CopyDir(ld.Path, dstPath); err != nil {
return err
}
@@ -1140,6 +1154,10 @@ func (gd *LocalDownloader) MainBranch() string {
return "master"
}
+func (ld *LocalDownloader) String() string {
+ return ld.Path
+}
+
func NewLocalDownloader() *LocalDownloader {
return &LocalDownloader{}
}
diff --git a/newt/repo/repo.go b/newt/repo/repo.go
index 8193e0ba..070cc452 100644
--- a/newt/repo/repo.go
+++ b/newt/repo/repo.go
@@ -260,6 +260,9 @@ func (r *Repo) downloadRepo(commit string) error {
}
defer os.RemoveAll(tmpdir)
+ util.StatusMessage(util.VERBOSITY_DEFAULT,
+ "Cloning %s (%s)\n", r.Name(), dl.String())
+
// Download the git repo, returns the git repo, checked out to that
commit
if err := dl.Clone(commit, tmpdir); err != nil {
return util.FmtNewtError("Error downloading repository %s: %s",
@@ -382,7 +385,9 @@ func (r *Repo) UpdateDesc() (bool, error) {
return false, nil
}
- util.StatusMessage(util.VERBOSITY_DEFAULT, "Fetching %s\n", r.Name())
+ if !r.downloader.IsFetched() {
+ util.StatusMessage(util.VERBOSITY_DEFAULT, "Fetching %s\n",
r.Name())
+ }
// Make sure the repo's "origin" remote points to the correct URL.
This is
// necessary in case the user changed his `project.yml` file to point
to a