Copy branch configuration from the template #6666

Closed
opened 2025-11-02 07:03:06 -06:00 by GiteaMirror · 19 comments
Owner

Originally created by @tomaswarynyca on GitHub (Jan 11, 2021).

Description

Having a configuration for the main branch in a template should be copied when one creates a repository from that template.
This was discussed at the time in #9126 but it was left abandoned, I create these issues to see if it can be reactivated because it is a functionality that is very useful to devops.

Originally created by @tomaswarynyca on GitHub (Jan 11, 2021). ## Description Having a configuration for the main branch in a template should be copied when one creates a repository from that template. This was discussed at the time in #9126 but it was left abandoned, I create these issues to see if it can be reactivated because it is a functionality that is very useful to devops.
GiteaMirror added the type/enhancementtype/proposal labels 2025-11-02 07:03:06 -06:00
Author
Owner

@zeripath commented on GitHub (Jan 12, 2021):

are you sure that this is not already the case following #10803?

@zeripath commented on GitHub (Jan 12, 2021): are you sure that this is not already the case following #10803?
Author
Owner

@tomaswarynyca commented on GitHub (Jan 12, 2021):

I refer to the Branch Protection configuration. I have a template repository with x rules in the main branch, when I create a repository based on the template and copy the branch, the protection settings of that branch must be copied to the new repository.

@tomaswarynyca commented on GitHub (Jan 12, 2021): I refer to the Branch Protection configuration. I have a template repository with x rules in the main branch, when I create a repository based on the template and copy the branch, the protection settings of that branch must be copied to the new repository.
Author
Owner

@jolheiser commented on GitHub (Jan 13, 2021):

Hello! I am currently working on this (and I will re-open #9126, I forgot to keep the stalebot away 😓 )

One caveat is whitelisted users/teams, as those could be infeasible depending on who is using the template and what type of access they have compared to the template owner.
For the initial version I don't think those will be carried over.
Some fancy code could probably determine an intersection of valid values, but that's likely more complex than necessary.
A follow-up could be made to add the intersection, if needed. 🙂

@jolheiser commented on GitHub (Jan 13, 2021): Hello! I am currently working on this (and I will re-open #9126, I forgot to keep the stalebot away 😓 ) One caveat is whitelisted users/teams, as those could be infeasible depending on who is using the template and what type of access they have compared to the template owner. For the initial version I don't think those will be carried over. Some fancy code could probably determine an intersection of valid values, but that's likely more complex than necessary. A follow-up could be made to add the intersection, if needed. 🙂
Author
Owner

@lunny commented on GitHub (Jan 13, 2021):

You can read the template repositories, but maybe you have no permissions knows how the protected branches configured because this is a feature of owners of that repository.

@jolheiser I think this is a point we should be careful.

@lunny commented on GitHub (Jan 13, 2021): You can read the template repositories, but maybe you have no permissions knows how the protected branches configured because this is a feature of owners of that repository. @jolheiser I think this is a point we should be careful.
Author
Owner

@tomaswarynyca commented on GitHub (Jan 13, 2021):

Not all should be copied, but the main protected files, required approvals, status check, among others.
Captura de pantalla_área-de-selección_20210113142343

@tomaswarynyca commented on GitHub (Jan 13, 2021): Not all should be copied, but the main protected files, required approvals, status check, among others. ![Captura de pantalla_área-de-selección_20210113142343](https://user-images.githubusercontent.com/41587659/104487073-66f47f00-55ab-11eb-92b6-58f4709656d6.png)
Author
Owner

@tomaswarynyca commented on GitHub (Jan 27, 2021):

Hi, I saw that the pr was already made but was abandoned, it is a tool that I need at work, is it possible to implement it now?

@tomaswarynyca commented on GitHub (Jan 27, 2021): Hi, I saw that the pr was already made but was abandoned, it is a tool that I need at work, is it possible to implement it now?
Author
Owner

@jolheiser commented on GitHub (Jan 27, 2021):

What makes you think #14334 is abandoned? 🤔

@jolheiser commented on GitHub (Jan 27, 2021): What makes you think #14334 is abandoned? 🤔
Author
Owner

@tomaswarynyca commented on GitHub (Jan 27, 2021):

What makes you think #14334 is abandoned?

The last commit was 13 days ago, I thought it was already finished
As I had no news about the pr or issues I decided to send the message

@tomaswarynyca commented on GitHub (Jan 27, 2021): > What makes you think #14334 is abandoned? The last commit was 13 days ago, I thought it was already finished As I had no news about the pr or issues I decided to send the message
Author
Owner

@jolheiser commented on GitHub (Jan 27, 2021):

We are currently in a freeze to get 1.14 polished up, and the reference PR is slated for 1.15 as a result.
It may take a while for it to get reviewed. 🙂

@jolheiser commented on GitHub (Jan 27, 2021): We are currently in a freeze to get 1.14 polished up, and the reference PR is slated for 1.15 as a result. It may take a while for it to get reviewed. 🙂
Author
Owner

@tomaswarynyca commented on GitHub (Jan 29, 2021):

When is it planned to release the final v1.14 to start with v1.15?
I'm sorry if I'm pushing too hard, but I'm needing the function for several projects at work.

@tomaswarynyca commented on GitHub (Jan 29, 2021): When is it planned to release the final v1.14 to start with v1.15? I'm sorry if I'm pushing too hard, but I'm needing the function for several projects at work.
Author
Owner

@jolheiser commented on GitHub (Jan 29, 2021):

Unfortunately it's very hard to pin down a day. We are entirely run by volunteer time, so the best we can do is a general timeframe.

The milestone for 1.14 is past due by 4 days (at time of this writing), however there will still need to be RCs prior to a stable release, etc.

If you are needing this sooner than later, I would suggest instead writing a script to copy branch protection from one repo to another in the interim.
You can use the API to get branch protection from a repo, and then use the API to create branch protection for another repo.

@jolheiser commented on GitHub (Jan 29, 2021): Unfortunately it's very hard to pin down a day. We are entirely run by volunteer time, so the best we can do is a general timeframe. The milestone for [1.14](https://github.com/go-gitea/gitea/milestone/76) is past due by 4 days (at time of this writing), however there will still need to be RCs prior to a stable release, etc. If you are needing this sooner than later, I would suggest instead writing a script to copy branch protection from one repo to another in the interim. You can use the API to [get branch protection](https://try.gitea.io/api/swagger#/repository/repoGetBranchProtection) from a repo, and then use the API to [create branch protection](https://try.gitea.io/api/swagger#/repository/repoCreateBranchProtection) for another repo.
Author
Owner

@tomaswarynyca commented on GitHub (Jan 30, 2021):

Ohh great I hadn't considered the option of using the API.
So thanks for the functionality and I look forward to v1.15 to try it out.

@tomaswarynyca commented on GitHub (Jan 30, 2021): Ohh great I hadn't considered the option of using the API. So thanks for the functionality and I look forward to v1.15 to try it out.
Author
Owner

@ztrnr commented on GitHub (Sep 12, 2022):

@tomaswarynyca have you created this script? I'm looking for the same functionality at my work.

@ztrnr commented on GitHub (Sep 12, 2022): @tomaswarynyca have you created this script? I'm looking for the same functionality at my work.
Author
Owner

@GregJCook commented on GitHub (Oct 26, 2022):

I just stumbled across this missing feature as well. Any update on getting branch protection policies to carry forward from a template?

@GregJCook commented on GitHub (Oct 26, 2022): I just stumbled across this missing feature as well. Any update on getting branch protection policies to carry forward from a template?
Author
Owner

@Calvin-Hill commented on GitHub (Jan 11, 2023):

Is this still in the works? Just stumbled on this issue when creating a repo from my template and realising none of my branch protection rules had copied over

@Calvin-Hill commented on GitHub (Jan 11, 2023): Is this still in the works? Just stumbled on this issue when creating a repo from my template and realising none of my branch protection rules had copied over
Author
Owner

@Barsay commented on GitHub (Mar 6, 2023):

Any news on this? same as @Calvin-Hill , found this while setting up a template

@Barsay commented on GitHub (Mar 6, 2023): Any news on this? same as @Calvin-Hill , found this while setting up a template
Author
Owner

@w4dd325 commented on GitHub (Jul 7, 2023):

Any further developments on this? Interested to get this setup...

@w4dd325 commented on GitHub (Jul 7, 2023): Any further developments on this? Interested to get this setup...
Author
Owner

@fuzunspm commented on GitHub (Jul 10, 2023):

this is a must have feature. I would like to copy master/main rule set from a repository to all other repositories

@fuzunspm commented on GitHub (Jul 10, 2023): this is a must have feature. I would like to copy master/main rule set from a repository to all other repositories
Author
Owner

@lmandon commented on GitHub (Jul 18, 2023):

Hello,
This would be beneficial to our teams as well, looking forward to the implementation.

@lmandon commented on GitHub (Jul 18, 2023): Hello, This would be beneficial to our teams as well, looking forward to the implementation.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#6666