MCPcopy Index your code
hub / github.com/coder/coder / buildChatRepositoryRefFromStatus

Method buildChatRepositoryRefFromStatus

coderd/exp_chats.go:4177–4203  ·  view source on GitHub ↗

buildChatRepositoryRefFromStatus constructs a chatRepositoryRef from the git branch and remote origin stored in the cached status. Returns nil if no ref data is available.

(ctx context.Context, status database.ChatDiffStatus)

Source from the content-addressed store, hash-verified

4175// from the git branch and remote origin stored in the cached status.
4176// Returns nil if no ref data is available.
4177func (api *API) buildChatRepositoryRefFromStatus(ctx context.Context, status database.ChatDiffStatus) *chatRepositoryRef {
4178 branch := strings.TrimSpace(status.GitBranch)
4179 origin := strings.TrimSpace(status.GitRemoteOrigin)
4180 if branch == "" || origin == "" {
4181 return nil
4182 }
4183
4184 providerType, gp := api.resolveExternalAuth(ctx, origin)
4185 repoRef := &chatRepositoryRef{
4186 Provider: providerType,
4187 RemoteOrigin: origin,
4188 Branch: branch,
4189 }
4190 if gp != nil {
4191 if owner, repo, normalizedOrigin, ok := gp.ParseRepositoryOrigin(repoRef.RemoteOrigin); ok {
4192 repoRef.RemoteOrigin = normalizedOrigin
4193 repoRef.Owner = owner
4194 repoRef.Repo = repo
4195 }
4196 }
4197
4198 if repoRef.Provider == "" {
4199 return nil
4200 }
4201
4202 return repoRef
4203}
4204
4205func (api *API) upsertChatDiffStatusReference(
4206 ctx context.Context,

Callers 1

Calls 2

resolveExternalAuthMethod · 0.95
ParseRepositoryOriginMethod · 0.65

Tested by

no test coverage detected