Skip to content

Project File Templates

What does this MR do?

In creating a new file, Gitlab offers templates for Dockerfile, .gitignore, .gitlab-ci.yml and LICENSE. This MR allows the user to add a new file based on a custom template defined in the repository. This is similar to issue and merge request templates (like this one).

The template files are read from the .gitlab/file_templates folder in the repository.

Are there points in the code the reviewer needs to double check?

To allow this feature to work for additional use-cases beyond my imagination, the file extension restriction has been lifted and the file extension is seen in the project file template dropdown menu.

In order to do this, this MR removes the format from the template_controller.rb and passes the extension to each of the existing global and repo template finders. Is this the correct way to do this?

Why was this MR needed?

We use Gitlab to run and generate a static blog site using the Hexo.io framework. The entire process of adding a new blog post can be performed online using Gitlab however when creating the new file for the post, users were manually copying the metadata (Hexo front-matter) from another post first. This MR allows us to load a template into Gitlab and allow the user to select it from the template menu.

Screenshots (if relevant)

image

Does this MR meet the acceptance criteria?

What are the relevant issue numbers?

Merge request reports