Skip to content

Commit

Permalink
Add YEAR, MONTH, MONTH_ENGLISH, DAY variables for template re…
Browse files Browse the repository at this point in the history
  • Loading branch information
delvh authored Jul 9, 2024
1 parent 1ee59f0 commit 7bb3835
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions services/repository/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"path"
"path/filepath"
"regexp"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -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},
Expand Down

0 comments on commit 7bb3835

Please sign in to comment.