Skip to content

newt: If no dependencies are present, still try to build #595

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
6 changes: 5 additions & 1 deletion newt/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,11 @@ func (r *Repo) Name() string {
}

func (r *Repo) Path() string {
return r.localPath
if r != nil {
return r.localPath
} else {
return ""
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will "hide" all issues where Path() is called unintentionally on nil object, so better to actually explicitly handle this on caller side. Of course as long as there is some valid case in which we can actually have nil repo that we should handle properly, not sure when this could happen though tbh.

}

func (r *Repo) IsLocal() bool {
Expand Down
5 changes: 4 additions & 1 deletion newt/sysinit/sysinit.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ func ResolveStageFuncsOrder(sfs []stage.StageFunc) ([]stage.StageFunc, error) {
sort.Slice(nodesQ, func(i int, j int) bool {
a := nodesQ[i]
b := nodesQ[j]

if strings.Compare(a.Name, b.Name) == -1 {
return false
}
Expand All @@ -181,6 +180,10 @@ func ResolveStageFuncsOrder(sfs []stage.StageFunc) ([]stage.StageFunc, error) {
// direct dependencies between each node of stage X to each node of
// stage Y to make sure they can be resolved properly and reordered
// if needed due to other dependencies.
if stages == nil {
util.FmtNewtError("Cannot resolve sysinit order: no stages defined.")
return []stage.StageFunc{}, nil
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can only happen if sfs is empty so you can basically check that at the very beginning of the function. Also no need to emit warning.

sfsPrev := nodesByStage[stages[0]]
stages = stages[1:]
for _, stage := range stages {
Expand Down
Loading