ReinitMissingRepositories reinitializes all repository records that lost Git files.
()
| 2027 | |
| 2028 | // ReinitMissingRepositories reinitializes all repository records that lost Git files. |
| 2029 | func ReinitMissingRepositories() error { |
| 2030 | repos, err := gatherMissingRepoRecords() |
| 2031 | if err != nil { |
| 2032 | return errors.Newf("gatherMissingRepoRecords: %v", err) |
| 2033 | } |
| 2034 | |
| 2035 | if len(repos) == 0 { |
| 2036 | return nil |
| 2037 | } |
| 2038 | |
| 2039 | for _, repo := range repos { |
| 2040 | log.Trace("Initializing %d/%d...", repo.OwnerID, repo.ID) |
| 2041 | if err := git.Init(repo.RepoPath(), git.InitOptions{Bare: true}); err != nil { |
| 2042 | if err2 := Handle.Notices().Create(context.TODO(), NoticeTypeRepository, fmt.Sprintf("init repository [repo_id: %d]: %v", repo.ID, err)); err2 != nil { |
| 2043 | return errors.Newf("create repository notice: %v", err) |
| 2044 | } |
| 2045 | } |
| 2046 | } |
| 2047 | return nil |
| 2048 | } |
| 2049 | |
| 2050 | // SyncRepositoryHooks rewrites all repositories' pre-receive, update and post-receive hooks |
| 2051 | // to make sure the binary and custom conf path are up-to-date. |
no test coverage detected