code.gitea.io/gitea@v1.22.3/docs/content/usage/template-repositories.en-us.md (about) 1 --- 2 date: "2019-11-28:00:00+02:00" 3 title: "Template Repositories" 4 slug: "template-repositories" 5 sidebar_position: 14 6 toc: false 7 draft: false 8 aliases: 9 - /en-us/template-repositories 10 menu: 11 sidebar: 12 parent: "usage" 13 name: "Template Repositories" 14 sidebar_position: 14 15 identifier: "template-repositories" 16 --- 17 18 # Template Repositories 19 20 Gitea (starting with version `1.11.0`) supports creating template repositories 21 which can be used to generate repositories based on the template, complete with 22 variable expansion of certain pre-defined variables. 23 24 All files in the template repository are included in a generated repository from the 25 template except for the `.gitea/template` file. The `.gitea/template` file tells 26 Gitea which files are subject to the variable expansion when creating a 27 repository from the template. 28 29 Gitea uses [gobwas/glob](https://github.com/gobwas/glob) for its glob syntax. It closely resembles a traditional `.gitignore`, however there may be slight differences. 30 31 ## Example `.gitea/template` file 32 33 All paths are relative to the base of the repository 34 35 ```gitignore 36 # Expand all .go files, anywhere in the repository 37 **.go 38 39 # All text files in the text directory 40 text/*.txt 41 42 # A specific file 43 a/b/c/d.json 44 45 # Batch files in both upper or lower case can be matched 46 **.[bB][aA][tT] 47 ``` 48 49 ## Variable Expansion 50 51 In any file matched by the above globs, certain variables will be expanded. 52 53 Matching filenames and paths can also be expanded, and are conservatively sanitized to support cross-platform filesystems. 54 55 All variables must be of the form `$VAR` or `${VAR}`. To escape an expansion, use a double `$$`, such as `$$VAR` or `$${VAR}` 56 57 | Variable | Expands To | Transformable | 58 | -------------------- | --------------------------------------------------- | ------------- | 59 | REPO_NAME | The name of the generated repository | ✓ | 60 | TEMPLATE_NAME | The name of the template repository | ✓ | 61 | REPO_DESCRIPTION | The description of the generated repository | ✘ | 62 | TEMPLATE_DESCRIPTION | The description of the template repository | ✘ | 63 | REPO_OWNER | The owner of the generated repository | ✓ | 64 | TEMPLATE_OWNER | The owner of the template repository | ✓ | 65 | REPO_LINK | The URL to the generated repository | ✘ | 66 | TEMPLATE_LINK | The URL to the template repository | ✘ | 67 | REPO_HTTPS_URL | The HTTP(S) clone link for the generated repository | ✘ | 68 | TEMPLATE_HTTPS_URL | The HTTP(S) clone link for the template repository | ✘ | 69 | REPO_SSH_URL | The SSH clone link for the generated repository | ✘ | 70 | TEMPLATE_SSH_URL | The SSH clone link for the template repository | ✘ | 71 72 ## Transformers :robot: 73 74 Gitea `1.12.0` adds a few transformers to some of the applicable variables above. 75 76 For example, to get `REPO_NAME` in `PASCAL`-case, your template would use `${REPO_NAME_PASCAL}` 77 78 Feeding `go-sdk` to the available transformers yields... 79 80 | Transformer | Effect | 81 | ----------- | ------ | 82 | SNAKE | go_sdk | 83 | KEBAB | go-sdk | 84 | CAMEL | goSdk | 85 | PASCAL | GoSdk | 86 | LOWER | go-sdk | 87 | UPPER | GO-SDK | 88 | TITLE | Go-Sdk |