Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

Commit

Permalink
merge: branch 'release/1.0.1'
Browse files Browse the repository at this point in the history
better gitlab ci handling
  • Loading branch information
sascha-andres committed Aug 16, 2019
2 parents d8347a3 + 51dd856 commit 42de064
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
5 changes: 0 additions & 5 deletions .commit-hook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,3 @@ external-tools:
command:
- make
- test
- severity: error
name: linter
command:
- make
- lint
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Essentially this just removes the hook, so it would remove any other hook also.

|Version|Description|
|---|---|
|1.0.1|better gitlab ci handling|
|1.0.0|update to use go modules|
|0.9.0|add support for GitLab CI linter|
||fix a bug where body lines where multiplied by the number of ignore expressions|
Expand Down
6 changes: 3 additions & 3 deletions cmd/methods/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
func UninstallHook() int {
err := subcommands.Uninstall(".git")
if err != nil {
fmt.Fprintln(os.Stderr, "error:", err)
_, _ = fmt.Fprintln(os.Stderr, "error:", err)
return 1
}
return 0
Expand All @@ -23,11 +23,11 @@ func InstallHook() int {
if helper.DirectoryExists(".git") {
err := subcommands.Install(".git")
if err != nil {
fmt.Fprintln(os.Stderr, "error:", err)
_, _ = fmt.Fprintln(os.Stderr, "error:", err)
return 1
}
} else {
fmt.Fprintln(os.Stderr, "error: no git repository")
_, _ = fmt.Fprintln(os.Stderr, "error: no git repository")
return 1
}
return 0
Expand Down
2 changes: 1 addition & 1 deletion hook/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"

"livingit.de/code/git-commit/hook/config"
"livingit.de/code/git-commit/hook/v2"
v2 "livingit.de/code/git-commit/hook/v2"
"livingit.de/code/go-hookhelper"
"livingit.de/code/versioned"
)
Expand Down
14 changes: 13 additions & 1 deletion hook/v2/gitlab_ci_linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ func (cfg *Configuration) validateGitLabCI() (result bool) {
return true
}

if !ciConfigExists() && cfg.GitLabCIFile == "" {
return true
}

var (
cmd *exec.Cmd
)

fmt.Println("running GitLab CI linter")
_, _ = fmt.Println("running GitLab CI linter")

pathToLinter, err := exec.LookPath("gitlab-ci-linter")
if err != nil {
Expand Down Expand Up @@ -45,3 +49,11 @@ func (cfg *Configuration) validateGitLabCI() (result bool) {

return true
}

func ciConfigExists() bool {
info, err := os.Stat(".gitlab-ci.yml")
if os.IsNotExist(err) {
return false
}
return !info.IsDir()
}

0 comments on commit 42de064

Please sign in to comment.