Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
build: gitector
build:
go build

install: build
Expand Down
12 changes: 12 additions & 0 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"fmt"
"github.com/op/go-logging"

"github.com/urfave/cli"
"gitlab.com/tbacompany/gitector/printer"
Expand Down Expand Up @@ -39,9 +40,20 @@ func CreateNewApp() *cli.App {
Name: "direct-input, di",
Usage: "Use direct input ",
},
cli.BoolFlag{
Name: "verbose",
Usage: "Print additional debug info",
},
}

app.Action = func(c *cli.Context) error {
// Set logging level
if c.Bool("verbose") {
logging.SetLevel(logging.INFO, "")
} else {
logging.SetLevel(logging.DEBUG, "")
}

// gitScope is defined same way as git diff does it branch..branch or commit..commit
gitScope := "master.."
if c.NArg() > 0 {
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/bclicn/color v0.0.0-20180711051946-108f2023dc84
github.com/gobuffalo/packr v1.30.1
github.com/knadh/koanf v0.5.0
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7
github.com/stretchr/testify v1.4.0
github.com/urfave/cli v1.22.1
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88=
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
github.com/pelletier/go-buffruneio v0.2.0/go.mod h1:JkE26KsDizTr40EUHkXVtNPvgGtbSNq5BcowyYOWdKo=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pelletier/go-toml v1.4.0 h1:u3Z1r+oOXJIkxqw34zVhyPgjBsm6X2wn21NWs/HfSeg=
Expand Down
10 changes: 7 additions & 3 deletions rules/rules.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package rules

import (
"github.com/op/go-logging"
"gitlab.com/tbacompany/gitector/reader"
"strings"
)
Expand All @@ -12,11 +13,14 @@ type GitError struct {
Commit reader.GitCommit
}

func Rules(description []reader.GitCommit, directory string) []GitError {
var log = logging.MustGetLogger("")

func Rules(commits []reader.GitCommit, directory string) []GitError {
config := ReadConfig(directory)
var errors []GitError
for _, elem := range description {
foundErrors := singleCommit(elem, config)
for _, commit := range commits {
foundErrors := singleCommit(commit, config)
log.Debugf("Found %d issues for commit %s ", len(foundErrors), commit.Title)
errors = append(errors, foundErrors...)
}
return errors
Expand Down