Skip to content

Commit

Permalink
refactor: remvoe GetRepoInitFile
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfogre committed Mar 8, 2023
1 parent 7f39e27 commit aa61e0c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 50 deletions.
6 changes: 3 additions & 3 deletions modules/label/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ func (err ErrTemplateLoad) Error() string {
// GetTemplateFile loads the label template file by given name,
// then parses and returns a list of name-color pairs and optionally description.
func GetTemplateFile(name string) ([]*Label, error) {
data, err := options.GetRepoInitFile("label", name+".yaml")
data, err := options.Labels(name + ".yaml")
if err == nil && len(data) > 0 {
return parseYamlFormat(name+".yaml", data)
}

data, err = options.GetRepoInitFile("label", name+".yml")
data, err = options.Labels(name + ".yml")
if err == nil && len(data) > 0 {
return parseYamlFormat(name+".yml", data)
}

data, err = options.GetRepoInitFile("label", name)
data, err = options.Labels(name)
if err != nil {
return nil, ErrTemplateLoad{name, fmt.Errorf("GetRepoInitFile: %w", err)}
}
Expand Down
44 changes: 0 additions & 44 deletions modules/options/repo.go

This file was deleted.

6 changes: 3 additions & 3 deletions modules/repository/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func prepareRepoCommit(ctx context.Context, repo *repo_model.Repository, tmpDir,
}

// README
data, err := options.GetRepoInitFile("readme", opts.Readme)
data, err := options.Readme(opts.Readme)
if err != nil {
return fmt.Errorf("GetRepoInitFile[%s]: %w", opts.Readme, err)
}
Expand Down Expand Up @@ -164,7 +164,7 @@ func prepareRepoCommit(ctx context.Context, repo *repo_model.Repository, tmpDir,
var buf bytes.Buffer
names := strings.Split(opts.Gitignores, ",")
for _, name := range names {
data, err = options.GetRepoInitFile("gitignore", name)
data, err = options.Gitignore(name)
if err != nil {
return fmt.Errorf("GetRepoInitFile[%s]: %w", name, err)
}
Expand All @@ -182,7 +182,7 @@ func prepareRepoCommit(ctx context.Context, repo *repo_model.Repository, tmpDir,

// LICENSE
if len(opts.License) > 0 {
data, err = options.GetRepoInitFile("license", opts.License)
data, err = options.License(opts.License)
if err != nil {
return fmt.Errorf("GetRepoInitFile[%s]: %w", opts.License, err)
}
Expand Down

0 comments on commit aa61e0c

Please sign in to comment.