Delete removes the auth file.
(_ context.Context, id string)
| 383 | |
| 384 | // Delete removes the auth file. |
| 385 | func (s *GitTokenStore) Delete(_ context.Context, id string) error { |
| 386 | id = strings.TrimSpace(id) |
| 387 | if id == "" { |
| 388 | return fmt.Errorf("auth filestore: id is empty") |
| 389 | } |
| 390 | path, err := s.resolveDeletePath(id) |
| 391 | if err != nil { |
| 392 | return err |
| 393 | } |
| 394 | if err = s.EnsureRepository(); err != nil { |
| 395 | return err |
| 396 | } |
| 397 | |
| 398 | s.mu.Lock() |
| 399 | defer s.mu.Unlock() |
| 400 | |
| 401 | if err = os.Remove(path); err != nil && !os.IsNotExist(err) { |
| 402 | return fmt.Errorf("auth filestore: delete failed: %w", err) |
| 403 | } |
| 404 | if err == nil { |
| 405 | rel, errRel := s.relativeToRepo(path) |
| 406 | if errRel != nil { |
| 407 | return errRel |
| 408 | } |
| 409 | messageID := id |
| 410 | if errCommit := s.commitAndPushLocked(fmt.Sprintf("Delete auth %s", messageID), rel); errCommit != nil { |
| 411 | return errCommit |
| 412 | } |
| 413 | } |
| 414 | return nil |
| 415 | } |
| 416 | |
| 417 | // PersistAuthFiles commits and pushes the provided paths to the remote repository. |
| 418 | // It no-ops when the store is not fully configured or when there are no paths. |
nothing calls this directly
no test coverage detected