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:6071

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"
! exec pint -l error --no-color ci --require-owner
! stdout .
cd ..
cmp stderr stderr.txt

-- stderr.txt --
Bug: missing owner (rule/owner)
  ---> rules.yml:4-5 -> `rule1`
5 |       expr: sum(foo) by(job)
                ^^^ `rule/owner` comments are required in all files, please add a `# pint file/owner $owner` somewhere in this file and/or `# pint rule/owner $owner` on top of each rule.

Warning: always firing alert (alerts/comparison)
  ---> rules.yml:5 -> `rule1`
5 |       expr: sum(foo) by(job)
                    ^^^ This query doesn't have any condition and so this alert will always fire if it matches anything.

Bug: missing owner (rule/owner)
  ---> rules.yml:6-7 -> `rule2`
7 |       expr: sum(foo) by(job) > 0
                ^^^ `rule/owner` comments are required in all files, please add a `# pint file/owner $owner` somewhere in this file and/or `# pint rule/owner $owner` on top of each rule.

level=ERROR msg="Execution completed with error(s)" err="problems found"
-- src/v1.yml --
- alert: rule1
    expr: sum(foo) by(job)
- alert: rule2
    expr: sum(foo) by(job)
    for: 0s

-- src/v2.yml --
groups:
  - name: foo
    rules:
    - alert: rule1
      expr: sum(foo) by(job)
    - alert: rule2
      expr: sum(foo) by(job) > 0

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