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)
| 4175 | // from the git branch and remote origin stored in the cached status. |
| 4176 | // Returns nil if no ref data is available. |
| 4177 | func (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 | |
| 4205 | func (api *API) upsertChatDiffStatusReference( |
| 4206 | ctx context.Context, |
no test coverage detected