Skip to content
Closed
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
2 changes: 1 addition & 1 deletion docs/user/reference/cli/azldev_component_build.md

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

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

8 changes: 4 additions & 4 deletions internal/app/azldev/cmds/component/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type ComponentBuildOptions struct {

ContinueOnError bool
NoCheck bool
WithGitRepo bool
WithoutGitRepo bool
SourcePackageOnly bool
BuildEnvPolicy BuildEnvPreservePolicy

Expand Down Expand Up @@ -131,8 +131,8 @@ builds can consume.`,
cmd.Flags().BoolVarP(&options.ContinueOnError, "continue-on-error", "k", false,
"Continue building when some components fail")
cmd.Flags().BoolVar(&options.NoCheck, "no-check", false, "Skip package %check tests")
cmd.Flags().BoolVar(&options.WithGitRepo, "with-git", false,
"Create a dist-git repository with synthetic commit history (requires a project git repository)")
cmd.Flags().BoolVar(&options.WithoutGitRepo, "without-git", false,
"Skip creating a dist-git repository with synthetic commit history")
Comment on lines +134 to +135
cmd.Flags().BoolVar(&options.SourcePackageOnly, "srpm-only", false, "Build SRPM (source RPM) *only*")
cmd.Flags().Var(&options.BuildEnvPolicy, "preserve-buildenv",
fmt.Sprintf("Preserve build environment {%s, %s, %s}",
Expand Down Expand Up @@ -252,7 +252,7 @@ func BuildComponent(
}, &err)

var preparerOpts []sources.PreparerOption
if options.WithGitRepo {
if !options.WithoutGitRepo {
preparerOpts = append(preparerOpts, sources.WithGitRepo(env, env.LockReader()))
}

Expand Down
9 changes: 9 additions & 0 deletions internal/app/azldev/cmds/component/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ func TestNewBuildCommand(t *testing.T) {
assert.Equal(t, "build", cmd.Use)
assert.NotNil(t, cmd.RunE)
}

withoutGitFlag := cmd.Flags().Lookup("without-git")
require.NotNil(t, withoutGitFlag, "--without-git flag should be registered")
assert.Equal(t, "false", withoutGitFlag.DefValue, "dist-git flow should be enabled by default")
assert.Contains(t, withoutGitFlag.Usage, "dist-git")

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

func TestNewBuildCommand_MockConfigOptFlag(t *testing.T) {
Expand Down
20 changes: 10 additions & 10 deletions internal/app/azldev/cmds/component/preparesources.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import (
type PrepareSourcesOptions struct {
ComponentFilter components.ComponentFilter

OutputDir string
SkipOverlays bool
WithGitRepo bool
Force bool
AllowNoHashes bool
OutputDir string
SkipOverlays bool
WithoutGitRepo bool
Force bool
AllowNoHashes bool
}

func prepareOnAppInit(_ *azldev.App, sourceCmd *cobra.Command) {
Expand Down Expand Up @@ -68,8 +68,8 @@ Only one component may be selected at a time.`,
_ = cmd.MarkFlagDirname("output-dir")

cmd.Flags().BoolVar(&options.SkipOverlays, "skip-overlays", false, "skip applying overlays to prepared sources")
cmd.Flags().BoolVar(&options.WithGitRepo, "with-git", false,
"Create a dist-git repository with synthetic commit history (requires a project git repository)")
cmd.Flags().BoolVar(&options.WithoutGitRepo, "without-git", false,
"Skip creating a dist-git repository with synthetic commit history")
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")
Expand Down Expand Up @@ -121,13 +121,13 @@ func PrepareComponentSources(env *azldev.Env, options *PrepareSourcesOptions) er
return err
}

if options.SkipOverlays && options.WithGitRepo {
slog.Warn("--with-git has no effect when --skip-overlays is set; " +
if options.SkipOverlays && !options.WithoutGitRepo {
slog.Warn("dist-git flow has no effect when '--skip-overlays' is set; " +
"synthetic history requires overlays to be applied")
Comment on lines +125 to 126
}

var preparerOpts []sources.PreparerOption
if options.WithGitRepo {
if !options.WithoutGitRepo {
preparerOpts = append(preparerOpts, sources.WithGitRepo(env, env.LockReader()))
}

Expand Down
9 changes: 9 additions & 0 deletions internal/app/azldev/cmds/component/preparesources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ func TestNewPrepareSourcesCmd(t *testing.T) {
require.NotNil(t, allowNoHashesFlag, "--allow-no-hashes flag should be registered")
assert.Equal(t, "false", allowNoHashesFlag.DefValue)
assert.Contains(t, allowNoHashesFlag.Usage, "compute missing hashes")

withoutGitFlag := cmd.Flags().Lookup("without-git")
require.NotNil(t, withoutGitFlag, "--without-git flag should be registered")
assert.Equal(t, "false", withoutGitFlag.DefValue, "dist-git flow should be enabled by default")
assert.Contains(t, withoutGitFlag.Usage, "dist-git")

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

func TestPrepareSourcesCmd_NoMatch(t *testing.T) {
Expand Down
Loading