aboutsummaryrefslogtreecommitdiffstats
path: root/modules/repository
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2024-01-29 04:18:15 +0800
committerGitHub <noreply@github.com>2024-01-28 20:18:15 +0000
commit34633d85f18ff77643302302379078128dd4ddb7 (patch)
tree0377958609c3a5b159ad6d618f1ea51338573fe7 /modules/repository
parentdfc1ae15b6a15aaa8487b770b2d2f7b36e171c5e (diff)
downloadgitea-34633d85f18ff77643302302379078128dd4ddb7.tar.gz
gitea-34633d85f18ff77643302302379078128dd4ddb7.zip
Fix bug for generated repository object format (#28969)
A repository generated from a template repository should have the same git ObjectFormat.
Diffstat (limited to 'modules/repository')
-rw-r--r--modules/repository/generate.go31
1 files changed, 15 insertions, 16 deletions
diff --git a/modules/repository/generate.go b/modules/repository/generate.go
index b32c4e058e..013dd8f76f 100644
--- a/modules/repository/generate.go
+++ b/modules/repository/generate.go
@@ -224,8 +224,7 @@ func generateRepoCommit(ctx context.Context, repo, templateRepo, generateRepo *r
}
}
- // FIXME: fix the hash
- if err := git.InitRepository(ctx, tmpDir, false, git.Sha1ObjectFormat.Name()); err != nil {
+ if err := git.InitRepository(ctx, tmpDir, false, templateRepo.ObjectFormatName); err != nil {
return err
}
@@ -327,18 +326,19 @@ func (gro GenerateRepoOptions) IsValid() bool {
// GenerateRepository generates a repository from a template
func GenerateRepository(ctx context.Context, doer, owner *user_model.User, templateRepo *repo_model.Repository, opts GenerateRepoOptions) (_ *repo_model.Repository, err error) {
generateRepo := &repo_model.Repository{
- OwnerID: owner.ID,
- Owner: owner,
- OwnerName: owner.Name,
- Name: opts.Name,
- LowerName: strings.ToLower(opts.Name),
- Description: opts.Description,
- DefaultBranch: opts.DefaultBranch,
- IsPrivate: opts.Private,
- IsEmpty: !opts.GitContent || templateRepo.IsEmpty,
- IsFsckEnabled: templateRepo.IsFsckEnabled,
- TemplateID: templateRepo.ID,
- TrustModel: templateRepo.TrustModel,
+ OwnerID: owner.ID,
+ Owner: owner,
+ OwnerName: owner.Name,
+ Name: opts.Name,
+ LowerName: strings.ToLower(opts.Name),
+ Description: opts.Description,
+ DefaultBranch: opts.DefaultBranch,
+ IsPrivate: opts.Private,
+ IsEmpty: !opts.GitContent || templateRepo.IsEmpty,
+ IsFsckEnabled: templateRepo.IsFsckEnabled,
+ TemplateID: templateRepo.ID,
+ TrustModel: templateRepo.TrustModel,
+ ObjectFormatName: templateRepo.ObjectFormatName,
}
if err = CreateRepositoryByExample(ctx, doer, owner, generateRepo, false, false); err != nil {
@@ -358,8 +358,7 @@ func GenerateRepository(ctx context.Context, doer, owner *user_model.User, templ
}
}
- // FIXME - fix the hash
- if err = CheckInitRepository(ctx, owner.Name, generateRepo.Name, git.Sha1ObjectFormat.Name()); err != nil {
+ if err = CheckInitRepository(ctx, owner.Name, generateRepo.Name, generateRepo.ObjectFormatName); err != nil {
return generateRepo, err
}