Skip to content

Self-hosted workflows for coding-agent delivery. Orchestrate CodeBuddy, Codex and Claude Code with scripts and human approval gates. Includes Local workflows for coding assistants.

refactor(domain): extract publicRunnerRepository from PublicRunnerTask (#419) (#420)

fx-kurumie05b3ac0cacc
diff --git a/internal/domain/runner.go b/internal/domain/runner.go
index 5584da40..48bebf5b 100644
--- a/internal/domain/runner.go
+++ b/internal/domain/runner.go
@@ -411,17 +411,13 @@ func PublicRunnerTask(task RunnerTask) RunnerTask {
copyInvocation.GitSSHUserID = 0
copyInvocation.GitSSHKeys = nil
if copyInvocation.Repository != nil {
- copyRepository := *copyInvocation.Repository
- copyRepository.GitToken = ""
- copyRepository.CloneURL = StripURLCredentials(copyRepository.CloneURL)
+ copyRepository := publicRunnerRepository(*copyInvocation.Repository)
copyInvocation.Repository = &copyRepository
}
if len(copyInvocation.Repositories) > 0 {
copyRepositories := make([]RunnerRepository, len(copyInvocation.Repositories))
for i, repository := range copyInvocation.Repositories {
- repository.GitToken = ""
- repository.CloneURL = StripURLCredentials(repository.CloneURL)
- copyRepositories[i] = repository
+ copyRepositories[i] = publicRunnerRepository(repository)
}
copyInvocation.Repositories = copyRepositories
}
@@ -429,6 +425,14 @@ func PublicRunnerTask(task RunnerTask) RunnerTask {
return task
}
+// publicRunnerRepository returns a copy of one checkout spec with its Git
+// credentials removed: the token field and any userinfo in the clone URL.
+func publicRunnerRepository(repository RunnerRepository) RunnerRepository {
+ repository.GitToken = ""
+ repository.CloneURL = StripURLCredentials(repository.CloneURL)
+ return repository
+}
+
// RunnerInvocation is the self-contained package a runner daemon needs to
// reconstruct one Agent node invocation in its own task workspace. Provider
// credentials are included only when the runtime selects personal credentials
diff --git a/internal/domain/runner_test.go b/internal/domain/runner_test.go
index 5eb66afa..d1485797 100644
--- a/internal/domain/runner_test.go
+++ b/internal/domain/runner_test.go
@@ -114,3 +114,26 @@ func TestRunnerSupportsExistingWorkBranch(t *testing.T) {
}
}
}
+
+func TestPublicRunnerRepositoryScrubsCredentialsOnly(t *testing.T) {
+ source := RunnerRepository{
+ RepositoryID: "repo-1",
+ Name: "app",
+ CloneURL: "https://user:[email protected]/acme/app.git",
+ Ref: "main",
+ WorkBranch: "feature/x",
+ GitToken: "token",
+ UseSSH: true,
+ Dir: "app",
+ }
+ got := publicRunnerRepository(source)
+ want := source
+ want.GitToken = ""
+ want.CloneURL = "https://github.com/acme/app.git"
+ if got != want {
+ t.Fatalf("publicRunnerRepository() = %+v, want %+v", got, want)
+ }
+ if source.GitToken != "token" || source.CloneURL != "https://user:[email protected]/acme/app.git" {
+ t.Fatal("publicRunnerRepository must not mutate its argument")
+ }
+}