Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Commit fd36ee2

Browse files
committed
runProjectStatus: add PUB VERSIONS
1 parent e2f7895 commit fd36ee2

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

cmd/dep/status.go

+26-1
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ type projectStatus struct {
655655
Constraints []string
656656
Source string
657657
AltSource string
658-
PubVersions []string
658+
PubVersions map[string][]string
659659
Revision string
660660
LatestAllowed string
661661
SourceType string
@@ -711,23 +711,29 @@ func runProjectStatus(ctx *dep.Ctx, args []string, p *dep.Project, sm gps.Source
711711
// Get the currently selected version from from lock.
712712
for _, pl := range p.Lock.Projects() {
713713
if pr == pl.Ident().ProjectRoot {
714+
// VERSION
714715
projStatus.Version = pl.Version().String()
716+
// SOURCE
715717
projStatus.Source = projStatus.Project
718+
// ALT SOURCE
716719
projStatus.AltSource = pl.Ident().Source
717720

718721
rev, _, _ := gps.VersionComponentStrings(pl.Version())
722+
// REVISION
719723
projStatus.Revision = rev
720724

721725
vcsType, err := sm.GetVcsType(pl.Ident())
722726
if err != nil {
723727
return err
724728
}
729+
// SOURCE TYPE
725730
projStatus.SourceType = vcsType
726731

727732
existsUpstream, err := sm.ExistsUpstream(pl.Ident())
728733
if err != nil {
729734
return err
730735
}
736+
// UPSTREAM EXISTS
731737
projStatus.UpstreamExists = existsUpstream
732738

733739
// Update local copy of the source and then fetch all the versions.
@@ -737,6 +743,7 @@ func runProjectStatus(ctx *dep.Ctx, args []string, p *dep.Project, sm gps.Source
737743
return err
738744
}
739745

746+
// UPSTREAM VERSION EXISTS
740747
for _, pv := range pvs {
741748
if pv.Unpair().String() == pl.Version().String() {
742749
projStatus.UpstreamVersionExists = true
@@ -749,9 +756,27 @@ func runProjectStatus(ctx *dep.Ctx, args []string, p *dep.Project, sm gps.Source
749756
return err
750757
}
751758

759+
// PACKAGES
752760
for pkgPath := range pkgtree.Packages {
753761
projStatus.Packages = append(projStatus.Packages, pkgPath)
754762
}
763+
764+
// PUB VERSION
765+
var semvers, branches, nonsemvers []string
766+
for _, pv := range pvs {
767+
switch pv.Type() {
768+
case gps.IsSemver:
769+
semvers = append(semvers, pv.Unpair().String())
770+
case gps.IsBranch:
771+
branches = append(branches, pv.Unpair().String())
772+
default:
773+
nonsemvers = append(nonsemvers, pv.Unpair().String())
774+
}
775+
}
776+
projStatus.PubVersions = make(map[string][]string)
777+
projStatus.PubVersions["semver"] = semvers
778+
projStatus.PubVersions["branches"] = branches
779+
projStatus.PubVersions["nonsemvers"] = nonsemvers
755780
}
756781
}
757782

0 commit comments

Comments
 (0)