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

Commit

Permalink
runProjectStatus: add PUB VERSIONS
Browse files Browse the repository at this point in the history
  • Loading branch information
darkowlzz committed Nov 12, 2017
1 parent e2f7895 commit fd36ee2
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion cmd/dep/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ type projectStatus struct {
Constraints []string
Source string
AltSource string
PubVersions []string
PubVersions map[string][]string
Revision string
LatestAllowed string
SourceType string
Expand Down Expand Up @@ -711,23 +711,29 @@ func runProjectStatus(ctx *dep.Ctx, args []string, p *dep.Project, sm gps.Source
// Get the currently selected version from from lock.
for _, pl := range p.Lock.Projects() {
if pr == pl.Ident().ProjectRoot {
// VERSION
projStatus.Version = pl.Version().String()
// SOURCE
projStatus.Source = projStatus.Project
// ALT SOURCE
projStatus.AltSource = pl.Ident().Source

rev, _, _ := gps.VersionComponentStrings(pl.Version())
// REVISION
projStatus.Revision = rev

vcsType, err := sm.GetVcsType(pl.Ident())
if err != nil {
return err
}
// SOURCE TYPE
projStatus.SourceType = vcsType

existsUpstream, err := sm.ExistsUpstream(pl.Ident())
if err != nil {
return err
}
// UPSTREAM EXISTS
projStatus.UpstreamExists = existsUpstream

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

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

// PACKAGES
for pkgPath := range pkgtree.Packages {
projStatus.Packages = append(projStatus.Packages, pkgPath)
}

// PUB VERSION
var semvers, branches, nonsemvers []string
for _, pv := range pvs {
switch pv.Type() {
case gps.IsSemver:
semvers = append(semvers, pv.Unpair().String())
case gps.IsBranch:
branches = append(branches, pv.Unpair().String())
default:
nonsemvers = append(nonsemvers, pv.Unpair().String())
}
}
projStatus.PubVersions = make(map[string][]string)
projStatus.PubVersions["semver"] = semvers
projStatus.PubVersions["branches"] = branches
projStatus.PubVersions["nonsemvers"] = nonsemvers
}
}

Expand Down

0 comments on commit fd36ee2

Please sign in to comment.