From a28e2d87840f275a2c4e1d216bce06aeabb7b011 Mon Sep 17 00:00:00 2001 From: Kynan Ware <47394200+BagToad@users.noreply.github.com> Date: Fri, 16 May 2025 12:28:46 -0600 Subject: [PATCH] refactor(api): use constant for Copilot login --- api/queries_repo.go | 7 ++++++- pkg/cmd/pr/shared/params.go | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/api/queries_repo.go b/api/queries_repo.go index f72277fb2..28d4374b7 100644 --- a/api/queries_repo.go +++ b/api/queries_repo.go @@ -1183,6 +1183,11 @@ func RepoProjects(client *Client, repo ghrepo.Interface) ([]RepoProject, error) return projects, nil } +// Expected login for Copilot when retrieved as an Actor +// This is returned from assignable actors and issue/pr assigned actors. +// We use this to check if the actor is Copilot. +var CopilotActorLogin = "copilot-swe-agent" + type AssignableActor interface { DisplayName() string ID() string @@ -1241,7 +1246,7 @@ func NewAssignableBot(id, login string) AssignableBot { } func (b AssignableBot) DisplayName() string { - if b.login == "copilot-swe-agent" { + if b.login == CopilotActorLogin { return "Copilot (AI)" } return b.Login() diff --git a/pkg/cmd/pr/shared/params.go b/pkg/cmd/pr/shared/params.go index e53ad7a06..ba9901f77 100644 --- a/pkg/cmd/pr/shared/params.go +++ b/pkg/cmd/pr/shared/params.go @@ -322,7 +322,7 @@ func NewCopilotReplacer() *CopilotReplacer { func (r *CopilotReplacer) replace(handle string) string { if strings.EqualFold(handle, "@copilot") { - return "copilot-swe-agent" + return api.CopilotActorLogin } return handle }