MCPcopy Index your code
hub / github.com/rilldata/rill / CreateManagedGitRepo

Method CreateManagedGitRepo

admin/github.go:250–277  ·  view source on GitHub ↗
(ctx context.Context, org *database.Organization, name, ownerID string, autoInit bool)

Source from the content-addressed store, hash-verified

248}
249
250func (s *Service) CreateManagedGitRepo(ctx context.Context, org *database.Organization, name, ownerID string, autoInit bool) (*github.Repository, error) {
251 if org.QuotaProjects >= 0 {
252 count, err := s.DB.CountManagedGitRepos(ctx, org.ID)
253 if err != nil {
254 return nil, fmt.Errorf("failed to count managed repos: %w", err)
255 }
256
257 quota := quotaManagedRepos(org)
258 if count >= quota {
259 return nil, fmt.Errorf("managed repo quota exceeded: %d/%d", count, quota)
260 }
261 }
262
263 repo, err := s.Github.CreateManagedRepo(ctx, fmt.Sprintf("%s-%s", org.Name, name), autoInit)
264 if err != nil {
265 return nil, fmt.Errorf("failed to create managed repo: %w", err)
266 }
267 _, err = s.DB.InsertManagedGitRepo(ctx, &database.InsertManagedGitRepoOptions{
268 OrgID: org.ID,
269 Remote: repo.GetCloneURL(),
270 OwnerID: ownerID,
271 })
272 if err != nil {
273 return nil, fmt.Errorf("failed to insert managed repo meta: %w", err)
274 }
275
276 return repo, nil
277}
278
279// GetGithubInstallation returns a non zero Github installation ID if the Github App is installed on the repository and is not in suspended state.
280// The remote should be a HTTPS URL for a github.com repository with the .git suffix.

Callers

nothing calls this directly

Calls 5

quotaManagedReposFunction · 0.85
CountManagedGitReposMethod · 0.65
ErrorfMethod · 0.65
CreateManagedRepoMethod · 0.65
InsertManagedGitRepoMethod · 0.65

Tested by

no test coverage detected