MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / PersistConfig

Method PersistConfig

internal/store/gitstore.go:937–958  ·  view source on GitHub ↗

PersistConfig commits and pushes configuration changes to git.

(_ context.Context)

Source from the content-addressed store, hash-verified

935
936// PersistConfig commits and pushes configuration changes to git.
937func (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
960func ensureEmptyFile(path string) error {
961 if _, err := os.Stat(path); err != nil {

Callers

nothing calls this directly

Calls 4

EnsureRepositoryMethod · 0.95
ConfigPathMethod · 0.95
relativeToRepoMethod · 0.95
commitAndPushLockedMethod · 0.95

Tested by

no test coverage detected