Skip to content

Commit 0c56547

Browse files
committed
Fix linter issue
1 parent 769c4d1 commit 0c56547

1 file changed

Lines changed: 16 additions & 15 deletions

File tree

test/utils/git.go

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,61 +32,62 @@ func buildAuthURL(repoURL, username, password string) string {
3232
}
3333

3434
// InitializeRepoWithFunction creates a function project and pushes it to the Gitea repo
35-
func InitializeRepoWithFunction(repoURL, username, password, language string) (repoDir string, err error) {
35+
func InitializeRepoWithFunction(repoURL, username, password, language string) (string, error) {
3636
return InitializeRepoWithFunctionVersion(repoURL, username, password, language, "")
3737
}
3838

3939
// InitializeRepoWithFunctionVersion creates a function project with a specific func CLI version
4040
// If version is empty, uses the current func CLI
41-
func InitializeRepoWithFunctionVersion(repoURL, username, password, language, version string) (repoDir string, err error) {
42-
repoDir = fmt.Sprintf("%s/func-test-%s", os.TempDir(), rand.String(10))
41+
func InitializeRepoWithFunctionVersion(repoURL, username, password, language, version string) (string, error) {
42+
repoDir := fmt.Sprintf("%s/func-test-%s", os.TempDir(), rand.String(10))
4343

4444
// Build authenticated URL
4545
authURL := buildAuthURL(repoURL, username, password)
4646

4747
// Initialize function (func init creates the directory)
4848
if version == "" {
49-
_, err = RunFunc("init", "-l", language, repoDir)
49+
if _, err := RunFunc("init", "-l", language, repoDir); err != nil {
50+
return "", fmt.Errorf("failed to init function: %w", err)
51+
}
5052
} else {
51-
_, err = RunFuncWithVersion(version, "init", "-l", language, repoDir)
52-
}
53-
if err != nil {
54-
return "", fmt.Errorf("failed to init function: %w", err)
53+
if _, err := RunFuncWithVersion(version, "init", "-l", language, repoDir); err != nil {
54+
return "", fmt.Errorf("failed to init function: %w", err)
55+
}
5556
}
5657

5758
// Initialize git repo with main as default branch
5859
cmd := exec.Command("git", "-C", repoDir, "init", "-b", "main")
59-
if _, err = Run(cmd); err != nil {
60+
if _, err := Run(cmd); err != nil {
6061
return "", fmt.Errorf("failed to git init: %w", err)
6162
}
6263

6364
// Configure git user
6465
cmd = exec.Command("git", "-C", repoDir, "config", "user.name", "Test User")
65-
if _, err = Run(cmd); err != nil {
66+
if _, err := Run(cmd); err != nil {
6667
return "", fmt.Errorf("failed to set git user.name: %w", err)
6768
}
6869
cmd = exec.Command("git", "-C", repoDir, "config", "user.email", "test@example.com")
69-
if _, err = Run(cmd); err != nil {
70+
if _, err := Run(cmd); err != nil {
7071
return "", fmt.Errorf("failed to set git user.email: %w", err)
7172
}
7273

7374
// Add remote
7475
cmd = exec.Command("git", "-C", repoDir, "remote", "add", "origin", authURL)
75-
if _, err = Run(cmd); err != nil {
76+
if _, err := Run(cmd); err != nil {
7677
return "", fmt.Errorf("failed to add remote: %w", err)
7778
}
7879

7980
// Commit and push
8081
cmd = exec.Command("git", "-C", repoDir, "add", ".")
81-
if _, err = Run(cmd); err != nil {
82+
if _, err := Run(cmd); err != nil {
8283
return "", fmt.Errorf("failed to git add: %w", err)
8384
}
8485
cmd = exec.Command("git", "-C", repoDir, "commit", "-m", "Initial function")
85-
if _, err = Run(cmd); err != nil {
86+
if _, err := Run(cmd); err != nil {
8687
return "", fmt.Errorf("failed to git commit: %w", err)
8788
}
8889
cmd = exec.Command("git", "-C", repoDir, "push", "-u", "origin", "main")
89-
if _, err = Run(cmd); err != nil {
90+
if _, err := Run(cmd); err != nil {
9091
return "", fmt.Errorf("failed to push initial commit: %w", err)
9192
}
9293

0 commit comments

Comments
 (0)