1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-09 20:17:21 +00:00

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>
This commit is contained in:
zeripath
2021-10-14 17:07:53 +01:00
committed by GitHub
parent 9c2b7a196e
commit a20ccec369
6 changed files with 79 additions and 28 deletions

View File

@ -95,14 +95,17 @@ func ForkRepository(doer, owner *models.User, oldRepo *models.Repository, name,
needsRollback = true
repoPath := models.RepoPath(owner.Name, repo.Name)
if stdout, err := git.NewCommand(
"clone", "--bare", oldRepoPath, repoPath).
if stdout, err := git.NewCommand("clone", "--bare", oldRepoPath, repoPath).
SetDescription(fmt.Sprintf("ForkRepository(git clone): %s to %s", oldRepo.FullName(), repo.FullName())).
RunInDirTimeout(10*time.Minute, ""); err != nil {
log.Error("Fork Repository (git clone) Failed for %v (from %v):\nStdout: %s\nError: %v", repo, oldRepo, stdout, err)
return fmt.Errorf("git clone: %v", err)
}
if err := repo.CheckDaemonExportOKCtx(ctx); err != nil {
return fmt.Errorf("checkDaemonExportOK: %v", err)
}
if stdout, err := git.NewCommand("update-server-info").
SetDescription(fmt.Sprintf("ForkRepository(git update-server-info): %s", repo.FullName())).
RunInDir(repoPath); err != nil {