Skip to content

Commit 7de031e

Browse files
committed
fix: Allow detection of experiments in config early in init, but re-parse the root module after it might have been impacted by use of the -from-module flag (parsing may yield something different the second time!). Diagnostics still need to be passed though.
1 parent bc4fdc8 commit 7de031e

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

internal/command/init_run.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,13 @@ func (c *InitCommand) run(initArgs *arguments.Init, view views.Init, rootModEarl
130130
return 0
131131
}
132132

133-
// If the passed root module is nil, attempt to parse it.
134-
// At this point we load just the root module to begin backend and module initialization
133+
// We parse the root module here because it may have been affected by use of init's -from-module flag.
134+
// However we need to use diagnostics passed in from calling code due to detection of experiments in the config.
135+
// See calling code for more context.
135136
//
136-
// TODO(SarahFrench/radeksimko): Once PSS's experiment is over, remove use of arguments and
137-
// restore parsing of config to always happen here in this code instead of calling code.
138-
if rootModEarly == nil {
139-
rootModEarly, earlyConfDiags = c.loadSingleModuleWithTests(path, initArgs.TestsDirectory)
140-
}
137+
// TODO(SarahFrench/radeksimko): Once PSS's experiment is over, remove use of earlyConfDiags argument and
138+
// restore parsing of config to only happen here in this code instead of calling code.
139+
rootModEarly, _ = c.loadSingleModuleWithTests(path, initArgs.TestsDirectory)
141140

142141
// There may be parsing errors in config loading but these will be shown later _after_
143142
// checking for core version requirement errors. Not meeting the version requirement should

internal/command/init_run_experiment.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,13 @@ func (c *InitCommand) runPssInit(initArgs *arguments.Init, view views.Init, root
138138
return 0
139139
}
140140

141-
// If the passed root module is nil, attempt to parse it.
142-
// At this point we load just the root module to begin backend and module initialization
141+
// We parse the root module here because it may have been affected by use of init's -from-module flag.
142+
// However we need to use diagnostics passed in from calling code due to detection of experiments in the config.
143+
// See calling code for more context.
143144
//
144-
// TODO(SarahFrench/radeksimko): Once PSS's experiment is over, remove use of arguments and
145-
// restore parsing of config to always happen here in this code instead of calling code.
146-
if rootModEarly == nil {
147-
rootModEarly, earlyConfDiags = c.loadSingleModuleWithTests(path, initArgs.TestsDirectory)
148-
}
145+
// TODO(SarahFrench/radeksimko): Once PSS's experiment is over, remove use of earlyConfDiags argument and
146+
// restore parsing of config to only happen here in this code instead of calling code.
147+
rootModEarly, _ = c.loadSingleModuleWithTests(path, initArgs.TestsDirectory)
149148

150149
// There may be parsing errors in config loading but these will be shown later _after_
151150
// checking for core version requirement errors. Not meeting the version requirement should

0 commit comments

Comments
 (0)