Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 29 additions & 11 deletions newt/downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -960,6 +966,8 @@ func (gd *GithubDownloader) Clone(commit string, dstPath string) error {
return err
}

gd.fetched = true

return nil
}

Expand Down Expand Up @@ -987,6 +995,12 @@ func (gd *GithubDownloader) MainBranch() string {
}
}

func (gd *GithubDownloader) String() string {
_, publicUrl := gd.remoteUrls()

return publicUrl
}

func NewGithubDownloader() *GithubDownloader {
return &GithubDownloader{}
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1059,6 +1070,8 @@ func (gd *GitDownloader) Clone(commit string, dstPath string) error {
return err
}

gd.fetched = true

return nil
}

Expand All @@ -1084,6 +1097,10 @@ func (gd *GitDownloader) MainBranch() string {
}
}

func (gd *GitDownloader) String() string {
return gd.Url
}

func NewGitDownloader() *GitDownloader {
return &GitDownloader{}
}
Expand Down Expand Up @@ -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
}
Expand All @@ -1140,6 +1154,10 @@ func (gd *LocalDownloader) MainBranch() string {
return "master"
}

func (ld *LocalDownloader) String() string {
return ld.Path
}

func NewLocalDownloader() *LocalDownloader {
return &LocalDownloader{}
}
Expand Down
7 changes: 6 additions & 1 deletion newt/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down
Loading