You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

template-repositories.md 3.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. ---
  2. date: "2019-11-28:00:00+02:00"
  3. title: "Template Repositories"
  4. slug: "template-repositories"
  5. weight: 14
  6. toc: true
  7. draft: false
  8. menu:
  9. sidebar:
  10. parent: "usage"
  11. name: "Template Repositories"
  12. weight: 14
  13. identifier: "template-repositories"
  14. ---
  15. ## Template Repositories
  16. Gitea `1.11.0` and above includes template repositories, and one feature implemented with them is auto-expansion of specific variables within your template files.
  17. To tell Gitea which files to expand, you must include a `template` file inside the `.gitea` directory of the template repository.
  18. 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.
  19. ### Example `.gitea/template` file
  20. All paths are relative to the base of the repository
  21. ```gitignore
  22. # All .go files, anywhere in the repository
  23. **.go
  24. # All text files in the text directory
  25. text/*.txt
  26. # A specific file
  27. a/b/c/d.json
  28. # Batch files in both upper or lower case can be matched
  29. **.[bB][aA][tT]
  30. ```
  31. **NOTE:** The `template` file will be removed from the `.gitea` directory when a repository is generated from the template.
  32. ### Variable Expansion
  33. In any file matched by the above globs, certain variables will be expanded.
  34. All variables must be of the form `$VAR` or `${VAR}`. To escape an expansion, use a double `$$`, such as `$$VAR` or `$${VAR}`
  35. | Variable | Expands To | Transformable |
  36. |----------------------|-----------------------------------------------------|---------------|
  37. | REPO_NAME | The name of the generated repository | ✓ |
  38. | TEMPLATE_NAME | The name of the template repository | ✓ |
  39. | REPO_DESCRIPTION | The description of the generated repository | ✘ |
  40. | TEMPLATE_DESCRIPTION | The description of the template repository | ✘ |
  41. | REPO_OWNER | The owner of the generated repository | ✓ |
  42. | TEMPLATE_OWNER | The owner of the template repository | ✓ |
  43. | REPO_LINK | The URL to the generated repository | ✘ |
  44. | TEMPLATE_LINK | The URL to the template repository | ✘ |
  45. | REPO_HTTPS_URL | The HTTP(S) clone link for the generated repository | ✘ |
  46. | TEMPLATE_HTTPS_URL | The HTTP(S) clone link for the template repository | ✘ |
  47. | REPO_SSH_URL | The SSH clone link for the generated repository | ✘ |
  48. | TEMPLATE_SSH_URL | The SSH clone link for the template repository | ✘ |
  49. ### Transformers :robot:
  50. Gitea `1.12.0` adds a few transformers to some of the applicable variables above.
  51. For example, to get `REPO_NAME` in `PASCAL`-case, your template would use `${REPO_NAME_PASCAL}`
  52. Feeding `go-sdk` to the available transformers yields...
  53. | Transformer | Effect |
  54. |-------------|------------|
  55. | SNAKE | go_sdk |
  56. | KEBAB | go-sdk |
  57. | CAMEL | goSdk |
  58. | PASCAL | GoSdk |
  59. | LOWER | go-sdk |
  60. | UPPER | GO-SDK |
  61. | TITLE | Go-Sdk |