diff --git a/newt/downloader/downloader.go b/newt/downloader/downloader.go index c3a9bc530..bf88e884d 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 8193e0baf..070cc452e 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