Skip to content

Commit c25c519

Browse files
committed
clean: remove unused loader funcs
1 parent 4fa47ae commit c25c519

File tree

2 files changed

+0
-60
lines changed

2 files changed

+0
-60
lines changed

pkg/config/action.go

-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ func (actions Actions) Evaluate(evalContext scm.EvalContext) ([]Action, error) {
2929
return results, nil
3030
}
3131

32-
type ActionStep = scm.EvaluationActionStep
33-
3432
type Action scm.EvaluationActionResult
3533

3634
func (p *Action) Evaluate(evalContext scm.EvalContext) (bool, error) {

pkg/config/loader.go

-58
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,12 @@ package config
22

33
import (
44
"bytes"
5-
"errors"
65
"io"
7-
"io/fs"
86
"os"
9-
"os/exec"
10-
"path/filepath"
11-
"strings"
127

138
"gopkg.in/yaml.v3"
149
)
1510

16-
// LoadFileFromStandardLocation loads and parses a GITLAB_LABELS file at one of the
17-
// standard locations for GITLAB_LABELS files (./, .github/, docs/). If run from a
18-
// git repository, all paths are relative to the repository root.
19-
func LoadFileFromStandardLocation() (*Config, error) {
20-
path := findFileAtStandardLocation()
21-
if path == "" {
22-
return nil, errors.New("could not find GITLAB_LABELS file at any of the standard locations")
23-
}
24-
25-
return LoadFile(path)
26-
}
27-
2811
// LoadFile loads and parses a GITLAB_LABELS file at the path specified.
2912
func LoadFile(path string) (*Config, error) {
3013
f, err := os.Open(path)
@@ -35,47 +18,6 @@ func LoadFile(path string) (*Config, error) {
3518
return ParseFile(f)
3619
}
3720

38-
func findFileAtStandardLocation() string {
39-
pathPrefix := ""
40-
41-
repoRoot, inRepo := findRepositoryRoot()
42-
if inRepo {
43-
pathPrefix = repoRoot
44-
}
45-
46-
for _, path := range []string{".scm-engine.yml", ".gitlab/scm-engine.yml", ".github/scm-engine.yml"} {
47-
fullPath := filepath.Join(pathPrefix, path)
48-
49-
if fileExists(fullPath) {
50-
return fullPath
51-
}
52-
}
53-
54-
return ""
55-
}
56-
57-
// fileExist checks if a normal file exists at the path specified.
58-
func fileExists(path string) bool {
59-
info, err := os.Stat(path)
60-
if errors.Is(err, fs.ErrNotExist) {
61-
return false
62-
}
63-
64-
return !info.IsDir()
65-
}
66-
67-
// findRepositoryRoot returns the path to the root of the git repository, if
68-
// we're currently in one. If we're not in a git repository, the boolean return
69-
// value is false.
70-
func findRepositoryRoot() (string, bool) {
71-
output, err := exec.Command("git", "rev-parse", "--show-toplevel").Output()
72-
if err != nil {
73-
return "", false
74-
}
75-
76-
return strings.TrimSpace(string(output)), true
77-
}
78-
7921
// ParseFile parses a Gitlabber file, returning a Config.
8022
func ParseFile(f io.Reader) (*Config, error) {
8123
config := &Config{}

0 commit comments

Comments
 (0)