diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2023-07-21 12:32:47 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-21 12:32:47 +0800 |
commit | 037c9895a7406b42f88991295382db18f98dbef9 (patch) | |
tree | d3d893d77c082f629219d386c9cf6a45dc958f84 /modules | |
parent | 2b6f2243366b6640a4a322b33b419445c710cba9 (diff) | |
download | gitea-037c9895a7406b42f88991295382db18f98dbef9.tar.gz gitea-037c9895a7406b42f88991295382db18f98dbef9.zip |
Support copy protected branch from template repository (#25889)
Fix #14303
Diffstat (limited to 'modules')
-rw-r--r-- | modules/repository/generate.go | 24 | ||||
-rw-r--r-- | modules/structs/repo.go | 2 |
2 files changed, 15 insertions, 11 deletions
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 |