--- title: "ADR 0028: Bitbucket Data Center push events diff merge commits from the previous HEAD" --- * Status: accepted * Code: [`pkg/provider/bitbucketdatacenter/parse_payload.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/provider/bitbucketdatacenter/parse_payload.go), [`pkg/provider/bitbucketdatacenter/diff_api.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/provider/bitbucketdatacenter/diff_api.go), [`pkg/provider/bitbucketdatacenter/bitbucketdatacenter.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/provider/bitbucketdatacenter/bitbucketdatacenter.go) ## Context Changed-file matching (`on-path-change` and the `files.*` CEL variables) needs the list of files a push touched. For a push event the provider takes the SHA from `changes[0].ToHash`. When a pull request is merged in Bitbucket Data Center, that hash is the merge commit, and the commit listing for a merge commit does not carry the files brought in by the source branch. Asking for the changes of that single commit therefore under-reports, and path-filtered PipelineRuns fail to trigger. The go-scm client used by this provider has no call for the `changes` endpoint between two commits (`since`/`until`). It also does not expose an `isLastPage` field: `Page.Last` is not populated. ## Decision * `ParsePayload` records `previousHeadCommit` when the push payload has more than one commit and the first commit has more than one parent. The first parent is taken as the previous HEAD of the destination branch. * When `previousHeadCommit` is set, changed files for a push come from `getMergeCommitChanges`, which calls `rest/api/1.0/projects/{org}/repos/{repo}/changes?since=<previous HEAD>&until=<SHA>`. Otherwise the regular `Git.ListChanges` call is used. * `getMergeCommitChanges` issues the request through the go-scm client's `Do`, so authentication and the base URL are shared, but it does not go through the typed API. The call goes through `Client()`, which records API usage before returning the client, so these requests are counted like any other; only the typed request and response structs are bypassed. * Paging, for both pull request and push changes, stops when a page returns fewer items than `apiResponseLimit`, since the last-page flag is unavailable. * Push events that delete a branch (a `DELETE` change with a zero hash) are rejected with an error rather than processed. ## Consequences * A merge push is diffed against the previous HEAD of the destination branch, so it reports every file the merge brought in. * The endpoint path is hard-coded outside go-scm; a change in the Bitbucket Data Center REST API breaks this path without a compile error. * If the page size equals the item count exactly, one extra empty request is made.