Skip to content

Commit 6d2fb97

Browse files
committed
setup linting configuration
1 parent 1a62188 commit 6d2fb97

File tree

8 files changed

+103
-18
lines changed

8 files changed

+103
-18
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# These are supported funding model platforms
22

33
github: teaglebuilt
4+
buy_me_a_coffee: teaglebuilt

.github/workflows/release.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
name: Release Workflow
3+
4+
on:
5+
push:
6+
tags:
7+
- "v*.*.*"
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
release:
14+
name: Build & Release GH CLI Extension
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout Code
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Setup Go
23+
uses: actions/setup-go@v5
24+
with:
25+
go-version: stable
26+
27+
- name: Generate Changelog
28+
id: changelog
29+
uses: mikepenz/[email protected]
30+
with:
31+
configuration: |
32+
categories:
33+
- title: "🚀 Features"
34+
labels:
35+
- feature
36+
- title: "🐛 Fixes"
37+
labels:
38+
- fix
39+
- title: "📖 Documentation"
40+
labels:
41+
- docs
42+
- title: "🧰 Maintenance"
43+
labels:
44+
- chore
45+
- ci
46+
- refactor
47+
template: |
48+
## What's Changed
49+
$CHANGES
50+
pr_template: "- #$NUMBER $TITLE @$AUTHOR"
51+
outputFile: CHANGELOG.md
52+
env:
53+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
55+
- name: Precompile GH Extension
56+
uses: cli/gh-extension-precompile@v2
57+
with:
58+
go-version: stable
59+
binary-name: 'gh-subrepo'
60+
61+
- name: Create GitHub Release
62+
uses: softprops/action-gh-release@v2
63+
with:
64+
name: Release ${{ github.ref_name }}
65+
tag_name: ${{ github.ref }}
66+
body_path: CHANGELOG.md
67+
files: dist/*

.golangci.yaml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
---
2+
version: "2"
3+
24
linters:
35
enable:
46
- bodyclose
5-
- depguard
6-
- errorlint
77
- copyloopvar
88
- importas
9-
- gci
10-
- gofumpt
119
- gocritic
12-
- gosec
1310
- govet
1411
- misspell
15-
- revive
16-
- stylecheck
17-
- testifylint
1812
- unconvert
13+
# - errorlint
14+
# - depguard
15+
# - gosec
16+
# - testifylint
17+
# - revive
1918

2019
formatters:
2120
enable:
22-
- gci
2321
- gofmt
2422
- gofumpt
2523
- goimports

.vscode/settings.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"gopls": {
3+
"ui.semanticTokens": true,
4+
"formatting.gofumpt": true
5+
},
6+
"[go]": {
7+
"editor.formatOnSave": true
8+
}
9+
}

cmd/clone/clone.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ func CloneCmd() *cobra.Command {
2222

2323
func cloneRepository(cmd *cobra.Command, args []string) {
2424
repoURL := args[0]
25-
subdir := "."
25+
var subdir string
26+
2627
if len(args) == 2 {
2728
subdir = args[1]
2829
} else {

cmd/pull/pull.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@ func PullCmd() *cobra.Command {
4141
fmt.Printf("Failed to create temp dir: %v\n", err)
4242
os.Exit(1)
4343
}
44-
defer os.RemoveAll(tmpDir)
44+
45+
defer func() {
46+
if err := os.RemoveAll(tmpDir); err != nil {
47+
fmt.Printf("Warning: failed to remove tmp dir: %v\n", err)
48+
}
49+
}()
4550

4651
fmt.Printf("Pulling latest changes from %s...\n", remote)
4752
if err := utils.ExecCmd("", "git", "clone", "--depth=1", "-b", branch, remote, tmpDir); err != nil {

cmd/status/status.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func StatusCmd() *cobra.Command {
3131
}
3232

3333
for _, subdir := range subdirs {
34-
checkStatus(repoRoot, subdir)
34+
checkStatus(subdir)
3535
}
3636
},
3737
}
@@ -40,16 +40,19 @@ func StatusCmd() *cobra.Command {
4040

4141
func findAllSubrepos(root string) []string {
4242
var dirs []string
43-
filepath.WalkDir(root, func(path string, d os.DirEntry, err error) error {
43+
err := filepath.WalkDir(root, func(path string, d os.DirEntry, err error) error {
4444
if filepath.Base(path) == ".gitrepo" {
4545
dirs = append(dirs, filepath.Dir(path))
4646
}
4747
return nil
4848
})
49+
if err != nil {
50+
fmt.Printf("Error walking directory: %v\n", err)
51+
}
4952
return dirs
5053
}
5154

52-
func checkStatus(repoRoot, subdir string) {
55+
func checkStatus(subdir string) {
5356
gitrepoFile := filepath.Join(subdir, ".gitrepo")
5457

5558
cfg, err := ini.Load(gitrepoFile)
@@ -91,5 +94,5 @@ func execCommandOutput(dir, name string, args ...string) (string, error) {
9194
if err != nil {
9295
return "", err
9396
}
94-
return string(output[:40]), nil // 40-char hash
97+
return string(output[:40]), nil
9598
}

cmd/status/status_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ func TestStatusCmd_Integration(t *testing.T) {
3636
setupGitConfig(t, tmpWork)
3737

3838
readmePath := filepath.Join(tmpWork, "README.md")
39-
os.WriteFile(readmePath, []byte("Initial remote content"), 0644)
39+
assert.NoError(t, os.WriteFile(readmePath, []byte("Initial remote content"), 0644))
40+
4041
assert.NoError(t, utils.ExecCmd(tmpWork, "git", "add", "."))
4142
assert.NoError(t, utils.ExecCmd(tmpWork, "git", "commit", "-m", "Initial commit"))
4243
assert.NoError(t, utils.ExecCmd(tmpWork, "git", "push", "-u", "origin", "main"))
@@ -52,13 +53,13 @@ func TestStatusCmd_Integration(t *testing.T) {
5253
assert.NoError(t, utils.ExecCmd(rootDir, "git", "add", "."))
5354
assert.NoError(t, utils.ExecCmd(rootDir, "git", "commit", "-m", "Add subrepo"))
5455

55-
checkStatus(rootDir, subrepoPath)
56+
checkStatus(subrepoPath)
5657

5758
changelogPath := filepath.Join(tmpWork, "CHANGELOG.md")
5859
os.WriteFile(changelogPath, []byte("Changelog added"), 0644)
5960
assert.NoError(t, utils.ExecCmd(tmpWork, "git", "add", "."))
6061
assert.NoError(t, utils.ExecCmd(tmpWork, "git", "commit", "-m", "Add CHANGELOG"))
6162
assert.NoError(t, utils.ExecCmd(tmpWork, "git", "push", "origin", "main"))
6263

63-
checkStatus(rootDir, subrepoPath)
64+
checkStatus(subrepoPath)
6465
}

0 commit comments

Comments
 (0)