Skip to content
Merged
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions internal/app/azldev/cmds/component/preparesources.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type PrepareSourcesOptions struct {
WithoutGitRepo bool
Force bool
AllowNoHashes bool
SkipSources bool
}

func prepareOnAppInit(_ *azldev.App, sourceCmd *cobra.Command) {
Expand Down Expand Up @@ -73,6 +74,9 @@ Only one component may be selected at a time.`,
cmd.Flags().BoolVar(&options.Force, "force", false, "delete and recreate the output directory if it already exists")
cmd.Flags().BoolVar(&options.AllowNoHashes, "allow-no-hashes", false,
"compute missing hashes by downloading source files from their origin")
cmd.Flags().BoolVar(&options.SkipSources, "skip-sources", false,
"skip downloading fetched sources when preparing the package (useful to extract "+
"dist-git metadata when source files are not needed)")
Comment thread
dmcilvaney marked this conversation as resolved.
Comment thread
dmcilvaney marked this conversation as resolved.

return cmd
}
Expand Down Expand Up @@ -138,6 +142,10 @@ func PrepareComponentSources(env *azldev.Env, options *PrepareSourcesOptions) er
preparerOpts = append(preparerOpts, sources.WithAllowNoHashes())
}

if options.SkipSources {
preparerOpts = append(preparerOpts, sources.WithSkipLookaside())
}

preparer, err := sources.NewPreparer(sourceManager, env.FS(), env, env, preparerOpts...)
if err != nil {
return fmt.Errorf("failed to create source preparer:\n%w", err)
Expand Down
5 changes: 5 additions & 0 deletions internal/app/azldev/cmds/component/preparesources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ func TestNewPrepareSourcesCmd(t *testing.T) {
assert.Equal(t, "false", withoutGitFlag.DefValue, "dist-git flow should be enabled by default")
assert.Contains(t, withoutGitFlag.Usage, "dist-git")

skipSourcesFlag := cmd.Flags().Lookup("skip-sources")
require.NotNil(t, skipSourcesFlag, "--skip-sources flag should be registered")
assert.Equal(t, "false", skipSourcesFlag.DefValue)
assert.Contains(t, skipSourcesFlag.Usage, "skip downloading")

// Legacy --with-git flag must NOT exist.
withGitFlag := cmd.Flags().Lookup("with-git")
assert.Nil(t, withGitFlag, "--with-git flag must not be registered")
Expand Down
Loading