• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

gabyx / Githooks / 6711

20 Feb 2026 05:55PM UTC coverage: 78.823% (-0.2%) from 78.997%
6711

push

circleci

web-flow
chore: linting improvements (#184)

This change request performs comprehensive linting cleanup across the Githooks codebase, modernizing code style and fixing various linting issues. The changes standardize code patterns, improve error handling, and introduce a centralized linting configuration.

**Changes:**
- Added `run_docker` wrapper function to handle Docker commands with/without sudo based on CI environment + `podman`.
- Modernized Go code: replaced `interface{}` with `any`, improved defer patterns, standardized error handling, and cleaned up return statements
- Fixed spelling errors in comments and documentation.
- Added centralized `.golangci.yaml` configuration file and updated the pre-commit hook to use it.
- Run formatting over `treefmt` in the Nix shell.

282 of 426 new or added lines in 67 files covered. (66.2%)

29 existing lines in 20 files now uncovered.

9350 of 11862 relevant lines covered (78.82%)

1745.58 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

48.78
/githooks/container/executable.go
1
package container
2

3
import (
4
        cm "github.com/gabyx/githooks/githooks/common"
5
)
6

7
// ContainerizedExecutable contains the data to a script/executable file.
8
type ContainerizedExecutable struct {
9
        containerType ContainerManagerType
10

11
        Cmd string // The command.
12

13
        ArgsPre  []string // The pre arguments.
14
        ArgsEnv  []string // Arguments which set environment values inside the containerized run.
15
        ArgsPost []string // The post arguments.
16
}
17

18
// GetCommand gets the first command.
19
func (e *ContainerizedExecutable) GetCommand() string {
22✔
20
        return e.Cmd
22✔
21
}
22✔
22

23
// GetArgs gets all args.
24
func (e *ContainerizedExecutable) GetArgs(args ...string) (res []string) {
20✔
25
        res = cm.CopySliceC(e.ArgsPre, len(e.ArgsPre)+len(e.ArgsEnv)+len(e.ArgsPost)+len(args))
20✔
26
        res = append(res, e.ArgsEnv...)
20✔
27
        res = append(res, e.ArgsPost...)
20✔
28
        res = append(res, args...)
20✔
29

20✔
30
        return
20✔
31
}
20✔
32

33
// GetEnvironment gets all environment variables.
34
func (e *ContainerizedExecutable) GetEnvironment() []string {
12✔
35
        return nil
12✔
36
}
12✔
37

38
// ApplyEnvironmentToArgs applies all environment variables `env` to the arguments of
39
// the call to be able to forward them into the container.
40
func (e *ContainerizedExecutable) ApplyEnvironmentToArgs(env []string) {
8✔
41
        if e.containerType == ContainerManagerTypeV.Docker ||
8✔
42
                e.containerType == ContainerManagerTypeV.Podman {
16✔
43
                for i := range env {
40✔
44
                        e.ArgsEnv = append(e.ArgsEnv, "-e", env[i])
32✔
45
                }
32✔
46
        } else {
×
47
                panic("Not implemented.")
×
48
        }
49
}
50

51
const dindMsg = "Note: If you are inside a container ALREADY and want\n" +
52
        "to run hooks containerized (docker-in-docker) you can ONLY do\n" +
53
        "this by specifying host-machine paths (or a container volume) \n" +
54
        "for two locations:\n\n" +
55
        " - path (or container volume) and relative base path pointing to the \n" +
56
        "   workspace repository on the host machine where Githooks runs in,\n\n" +
57
        " - path (or container volume) pointing to the shared hooks \n" +
58
        "   location on the host machine, e.g `~/.githooks/shared`.\n\n" +
59
        "Check the Githooks manual for instructions on docker-in-docker."
60

61
// ResolveExitCode gets help for any non-zero exit code if needed.
62
func (e *ContainerizedExecutable) ResolveExitCode(exitCode int) string {
×
NEW
63
        switch e.containerType {
×
NEW
64
        case ContainerManagerTypeV.Docker:
×
65
                switch exitCode {
×
NEW
66
                case 125: //nolint:mnd
×
67
                        return "The docker daemon reported an error.\n" + dindMsg
×
NEW
68
                case 126: //nolint:mnd
×
69
                        return "Docker command could not be invoked (permission problem?)."
×
NEW
70
                case 127: //nolint:mnd
×
71
                        return "Command inside container could not be found."
×
72
                }
NEW
73
        case ContainerManagerTypeV.Podman:
×
74
                switch exitCode {
×
NEW
75
                case 125: //nolint:mnd
×
76
                        return "The podman reported an error.\n" + dindMsg
×
NEW
77
                case 126: //nolint:mnd
×
78
                        return "Podman command could not be invoked (permission problem?)."
×
NEW
79
                case 127: //nolint:mnd
×
80
                        return "Command inside container could not be found."
×
81
                }
82
        }
83

84
        return ""
×
85
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc