Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions modules/repository/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"path"
"path/filepath"
"sort"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -282,6 +283,18 @@ func prepareRepoCommit(ctx context.Context, repo *repo_model.Repository, tmpDir,
// LICENSE
if len(opts.License) > 0 {
data, err = GetRepoInitFile("license", opts.License)

// Replace Placeholders in License
data = bytes.ReplaceAll(data, []byte("<program>"), []byte(repo.Name))
data = bytes.ReplaceAll(data, []byte("[NAME]"), []byte(repo.OwnerName))
data = bytes.ReplaceAll(data, []byte("<owner>"), []byte(repo.OwnerName))
data = bytes.ReplaceAll(data, []byte("<name of author>"), []byte(repo.OwnerName))
data = bytes.ReplaceAll(data, []byte("<copyright holders>"), []byte(repo.OwnerName))
data = bytes.ReplaceAll(data, []byte("<year>"), []byte(strconv.Itoa(time.Now().Year())))
data = bytes.ReplaceAll(data, []byte("[YEAR]"), []byte(strconv.Itoa(time.Now().Year())))
data = bytes.ReplaceAll(data, []byte("{YEAR}"), []byte(strconv.Itoa(time.Now().Year())))
data = bytes.ReplaceAll(data, []byte("<one line to give the program's name and a brief idea of what it does.>"), []byte(repo.Description))

if err != nil {
return fmt.Errorf("GetRepoInitFile[%s]: %w", opts.License, err)
}
Expand Down