http response bitbucket /rest/insights/1.0/projects/prometheus/repos/rules/commits/.*/reports/pint 200 OK
http response bitbucket /rest/api/1.0/projects/prometheus/repos/rules/commits/.*/pull-requests 200 {}
http start bitbucket 127.0.0.1:6069

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'

env BITBUCKET_AUTH_TOKEN="12345"
pint.error -l error --no-color ci
! stdout .
cmp stderr ../stderr.txt

-- stderr.txt --
rules.yml:2 Warning: Alert query doesn't have any condition, it will always fire if the metric exists. (alerts/comparison)
 2 |   expr: sum(foo{job=~"xxx"}) by(job)

rules.yml:2 Bug: Unnecessary regexp match on static string `job=~"xxx"`, use `job="xxx"` instead. (promql/regexp)
 2 |   expr: sum(foo{job=~"xxx"}) by(job)

rules.yml:3 Information: `0s` is the default value of `for`, consider removing this redundant line. (alerts/for)
 3 |   for: 0s

rules.yml:5 Warning: Alert query doesn't have any condition, it will always fire if the metric exists. (alerts/comparison)
 5 |   expr: sum(foo{job=~"xxx"}) by(job)

rules.yml:5 Bug: Unnecessary regexp match on static string `job=~"xxx"`, use `job="xxx"` instead. (promql/regexp)
 5 |   expr: sum(foo{job=~"xxx"}) by(job)

rules.yml:6 Information: `0s` is the default value of `for`, consider removing this redundant line. (alerts/for)
 6 |   for: 0s

level=ERROR msg="Fatal error" err="problems found"
-- src/v1.yml --
- alert: rule1a
  expr: sum(foo{job=~"xxx"}) by(job)
- alert: rule2a
  expr: sum(foo{job=~"xxx"}) by(job)
  for: 0s

-- src/v2.yml --
- alert: rule1b
  expr: sum(foo{job=~"xxx"}) by(job)
  for: 0s
- alert: rule2b
  expr: sum(foo{job=~"xxx"}) by(job)
  for: 0s

-- src/.pint.hcl --
parser {
  relaxed = [".*"]
}
ci {
  baseBranch = "main"
}
repository {
  bitbucket {
    uri        = "http://127.0.0.1:6069"
    timeout    = "10s"
    project    = "prometheus"
    repository = "rules"
  }
}
