-
Notifications
You must be signed in to change notification settings - Fork 1k
status: add project status #1367
Conversation
63a5275 to
ec0cb8a
Compare
2b6a198 to
fd36ee2
Compare
internal/gps/source_manager.go
Outdated
| GetManifestAndLock(ProjectIdentifier, Version, ProjectAnalyzer) (Manifest, Lock, error) | ||
|
|
||
| // GetVcsType returns VCS Type for the provided ProjectIdentifier. | ||
| GetVcsType(ProjectIdentifier) (string, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/Vcs/Source/
also, let's create the following to capture this, rather than using strings:
type SourceType uint8
const (
InvalidSource = iota // zero value is invalid; there is no "default" type
VcsGit
VcsHg
VcsBzr
VcsSvn
)
func (st SourceType) String() string {
switch st {
case VcsGit:
return "git"
case VcsHg:
return "hg"
case VcsBzr:
return "bzr"
case VcsSvn:
return "svn"
default:
return fmt.Sprintf("%v does not represent a known source type, this probably indicates a bug", st)
}
}we'll then also want to update the source.sourceType() method to return this uint instead of a string.
internal/gps/source.go
Outdated
| return m, l, nil | ||
| } | ||
|
|
||
| func (sg *sourceGateway) getVcsType() string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/Vcs/Source/
also should return the SourceType type described in the other comment.
cmd/dep/status.go
Outdated
| SourceType string | ||
| Packages []string | ||
| ProjectImporters map[string]string | ||
| PackageImporters map[string]string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've got project & package importers here, but not project and package imports?
ProjectImports will be able to be a []string, but PackageImports will need to be a map[string][]string. You'll want to use pkgtree.ListPackages(), TrimHiddenPackages() and then ToReachMap() to assemble the PackageImports information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'd also be fine with leaving this to a follow-up PR - it's more important that we get something basically functional then ship additional bits of data later on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was working on adding ProjectImports, which I realized could be obtained from collectConstraints(), so I made the necessary changes in #962 . But yeah, we can add it as a follow-up PR.
| Revision string | ||
| LatestAllowed string | ||
| SourceType string | ||
| Packages []string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment about ProjectImports and PackageImports made me realize that it would also be worth listing the ignores that are currently affecting this project - both what packages within it are ignored (that would otherwise actually be imported), and which of its imports are ignored.
This has the potential to be a little tricky, as if there's a hash mismatch (or if the user manually messed with Gopkg.lock), then it's possible that there may be some packages listed in Gopkg.lock that actually should be ignored. There's also a fair bit of work involved in actually pulling out the ignoreds, so i think it'll be fine for us to defer this to a later PR.
i've updated the spec with new lines and some comments explaining this, so we can discuss/dissect there; just noting it here.
|
|
||
| // Get the currently selected version from from lock. | ||
| for _, pl := range p.Lock.Projects() { | ||
| if pr == pl.Ident().ProjectRoot { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
best practice here would be to minimize the indent level:
if pr != pl.Ident().ProjectRoot {
continue
}then we can deindent the rest of the block, and the reader can immediately recognize that we're effectively just searching the slice for that single item.
cmd/dep/status.go
Outdated
| } | ||
| } | ||
|
|
||
| fmt.Println(projStatus) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print through the ctx.Out logger
cmd/dep/status.go
Outdated
|
|
||
| // Update local copy of the source and then fetch all the versions. | ||
| sm.SyncSourceFor(pl.Ident()) | ||
| pvs, err := sm.ListVersions(pl.Ident()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the current implementation, ListVersions() is already guaranteed to always return the latest set of versions, so the SyncSourceFor() call is unnecessary.
that may change when the caching work goes in, but we don't need to code defensively against that eventuality - we'll cross that bridge when we come to it.
cmd/dep/status.go
Outdated
|
|
||
| rev, _, _ := gps.VersionComponentStrings(pl.Version()) | ||
| // REVISION | ||
| projStatus.Revision = rev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for the intermediate rev var, just assign directly to projStatus.Revision
07a02c2 to
6157038
Compare
|
Almost there. Figured out how to gather PACKAGE IMPORTS & PROJECT IMPORTS (hopefully correct 😅). LATEST ALLOWED is the only thing left. |
e0098dc to
4e31fe6
Compare
|
Made some optimizations like advanced collection of package reachmaps and package list, and single gps solve for all the projects' updates, to bring down the running time. Now, status of a single project or multiple projects take almost the same time (tried with 1 to 4 projects on dep itself, ~36s). It can be made concurrent to bring that down. Follow-up PR. Sample output: PROJECT IMPORTERS and PACKAGE IMPORTERS are empty in this case because we don't have any dependency that uses semver project. An example for this for CONSTRAINTS is empty for now because it depends on NEXT: Presentation improvements. |
ba7a019 to
a6ca4a8
Compare
|
Improved the output using tabwriter and added an integration test. I'll add the json output in a follow-up PR, avoiding huge change-set. Example output: Leaving |
de981c2 to
ae10ff2
Compare
f760ff8 to
7de341c
Compare
|
Rebased and updated project status to print project constraints in proper table output. |
cmd/dep/status.go
Outdated
| for _, pc := range pcs { | ||
| constList = append(constList, pc.String()) | ||
| } | ||
| sort.Strings(constList) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sorting would be simplified and improved with projectConstraint sort by Project implemented in #1413 .
fea4256 to
8d5d393
Compare
8d5d393 to
99aeaae
Compare
UPSTREAM VERSION EXISTS, PACKAGES, PUB VERSIONS, CONSTRAINTS
Perform solve at the end for all the target projects together and get the latest allowed revision for them.
99aeaae to
4b8290e
Compare
|
Dep was officially deprecated earlier this year, and the proposal to archive this repository was accepted. As such, I'm closing outstanding issues before archiving the repository. For any further comments, please use the proposal thread on the Go issue tracker. Thanks! |
What does this do / why do we need it?
Adds
statusfor project arguments.dep status github.com/foo/barWhat should your reviewer look out for in this PR?
The printed output formatting and logic of fetching all the project details.
Do you need help or clarification on anything?
Need to figure out ways to fetch some attributes like SOURCE TYPE, UPSTREAM EXISTS, UPSTREAM VERSION EXISTS using gps.