diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-12-12 23:48:20 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-12 23:48:20 +0800 |
commit | 572324049008ac803d3d7c17a7b3a81ef00386fc (patch) | |
tree | a9c3709643a23165d27aa67e76f10f26a89936d5 /models/repo_generate.go | |
parent | 0a7e8327a017c5dd43e552bbcd0d0f056bc1671b (diff) | |
download | gitea-572324049008ac803d3d7c17a7b3a81ef00386fc.tar.gz gitea-572324049008ac803d3d7c17a7b3a81ef00386fc.zip |
Some repository refactors (#17950)
* some repository refactors
* remove unnecessary code
* Fix test
* Remove unnecessary banner
Diffstat (limited to 'models/repo_generate.go')
-rw-r--r-- | models/repo_generate.go | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/models/repo_generate.go b/models/repo_generate.go index 6b5b8e5bc1..fc749f1120 100644 --- a/models/repo_generate.go +++ b/models/repo_generate.go @@ -8,15 +8,12 @@ import ( "bufio" "bytes" "context" - "strconv" "strings" "code.gitea.io/gitea/models/db" repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/models/webhook" - "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" - "code.gitea.io/gitea/modules/storage" "github.com/gobwas/glob" ) @@ -70,49 +67,6 @@ func (gt GiteaTemplate) Globs() []glob.Glob { return gt.globs } -// GenerateTopics generates topics from a template repository -func GenerateTopics(ctx context.Context, templateRepo, generateRepo *repo_model.Repository) error { - for _, topic := range templateRepo.Topics { - if _, err := addTopicByNameToRepo(db.GetEngine(ctx), generateRepo.ID, topic); err != nil { - return err - } - } - return nil -} - -// GenerateGitHooks generates git hooks from a template repository -func GenerateGitHooks(ctx context.Context, templateRepo, generateRepo *repo_model.Repository) error { - generateGitRepo, err := git.OpenRepository(generateRepo.RepoPath()) - if err != nil { - return err - } - defer generateGitRepo.Close() - - templateGitRepo, err := git.OpenRepository(templateRepo.RepoPath()) - if err != nil { - return err - } - defer templateGitRepo.Close() - - templateHooks, err := templateGitRepo.Hooks() - if err != nil { - return err - } - - for _, templateHook := range templateHooks { - generateHook, err := generateGitRepo.GetHook(templateHook.Name()) - if err != nil { - return err - } - - generateHook.Content = templateHook.Content - if err := generateHook.Update(); err != nil { - return err - } - } - return nil -} - // GenerateWebhooks generates webhooks from a template repository func GenerateWebhooks(ctx context.Context, templateRepo, generateRepo *repo_model.Repository) error { templateWebhooks, err := webhook.ListWebhooksByOpts(&webhook.ListWebhookOptions{RepoID: templateRepo.ID}) @@ -141,16 +95,6 @@ func GenerateWebhooks(ctx context.Context, templateRepo, generateRepo *repo_mode return nil } -// GenerateAvatar generates the avatar from a template repository -func GenerateAvatar(ctx context.Context, templateRepo, generateRepo *repo_model.Repository) error { - generateRepo.Avatar = strings.Replace(templateRepo.Avatar, strconv.FormatInt(templateRepo.ID, 10), strconv.FormatInt(generateRepo.ID, 10), 1) - if _, err := storage.Copy(storage.RepoAvatars, generateRepo.CustomAvatarRelativePath(), storage.RepoAvatars, templateRepo.CustomAvatarRelativePath()); err != nil { - return err - } - - return updateRepositoryCols(db.GetEngine(ctx), generateRepo, "avatar") -} - // GenerateIssueLabels generates issue labels from a template repository func GenerateIssueLabels(ctx context.Context, templateRepo, generateRepo *repo_model.Repository) error { templateLabels, err := getLabelsByRepoID(db.GetEngine(ctx), templateRepo.ID, "", db.ListOptions{}) |