diff --git a/ct/cmd/root.go b/ct/cmd/root.go index a67526fe..0de53311 100644 --- a/ct/cmd/root.go +++ b/ct/cmd/root.go @@ -64,6 +64,7 @@ func addCommonFlags(flags *pflag.FlagSet) { flags.StringVar(&cfgFile, "config", "", "Config file") flags.String("remote", "origin", "The name of the Git remote used to identify changed charts") flags.String("target-branch", "master", "The name of the target branch used to identify changed charts") + flags.String("since", "HEAD", "The Git reference used to identify changed charts") flags.StringSlice("chart-dirs", []string{"charts"}, heredoc.Doc(` Directories containing Helm charts. May be specified multiple times or separate values with commas`)) diff --git a/doc/ct.md b/doc/ct.md index c811f476..9fbd0938 100644 --- a/doc/ct.md +++ b/doc/ct.md @@ -26,4 +26,4 @@ in given chart directories. * [ct list-changed](ct_list-changed.md) - List changed charts * [ct version](ct_version.md) - Print version information -###### Auto generated by spf13/cobra on 13-Dec-2019 +###### Auto generated by spf13/cobra on 21-Apr-2020 diff --git a/doc/ct_install.md b/doc/ct_install.md index cf80772f..e38f651d 100644 --- a/doc/ct_install.md +++ b/doc/ct_install.md @@ -59,6 +59,7 @@ ct install [flags] --release-label string The label to be used as a selector when inspecting resources created by charts. This is only used if namespace is specified (default "app.kubernetes.io/instance") --remote string The name of the Git remote used to identify changed charts (default "origin") + --since string The Git reference used to identify changed charts (default "HEAD") --skip-missing-values When --upgrade has been passed, this flag will skip testing CI values files from the previous chart revision if they have been deleted or renamed at the current chart revision @@ -71,4 +72,4 @@ ct install [flags] * [ct](ct.md) - The Helm chart testing tool -###### Auto generated by spf13/cobra on 13-Dec-2019 +###### Auto generated by spf13/cobra on 21-Apr-2020 diff --git a/doc/ct_lint-and-install.md b/doc/ct_lint-and-install.md index a0794b11..a7888b14 100644 --- a/doc/ct_lint-and-install.md +++ b/doc/ct_lint-and-install.md @@ -50,6 +50,7 @@ ct lint-and-install [flags] --release-label string The label to be used as a selector when inspecting resources created by charts. This is only used if namespace is specified (default "app.kubernetes.io/instance") --remote string The name of the Git remote used to identify changed charts (default "origin") + --since string The Git reference used to identify changed charts (default "HEAD") --skip-missing-values When --upgrade has been passed, this flag will skip testing CI values files from the previous chart revision if they have been deleted or renamed at the current chart revision @@ -66,4 +67,4 @@ ct lint-and-install [flags] * [ct](ct.md) - The Helm chart testing tool -###### Auto generated by spf13/cobra on 13-Dec-2019 +###### Auto generated by spf13/cobra on 21-Apr-2020 diff --git a/doc/ct_lint.md b/doc/ct_lint.md index 4dff5ba0..8e94b6b7 100644 --- a/doc/ct_lint.md +++ b/doc/ct_lint.md @@ -54,6 +54,7 @@ ct lint [flags] is searched in the current directory, '$HOME/.ct', and '/etc/ct', in that order --remote string The name of the Git remote used to identify changed charts (default "origin") + --since string The Git reference used to identify changed charts (default "HEAD") --target-branch string The name of the target branch used to identify changed charts (default "master") --validate-chart-schema Enable schema validation of 'Chart.yaml' using Yamale (default: true) (default true) --validate-maintainers Enable validation of maintainer account names in chart.yml (default: true). @@ -65,4 +66,4 @@ ct lint [flags] * [ct](ct.md) - The Helm chart testing tool -###### Auto generated by spf13/cobra on 13-Dec-2019 +###### Auto generated by spf13/cobra on 21-Apr-2020 diff --git a/doc/ct_list-changed.md b/doc/ct_list-changed.md index b30ae3ff..480677f5 100644 --- a/doc/ct_list-changed.md +++ b/doc/ct_list-changed.md @@ -21,6 +21,7 @@ ct list-changed [flags] or separate values with commas -h, --help help for list-changed --remote string The name of the Git remote used to identify changed charts (default "origin") + --since string The Git reference used to identify changed charts (default "HEAD") --target-branch string The name of the target branch used to identify changed charts (default "master") ``` @@ -28,4 +29,4 @@ ct list-changed [flags] * [ct](ct.md) - The Helm chart testing tool -###### Auto generated by spf13/cobra on 13-Dec-2019 +###### Auto generated by spf13/cobra on 21-Apr-2020 diff --git a/doc/ct_version.md b/doc/ct_version.md index a705e008..12e25f1a 100644 --- a/doc/ct_version.md +++ b/doc/ct_version.md @@ -20,4 +20,4 @@ ct version [flags] * [ct](ct.md) - The Helm chart testing tool -###### Auto generated by spf13/cobra on 13-Dec-2019 +###### Auto generated by spf13/cobra on 21-Apr-2020 diff --git a/pkg/chart/chart.go b/pkg/chart/chart.go index a8353542..07c04f10 100644 --- a/pkg/chart/chart.go +++ b/pkg/chart/chart.go @@ -675,7 +675,7 @@ func (t *Testing) computeMergeBase() (string, error) { if err != nil { return "", errors.New("Must be in a git repository") } - return t.git.MergeBase(fmt.Sprintf("%s/%s", t.config.Remote, t.config.TargetBranch), "HEAD") + return t.git.MergeBase(fmt.Sprintf("%s/%s", t.config.Remote, t.config.TargetBranch), t.config.Since) } // ComputeChangedChartDirectories takes the merge base of HEAD and the configured remote and target branch and computes a diff --git a/pkg/config/config.go b/pkg/config/config.go index 94e7df35..040f1712 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -41,6 +41,7 @@ var ( type Configuration struct { Remote string `mapstructure:"remote"` TargetBranch string `mapstructure:"target-branch"` + Since string `mapstructure:"since"` BuildId string `mapstructure:"build-id"` LintConf string `mapstructure:"lint-conf"` ChartYamlSchema string `mapstructure:"chart-yaml-schema"` diff --git a/pkg/config/test_config.json b/pkg/config/test_config.json index ed5f0f7a..a46d1de4 100644 --- a/pkg/config/test_config.json +++ b/pkg/config/test_config.json @@ -1,6 +1,7 @@ { "remote": "origin", "target-branch": "master", + "since": "HEAD~1", "build-id": "pr-42", "lint-conf": "my-lint-conf.yaml", "chart-yaml-schema": "my-chart-yaml-schema.yaml", diff --git a/pkg/config/test_config.yaml b/pkg/config/test_config.yaml index 1e720be6..b2942340 100644 --- a/pkg/config/test_config.yaml +++ b/pkg/config/test_config.yaml @@ -1,5 +1,6 @@ remote: origin target-branch: master +since: HEAD~1 build-id: pr-42 lint-conf: my-lint-conf.yaml chart-yaml-schema: my-chart-yaml-schema.yaml