You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

repo.go 724B

123456789101112131415161718192021222324252627
  1. // Copyright 2022 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package org
  4. import (
  5. "context"
  6. "errors"
  7. "code.gitea.io/gitea/models"
  8. "code.gitea.io/gitea/models/db"
  9. "code.gitea.io/gitea/models/organization"
  10. repo_model "code.gitea.io/gitea/models/repo"
  11. )
  12. // TeamAddRepository adds new repository to team of organization.
  13. func TeamAddRepository(t *organization.Team, repo *repo_model.Repository) (err error) {
  14. if repo.OwnerID != t.OrgID {
  15. return errors.New("repository does not belong to organization")
  16. } else if models.HasRepository(t, repo.ID) {
  17. return nil
  18. }
  19. return db.WithTx(db.DefaultContext, func(ctx context.Context) error {
  20. return models.AddRepository(ctx, t, repo)
  21. })
  22. }