Skip to content

Commit

Permalink
Add since flag for changing the reference branch for git merge-base (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-sensenich authored Jul 24, 2020
1 parent 67ec12d commit 93b10e8
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions ct/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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`))
Expand Down
2 changes: 1 addition & 1 deletion doc/ct.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion doc/ct_install.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
3 changes: 2 additions & 1 deletion doc/ct_lint-and-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
3 changes: 2 additions & 1 deletion doc/ct_lint.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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
3 changes: 2 additions & 1 deletion doc/ct_list-changed.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ 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")
```

### SEE ALSO

* [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
2 changes: 1 addition & 1 deletion doc/ct_version.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion pkg/chart/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
1 change: 1 addition & 0 deletions pkg/config/test_config.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
1 change: 1 addition & 0 deletions pkg/config/test_config.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 93b10e8

Please sign in to comment.