summaryrefslogtreecommitdiffstats
path: root/modules/repository/repo.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-10-14 17:07:53 +0100
committerGitHub <noreply@github.com>2021-10-14 18:07:53 +0200
commita20ccec369e0ad7023cb77a480569e82fa5ada76 (patch)
tree26979dd57a0bebe4aeafbaa912073622b5d70f4c /modules/repository/repo.go
parent9c2b7a196e6e546650ed687b3e0992f6d5a11c33 (diff)
downloadgitea-a20ccec369e0ad7023cb77a480569e82fa5ada76.tar.gz
gitea-a20ccec369e0ad7023cb77a480569e82fa5ada76.zip
Ensure that git daemon export ok is created for mirrors (#17243) (#17306)
Backport #17243 There is an issue with #16508 where it appears that create repo requires that the repo does not exist. This causes #17241 where an error is reported because of this. This PR fixes this and also runs update-server-info for mirrors and generated repos. Fix #17241 Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules/repository/repo.go')
-rw-r--r--modules/repository/repo.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/modules/repository/repo.go b/modules/repository/repo.go
index 08531c04ed..45308ad162 100644
--- a/modules/repository/repo.go
+++ b/modules/repository/repo.go
@@ -95,6 +95,21 @@ func MigrateRepositoryGitData(ctx context.Context, u *models.User, repo *models.
}
}
+ if repo.OwnerID == u.ID {
+ repo.Owner = u
+ }
+
+ if err = repo.CheckDaemonExportOK(); err != nil {
+ return repo, fmt.Errorf("checkDaemonExportOK: %v", err)
+ }
+
+ if stdout, err := git.NewCommandContext(ctx, "update-server-info").
+ SetDescription(fmt.Sprintf("MigrateRepositoryGitData(git update-server-info): %s", repoPath)).
+ RunInDir(repoPath); err != nil {
+ log.Error("MigrateRepositoryGitData(git update-server-info) in %v: Stdout: %s\nError: %v", repo, stdout, err)
+ return repo, fmt.Errorf("error in MigrateRepositoryGitData(git update-server-info): %v", err)
+ }
+
gitRepo, err := git.OpenRepository(repoPath)
if err != nil {
return repo, fmt.Errorf("OpenRepository: %v", err)