diff --git a/docs/user/reference/cli/azldev_component_build.md b/docs/user/reference/cli/azldev_component_build.md index 8ee2e16b..25390853 100644 --- a/docs/user/reference/cli/azldev_component_build.md +++ b/docs/user/reference/cli/azldev_component_build.md @@ -60,7 +60,7 @@ azldev component build [flags] --skip-lock-validation skip lock file consistency checks (default true) -s, --spec-path stringArray Spec path --srpm-only Build SRPM (source RPM) *only* - --with-git Create a dist-git repository with synthetic commit history (requires a project git repository) + --without-git Skip creating a dist-git repository with synthetic commit history ``` ### Options inherited from parent commands diff --git a/docs/user/reference/cli/azldev_component_prepare-sources.md b/docs/user/reference/cli/azldev_component_prepare-sources.md index 64cfa48d..075da7e1 100644 --- a/docs/user/reference/cli/azldev_component_prepare-sources.md +++ b/docs/user/reference/cli/azldev_component_prepare-sources.md @@ -42,7 +42,7 @@ azldev component prepare-sources [flags] --skip-lock-validation skip lock file consistency checks (default true) --skip-overlays skip applying overlays to prepared sources -s, --spec-path stringArray Spec path - --with-git Create a dist-git repository with synthetic commit history (requires a project git repository) + --without-git Skip creating a dist-git repository with synthetic commit history ``` ### Options inherited from parent commands diff --git a/internal/app/azldev/cmds/component/build.go b/internal/app/azldev/cmds/component/build.go index b88676ea..195821bb 100644 --- a/internal/app/azldev/cmds/component/build.go +++ b/internal/app/azldev/cmds/component/build.go @@ -29,7 +29,7 @@ type ComponentBuildOptions struct { ContinueOnError bool NoCheck bool - WithGitRepo bool + WithoutGitRepo bool SourcePackageOnly bool BuildEnvPolicy BuildEnvPreservePolicy @@ -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") 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}", @@ -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())) } diff --git a/internal/app/azldev/cmds/component/build_test.go b/internal/app/azldev/cmds/component/build_test.go index 11eb9299..48e4cf95 100644 --- a/internal/app/azldev/cmds/component/build_test.go +++ b/internal/app/azldev/cmds/component/build_test.go @@ -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) { diff --git a/internal/app/azldev/cmds/component/preparesources.go b/internal/app/azldev/cmds/component/preparesources.go index 0506ac41..32b1e971 100644 --- a/internal/app/azldev/cmds/component/preparesources.go +++ b/internal/app/azldev/cmds/component/preparesources.go @@ -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) { @@ -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") @@ -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") } var preparerOpts []sources.PreparerOption - if options.WithGitRepo { + if !options.WithoutGitRepo { preparerOpts = append(preparerOpts, sources.WithGitRepo(env, env.LockReader())) } diff --git a/internal/app/azldev/cmds/component/preparesources_test.go b/internal/app/azldev/cmds/component/preparesources_test.go index dc046c3e..720b0941 100644 --- a/internal/app/azldev/cmds/component/preparesources_test.go +++ b/internal/app/azldev/cmds/component/preparesources_test.go @@ -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) {