feat: add head_branch to pull request diff status (#23076)

Adds the `head_branch` field (the source/feature branch name of a PR) to
the diff status pipeline. Previously only `base_branch` (target branch)
and the head commit SHA were captured from the GitHub API, but not the
head branch name itself.

## Changes

- **Migration 438**: Add `head_branch` nullable TEXT column to
`chat_diff_statuses`
- **gitprovider**: Parse `head.ref` from the GitHub API response
(alongside `head.sha`) and add `HeadBranch` to `PRStatus`
- **gitsync**: Wire `HeadBranch` through `refreshOne()` into the DB
upsert params
- **worker**: Map `HeadBranch` in `chatDiffStatusFromRow()`
- **coderd**: Convert `HeadBranch` in `convertChatDiffStatus()`
- **codersdk**: Expose as `head_branch` (`*string`, omitempty) in
`ChatDiffStatus` API response
- **Tests**: Updated `github_test.go` pull JSON fixtures and assertions
This commit is contained in:
Kyle Carberry
2026-03-14 17:24:19 +00:00
committed by GitHub
parent 3f7f25b3ee
commit 0d3e39a24e
14 changed files with 54 additions and 24 deletions
+1
View File
@@ -319,6 +319,7 @@ func (r *Refresher) refreshOne(
AuthorLogin: sql.NullString{String: status.AuthorLogin, Valid: status.AuthorLogin != ""},
AuthorAvatarUrl: sql.NullString{String: status.AuthorAvatarURL, Valid: status.AuthorAvatarURL != ""},
BaseBranch: sql.NullString{String: status.BaseBranch, Valid: status.BaseBranch != ""},
HeadBranch: sql.NullString{String: status.HeadBranch, Valid: status.HeadBranch != ""},
PrNumber: sql.NullInt32{Int32: int32(status.PRNumber), Valid: true},
Commits: sql.NullInt32{Int32: status.Commits, Valid: true},
Approved: sql.NullBool{Bool: status.Approved, Valid: true},
+1
View File
@@ -143,6 +143,7 @@ func chatDiffStatusFromRow(row database.AcquireStaleChatDiffStatusesRow) databas
AuthorLogin: row.AuthorLogin,
AuthorAvatarUrl: row.AuthorAvatarUrl,
BaseBranch: row.BaseBranch,
HeadBranch: row.HeadBranch,
PrNumber: row.PrNumber,
Commits: row.Commits,
Approved: row.Approved,