这是indexloc提供的服务,不要输入任何密码
Skip to content

Options cleanup #1295

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

Merged
merged 10 commits into from
May 31, 2022
Merged

Options cleanup #1295

merged 10 commits into from
May 31, 2022

Conversation

gsoltis
Copy link
Contributor

@gsoltis gsoltis commented May 26, 2022

Cleans up our RunOptions in advance of porting over to cobra. Attempts to have the zero value be the default in as many cases as possible, which means that some booleans needed to be flipped to be expressed internally as default: false. The external-facing arguments are unchanged.

Going commit-by-commit is probably the best way to go through this one.

There's definitely some refactoring still to be done around run and runOpts, but this felt like a big enough change to stand on its own.

@vercel
Copy link

vercel bot commented May 26, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
turbo-site ✅ Ready (Inspect) Visit Preview 💬 Add your feedback May 31, 2022 at 4:36PM (UTC)

@gsoltis gsoltis marked this pull request as ready for review May 26, 2022 23:29
@nathanhammond nathanhammond added the pr: fixship A PR which is approved with notes and does not require re-review. label May 31, 2022
Copy link
Contributor

@nathanhammond nathanhammond left a comment

Choose a reason for hiding this comment

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

🛠🚢, nice rescoping of options!

Since: tc.since,
IgnorePatterns: []string{tc.ignore},
GlobalDepPatterns: tc.globalDeps,
IncludeDependencies: tc.includeDependencies,
IncludeDependents: tc.includeDependents,
}, scm, &context.Context{
}, "dummy-repo-root", scm, &context.Context{
Copy link
Contributor

Choose a reason for hiding this comment

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

Change request: can you make this look more like a path? I had to go check what was going on.

ResolvePackages is well-suited for fs.AbsolutePath with only a definition, invocation, and tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to filepath.FromSlash("/dummy/repo/root").

Currently, the path passed in to ResolvePackages is used by a bunch of the filter code, so while I agree it needs to eventually be an AbsolutePath, it's a non-trivial change.

@@ -197,7 +197,7 @@ func (c *RunCommand) Run(args []string) int {
return 1
}
}
filteredPkgs, isAllPackages, err := scope.ResolvePackages(runOptions.scopeOpts(), scmInstance, ctx, c.Ui, c.Config.Logger)
filteredPkgs, isAllPackages, err := scope.ResolvePackages(&runOptions.scopeOpts, c.Config.Cwd.ToStringDuringMigration(), scmInstance, ctx, c.Ui, c.Config.Logger)
Copy link
Contributor

Choose a reason for hiding this comment

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

That this is called cwd throws me for a loop. I want to split "directory in which the command was invoked" from "directory which is being treated as the execution root" and cwd is woefully incomplete at expressing that.

Shouldn't be handled in this PR, but as you're thinking about things, this is something to keep in mind.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. I think a rename of the config field is in order at some point.

FilterPatterns []string
// IncludeDependents is whether to include dependent impacted consumers in execution (defaults to true)
IncludeDependents bool
// Entrypoints is a list of package entrypoints
Copy link
Contributor

Choose a reason for hiding this comment

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

DAG entrypoints, soon enough. (not a change request)

@@ -476,7 +474,7 @@ func parseRunArgs(args []string, config *config.Config, output cli.Ui) (*RunOpti
runOptions.profile = fmt.Sprintf("%v-profile.json", time.Now().UnixNano())

case strings.HasPrefix(arg, "--no-deps"):
runOptions.scopeOpts.IncludeDependents = false
runOptions.scopeOpts.SkipDependents = true
Copy link
Contributor

Choose a reason for hiding this comment

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

It even matches our command line flag better! 👍

@@ -79,7 +85,9 @@ func ResolvePackages(opts *Opts, cwd string, scm scm.SCM, ctx *context.Context,
Cwd: cwd,
PackagesChangedSince: opts.getPackageChangeFunc(scm, cwd, ctx.PackageInfos),
}
filterPatterns := opts.asFilterPatterns()
filterPatterns := opts.FilterPatterns
legacyFilterPatterns := opts.LegacyFilter.asFilterPatterns()
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice to tuck these away for easier future removal.

@@ -225,7 +225,7 @@ func (c *RunCommand) Run(args []string) int {
rs := &runSpec{
Targets: targets,
FilteredPkgs: filteredPkgs,
Opts: runOptions,
Opts: opts,
Copy link
Contributor

Choose a reason for hiding this comment

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

Our option boundaries between c (RunCommand) and rs (RunSpec) here are a little weird to me. Just noting, not a request for change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

RunCommand is not long for this world. The next PR in this series turns it into a wrapper around a cobra command.

profile: "", // empty string does no tracing
only: false,

func getDefaultOptions(config *config.Config) *Opts {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a nice incremental step.

@gsoltis gsoltis added pr: automerge Kodiak will merge these automatically after checks pass and removed pr: fixship A PR which is approved with notes and does not require re-review. labels May 31, 2022
@gsoltis gsoltis merged commit b100bf6 into main May 31, 2022
@gsoltis gsoltis deleted the gsoltis/run_opts branch May 31, 2022 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: automerge Kodiak will merge these automatically after checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants