From 037c9895a7406b42f88991295382db18f98dbef9 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Fri, 21 Jul 2023 12:32:47 +0800 Subject: Support copy protected branch from template repository (#25889) Fix #14303 --- modules/repository/generate.go | 24 +++++++++++++----------- modules/structs/repo.go | 2 ++ 2 files changed, 15 insertions(+), 11 deletions(-) (limited to 'modules') diff --git a/modules/repository/generate.go b/modules/repository/generate.go index cb25daa10b..2e0b7600a5 100644 --- a/modules/repository/generate.go +++ b/modules/repository/generate.go @@ -303,21 +303,23 @@ func GenerateGitContent(ctx context.Context, templateRepo, generateRepo *repo_mo // GenerateRepoOptions contains the template units to generate type GenerateRepoOptions struct { - Name string - DefaultBranch string - Description string - Private bool - GitContent bool - Topics bool - GitHooks bool - Webhooks bool - Avatar bool - IssueLabels bool + Name string + DefaultBranch string + Description string + Private bool + GitContent bool + Topics bool + GitHooks bool + Webhooks bool + Avatar bool + IssueLabels bool + ProtectedBranch bool } // IsValid checks whether at least one option is chosen for generation func (gro GenerateRepoOptions) IsValid() bool { - return gro.GitContent || gro.Topics || gro.GitHooks || gro.Webhooks || gro.Avatar || gro.IssueLabels // or other items as they are added + return gro.GitContent || gro.Topics || gro.GitHooks || gro.Webhooks || gro.Avatar || + gro.IssueLabels || gro.ProtectedBranch // or other items as they are added } // GenerateRepository generates a repository from a template diff --git a/modules/structs/repo.go b/modules/structs/repo.go index af439ad730..6a2ba4836b 100644 --- a/modules/structs/repo.go +++ b/modules/structs/repo.go @@ -238,6 +238,8 @@ type GenerateRepoOption struct { Avatar bool `json:"avatar"` // include labels in template repo Labels bool `json:"labels"` + // include protected branches in template repo + ProtectedBranch bool `json:"protected_branch"` } // CreateBranchRepoOption options when creating a branch in a repository -- cgit v1.2.3