Skip to content

newt: Print external repos with info command #594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 6 additions & 4 deletions newt/cli/project_cmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
)

var infoRemote bool
var infoExternal bool

func newRunCmd(cmd *cobra.Command, args []string) {
if len(args) < 1 {
Expand Down Expand Up @@ -148,11 +149,9 @@ func infoRunCmd(cmd *cobra.Command, args []string) {

// If no arguments specified, print status of all installed repos.
if len(args) == 0 {
pred := func(r *repo.Repo) bool { return true }
if err := proj.InfoIf(pred, infoRemote); err != nil {
if err := proj.Info(infoRemote, infoExternal); err != nil {
NewtUsage(nil, err)
}

return
}

Expand Down Expand Up @@ -243,7 +242,10 @@ func AddProjectCommands(cmd *cobra.Command) {
}
infoCmd.PersistentFlags().BoolVarP(&infoRemote,
"remote", "r", false,
"Fetch latest repos to determine if upgrades are required")
"Fetch latest repos to determine if upgrades are required. Works only on internal repositories.")
infoCmd.PersistentFlags().BoolVarP(&infoExternal,
"external", "e", false,
"Include external repositories.")

cmd.AddCommand(infoCmd)
}
1 change: 0 additions & 1 deletion newt/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,6 @@ func (inst *Installer) Info(repos []*repo.Repo, remote bool) error {
vmp = &vm
}

util.StatusMessage(util.VERBOSITY_DEFAULT, "Repository info:\n")
for _, r := range repos {
if r.IsLocal() {
inst.localRepoInfo(r)
Expand Down
32 changes: 27 additions & 5 deletions newt/project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,7 @@ func (proj *Project) UpgradeIf(
return inst.Upgrade(specifiedRepoList, force, ask)
}

func (proj *Project) InfoIf(predicate func(r *repo.Repo) bool,
remote bool) error {

func (proj *Project) Info(remote bool, external bool) error {
if remote {
// Make sure we have an up to date copy of all `repository.yml` files.
if err := proj.downloadRepositoryYmlFiles(); err != nil {
Expand All @@ -422,15 +420,39 @@ func (proj *Project) InfoIf(predicate func(r *repo.Repo) bool,
}

// Determine which repos the user wants info about.
repoList := proj.SelectRepos(predicate)
predicate := func(r *repo.Repo) bool { return true }
internalRepos := proj.SelectRepos(predicate)

if !remote && external {
proj.GetPkgRepos()
}

predicate = func(r *repo.Repo) bool {
for _, intRepo := range internalRepos {
if intRepo.Name() == r.Name() {
return false
}
}
return true
}
// This should be empty slice if remote is true
externalRepos := proj.SelectRepos(predicate)

// Ignore errors. We will deal with bad repos individually when we display
// info about them.
inst, _ := install.NewInstaller(proj.repos, proj.rootRepoReqs)
if err := inst.Info(repoList, remote); err != nil {
util.StatusMessage(util.VERBOSITY_DEFAULT, "Internal repository info:\n")
if err := inst.Info(internalRepos, remote); err != nil {
return err
}

if !remote && external {
util.StatusMessage(util.VERBOSITY_DEFAULT, "External repository info:\n")
if err := inst.Info(externalRepos, remote); err != nil {
return err
}
}

return nil
}

Expand Down
Loading