ads PR-triggered builds

This commit is contained in:
Michael Hoennig
2026-07-08 06:32:40 +02:00
parent 0e3f97db62
commit 0b17537b7c
7 changed files with 152 additions and 3 deletions
@@ -63,6 +63,18 @@ class GitService(
.filter { (branch, _) -> branch != "HEAD" }
.toMap()
/**
* Head commits of the remote's pull-request refs (`refs/pull/<n>/head`), which Gitea
* exposes to plain git clients — no API token needed. A branch whose head appears
* here has a pull request open for exactly this commit.
*/
fun pullRequestHeads(workingDir: Path = Paths.get(".")): Set<String> =
authenticated(workingDir) { environment ->
runner.runOrThrow(listOf("git", "ls-remote", "origin", "refs/pull/*/head"), workingDir, environment)
}.lines()
.map { it.substringBefore('\t') }
.toSet()
/**
* A branch has new commits when its origin counterpart is ahead of the local branch,
* or when it exists only on origin.