aboutsummaryrefslogtreecommitdiffstats
path: root/services/repository
diff options
context:
space:
mode:
authordelvh <dev.lh@web.de>2024-07-09 20:05:12 +0200
committerGitHub <noreply@github.com>2024-07-09 18:05:12 +0000
commit7bb38358114ef7f55ee9f56838df74f1dda969aa (patch)
treeb34fb0240befc15259b7f7ca5507ee8e3fcc3fd6 /services/repository
parent1ee59f0fa326685a7e4bc39f213b7894b37d8101 (diff)
downloadgitea-7bb38358114ef7f55ee9f56838df74f1dda969aa.tar.gz
gitea-7bb38358114ef7f55ee9f56838df74f1dda969aa.zip
Add `YEAR`, `MONTH`, `MONTH_ENGLISH`, `DAY` variables for template repos (#31584)
Fixes #31583
Diffstat (limited to 'services/repository')
-rw-r--r--services/repository/generate.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/services/repository/generate.go b/services/repository/generate.go
index 9b09e271ab..2b95bbcd4d 100644
--- a/services/repository/generate.go
+++ b/services/repository/generate.go
@@ -12,6 +12,7 @@ import (
"path"
"path/filepath"
"regexp"
+ "strconv"
"strings"
"time"
@@ -52,7 +53,12 @@ var defaultTransformers = []transformer{
}
func generateExpansion(src string, templateRepo, generateRepo *repo_model.Repository, sanitizeFileName bool) string {
+ year, month, day := time.Now().Date()
expansions := []expansion{
+ {Name: "YEAR", Value: strconv.Itoa(year), Transformers: nil},
+ {Name: "MONTH", Value: fmt.Sprintf("%02d", int(month)), Transformers: nil},
+ {Name: "MONTH_ENGLISH", Value: month.String(), Transformers: defaultTransformers},
+ {Name: "DAY", Value: fmt.Sprintf("%02d", day), Transformers: nil},
{Name: "REPO_NAME", Value: generateRepo.Name, Transformers: defaultTransformers},
{Name: "TEMPLATE_NAME", Value: templateRepo.Name, Transformers: defaultTransformers},
{Name: "REPO_DESCRIPTION", Value: generateRepo.Description, Transformers: nil},