gitea
gitea copied to clipboard
Copy branch configuration from the template
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.
are you sure that this is not already the case following #10803?
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.
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. 🙂
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.
Not all should be copied, but the main protected files, required approvals, status check, among others.

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?
What makes you think #14334 is abandoned? 🤔
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
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. 🙂
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.
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.
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 have you created this script? I'm looking for the same functionality at my work.
I just stumbled across this missing feature as well. Any update on getting branch protection policies to carry forward from a template?
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
Any news on this? same as @Calvin-Hill , found this while setting up a template
Any further developments on this? Interested to get this setup...
this is a must have feature. I would like to copy master/main rule set from a repository to all other repositories
Hello, This would be beneficial to our teams as well, looking forward to the implementation.