1
0
Fork 0
forked from forgejo/forgejo

Abstract hash function usage (#28138)

Refactor Hash interfaces and centralize hash function. This will allow
easier introduction of different hash function later on.

This forms the "no-op" part of the SHA256 enablement patch.
This commit is contained in:
Adam Majer 2023-12-13 21:02:00 +00:00 committed by GitHub
parent 064f05204c
commit cbf923e87b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
122 changed files with 947 additions and 594 deletions

View file

@ -43,6 +43,7 @@ type CreateRepoOptions struct {
Status repo_model.RepositoryStatus
TrustModel repo_model.TrustModelType
MirrorInterval string
ObjectFormat git.ObjectFormat
}
func prepareRepoCommit(ctx context.Context, repo *repo_model.Repository, tmpDir, repoPath string, opts CreateRepoOptions) error {
@ -134,7 +135,7 @@ func prepareRepoCommit(ctx context.Context, repo *repo_model.Repository, tmpDir,
// InitRepository initializes README and .gitignore if needed.
func initRepository(ctx context.Context, repoPath string, u *user_model.User, repo *repo_model.Repository, opts CreateRepoOptions) (err error) {
if err = repo_module.CheckInitRepository(ctx, repo.OwnerName, repo.Name); err != nil {
if err = repo_module.CheckInitRepository(ctx, repo.OwnerName, repo.Name, opts.ObjectFormat); err != nil {
return err
}
@ -209,6 +210,10 @@ func CreateRepositoryDirectly(ctx context.Context, doer, u *user_model.User, opt
opts.DefaultBranch = setting.Repository.DefaultBranch
}
if opts.ObjectFormat == nil {
opts.ObjectFormat = git.ObjectFormatFromID(git.Sha1)
}
// Check if label template exist
if len(opts.IssueLabels) > 0 {
if _, err := repo_module.LoadTemplateLabelsByDisplayName(opts.IssueLabels); err != nil {
@ -234,6 +239,7 @@ func CreateRepositoryDirectly(ctx context.Context, doer, u *user_model.User, opt
TrustModel: opts.TrustModel,
IsMirror: opts.IsMirror,
DefaultBranch: opts.DefaultBranch,
ObjectFormat: opts.ObjectFormat,
}
var rollbackRepo *repo_model.Repository