Skip to content

Commit fee7e3f

Browse files
committed
newt: Print external repos with info command
Now all repositories versions are printed on default. * prefix means internal repository @ means external one
1 parent 16449ee commit fee7e3f

File tree

3 files changed

+34
-10
lines changed

3 files changed

+34
-10
lines changed

newt/cli/project_cmds.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,13 @@ func infoRunCmd(cmd *cobra.Command, args []string) {
148148

149149
// If no arguments specified, print status of all installed repos.
150150
if len(args) == 0 {
151-
pred := func(r *repo.Repo) bool { return true }
152-
if err := proj.InfoIf(pred, infoRemote); err != nil {
153-
NewtUsage(nil, err)
151+
if !infoRemote {
152+
proj.GetPkgRepos()
154153
}
155154

155+
if err := proj.Info(infoRemote); err != nil {
156+
NewtUsage(nil, err)
157+
}
156158
return
157159
}
158160

@@ -243,7 +245,7 @@ func AddProjectCommands(cmd *cobra.Command) {
243245
}
244246
infoCmd.PersistentFlags().BoolVarP(&infoRemote,
245247
"remote", "r", false,
246-
"Fetch latest repos to determine if upgrades are required")
248+
"Fetch latest repos to determine if upgrades are required. Works only on internal repositories.")
247249

248250
cmd.AddCommand(infoCmd)
249251
}

newt/install/install.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -694,8 +694,17 @@ func (inst *Installer) Info(repos []*repo.Repo, remote bool) error {
694694
// remoteRepoInfo prints information about the specified repo. If `vm` is
695695
// non-nil, the output indicates whether a remote update is available.
696696
func (inst *Installer) remoteRepoInfo(r *repo.Repo, vm *deprepo.VersionMap) {
697+
var prefix_char string
698+
697699
ri := inst.gatherInfo(r, vm)
698-
s := fmt.Sprintf(" * %s:", r.Name())
700+
701+
if r.IsExternal(r.Path()) {
702+
prefix_char = "@"
703+
} else {
704+
prefix_char = "*"
705+
}
706+
707+
s := fmt.Sprintf(" %s %s:", prefix_char, r.Name())
699708

700709
s += fmt.Sprintf(" %s", ri.commitHash)
701710
if ri.installedVer == nil {
@@ -720,12 +729,20 @@ func (inst *Installer) remoteRepoInfo(r *repo.Repo, vm *deprepo.VersionMap) {
720729
// project itself). It does nothing if the project is not a git repo.
721730
func (inst *Installer) localRepoInfo(r *repo.Repo) {
722731
ri := inst.gatherInfo(r, nil)
732+
var prefix_char string
733+
723734
if ri.commitHash == "" {
724735
// The project is not a git repo.
725736
return
726737
}
727738

728-
s := fmt.Sprintf(" * %s (project):", r.Name())
739+
if r.IsExternal(r.Path()) {
740+
prefix_char = "@"
741+
} else {
742+
prefix_char = "*"
743+
}
744+
745+
s := fmt.Sprintf(" %s %s:", prefix_char, r.Name())
729746

730747
s += fmt.Sprintf(" %s", ri.commitHash)
731748
if ri.dirtyState != "" {

newt/project/project.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,7 @@ func (proj *Project) UpgradeIf(
411411
return inst.Upgrade(specifiedRepoList, force, ask)
412412
}
413413

414-
func (proj *Project) InfoIf(predicate func(r *repo.Repo) bool,
415-
remote bool) error {
416-
414+
func (proj *Project) Info(remote bool) error {
417415
if remote {
418416
// Make sure we have an up to date copy of all `repository.yml` files.
419417
if err := proj.downloadRepositoryYmlFiles(); err != nil {
@@ -422,7 +420,14 @@ func (proj *Project) InfoIf(predicate func(r *repo.Repo) bool,
422420
}
423421

424422
// Determine which repos the user wants info about.
425-
repoList := proj.SelectRepos(predicate)
423+
predicate := func(r *repo.Repo) bool { return !r.IsExternal(r.Path()) }
424+
internalRepos := proj.SelectRepos(predicate)
425+
426+
predicate = func(r *repo.Repo) bool { return r.IsExternal(r.Path()) }
427+
// This should be empty slice if remote is true
428+
externalRepos := proj.SelectRepos(predicate)
429+
430+
repoList := append(internalRepos, externalRepos...)
426431

427432
// Ignore errors. We will deal with bad repos individually when we display
428433
// info about them.

0 commit comments

Comments
 (0)