Skip to content

Commit

Permalink
Correctly pass base branch flag
Browse files Browse the repository at this point in the history
  • Loading branch information
prymitive committed Mar 7, 2023
1 parent e31c260 commit e213189
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cmd/pint/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ func actionCI(c *cli.Context) error {

var entries []discovery.Entry
if c.Bool(devFlag) {
finder := discovery.NewGitBranchFinder(git.RunGit, includeRe, meta.cfg.CI.BaseBranch, meta.cfg.CI.MaxCommits, meta.cfg.Parser.CompileRelaxed())
finder := discovery.NewGitBranchFinder(git.RunGit, includeRe, baseBranch, meta.cfg.CI.MaxCommits, meta.cfg.Parser.CompileRelaxed())
entries, err = finder.Find()
} else {
finder := discovery.NewGitBlameFinder(git.RunGit, includeRe, meta.cfg.CI.BaseBranch, meta.cfg.CI.MaxCommits, meta.cfg.Parser.CompileRelaxed())
finder := discovery.NewGitBlameFinder(git.RunGit, includeRe, baseBranch, meta.cfg.CI.MaxCommits, meta.cfg.Parser.CompileRelaxed())
entries, err = finder.Find()
}
if err != nil {
Expand Down
44 changes: 44 additions & 0 deletions cmd/pint/tests/0124_ci_base_branch_flag.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
mkdir testrepo
cd testrepo
exec git init --initial-branch=main .

cp ../src/v1.yml rules.yml
cp ../src/.pint.hcl .
env GIT_AUTHOR_NAME=pint
env GIT_AUTHOR_EMAIL=pint@example.com
env GIT_COMMITTER_NAME=pint
env GIT_COMMITTER_EMAIL=pint@example.com
exec git add .
exec git commit -am 'import rules and config'

exec git checkout -b v2
cp ../src/v2.yml rules.yml
exec git commit -am 'v2'

pint.error --no-color ci --base-branch=main
! stdout .
cmp stderr ../stderr.txt

-- stderr.txt --
level=info msg="Loading configuration file" path=.pint.hcl
level=info msg="Problems found" Fatal=1
rules.yml:2 Fatal: syntax error: unexpected identifier "bi" (promql/syntax)
2 | expr: sum(foo) bi(job)

level=fatal msg="Fatal error" error="problems found"
-- src/v1.yml --
- record: rule1
expr: sum(foo) by(job)
- record: rule2
expr: sum(foo) bi(job)

-- src/v2.yml --
- record: rule1
expr: sum(foo) bi(job)
- record: rule2
expr: sum(foo) bi(job)

-- src/.pint.hcl --
parser {
relaxed = [".*"]
}
7 changes: 7 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## v0.42.1

### Fixed

- Fixed `--initial-branch` flag handling.
Value of this flag wasn't being used correctly - #559.

## v0.42.0

### Fixed
Expand Down

0 comments on commit e213189

Please sign in to comment.