PersistConfig commits and pushes configuration changes to git.
(_ context.Context)
| 935 | |
| 936 | // PersistConfig commits and pushes configuration changes to git. |
| 937 | func (s *GitTokenStore) PersistConfig(_ context.Context) error { |
| 938 | if err := s.EnsureRepository(); err != nil { |
| 939 | return err |
| 940 | } |
| 941 | configPath := s.ConfigPath() |
| 942 | if configPath == "" { |
| 943 | return fmt.Errorf("git token store: config path not configured") |
| 944 | } |
| 945 | if _, err := os.Stat(configPath); err != nil { |
| 946 | if errors.Is(err, fs.ErrNotExist) { |
| 947 | return nil |
| 948 | } |
| 949 | return fmt.Errorf("git token store: stat config: %w", err) |
| 950 | } |
| 951 | s.mu.Lock() |
| 952 | defer s.mu.Unlock() |
| 953 | rel, err := s.relativeToRepo(configPath) |
| 954 | if err != nil { |
| 955 | return err |
| 956 | } |
| 957 | return s.commitAndPushLocked("Update config", rel) |
| 958 | } |
| 959 | |
| 960 | func ensureEmptyFile(path string) error { |
| 961 | if _, err := os.Stat(path); err != nil { |
nothing calls this directly
no test coverage detected