(ctx context.Context, repoID string)
| 129 | } |
| 130 | |
| 131 | func (s *sqlDatabase) DeleteRepository(ctx context.Context, repoID string) (err error) { |
| 132 | repo, err := s.getRepoByID(ctx, s.conn, repoID, "Endpoint", "Credentials", "Credentials.Endpoint", "GiteaCredentials", "GiteaCredentials.Endpoint") |
| 133 | if err != nil { |
| 134 | return fmt.Errorf("error fetching repo: %w", err) |
| 135 | } |
| 136 | |
| 137 | defer func(repo Repository) { |
| 138 | if err == nil { |
| 139 | asParam, innerErr := s.sqlToCommonRepository(repo, true) |
| 140 | if innerErr == nil { |
| 141 | s.sendNotify(common.RepositoryEntityType, common.DeleteOperation, asParam) |
| 142 | } else { |
| 143 | slog.With(slog.Any("error", innerErr)).ErrorContext(ctx, "error sending delete notification", "repo", repoID) |
| 144 | } |
| 145 | } |
| 146 | }(repo) |
| 147 | |
| 148 | q := s.conn.Unscoped().Delete(&repo) |
| 149 | if q.Error != nil && !errors.Is(q.Error, gorm.ErrRecordNotFound) { |
| 150 | return fmt.Errorf("error deleting repo: %w", q.Error) |
| 151 | } |
| 152 | |
| 153 | return nil |
| 154 | } |
| 155 | |
| 156 | func (s *sqlDatabase) UpdateRepository(ctx context.Context, repoID string, param params.UpdateEntityParams) (newParams params.Repository, err error) { |
| 157 | var rowsAffected int64 |
nothing calls this directly
no test coverage detected