Skip to content

Commit

Permalink
Add debug logging to parseLocalCommitStack
Browse files Browse the repository at this point in the history
commit-id:7f63c86c
  • Loading branch information
ejoffe committed Mar 16, 2022
1 parent 15b7c94 commit 5fa7971
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ module github.com/ejoffe/spr
go 1.16

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/ejoffe/profiletimer v0.1.0
github.com/ejoffe/rake v0.2.3
github.com/google/uuid v1.2.0
github.com/jessevdk/go-flags v1.5.0
github.com/kr/pretty v0.2.0 // indirect
github.com/mvdan/xurls v1.1.0 // indirect
github.com/rs/zerolog v1.22.0
github.com/shurcooL/githubv4 v0.0.0-20201206200315-234843c633fa
Expand All @@ -15,6 +17,7 @@ require (
github.com/urfave/cli/v2 v2.3.0
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c
mvdan.cc/xurls v1.1.0
)
12 changes: 8 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGX
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/ejoffe/profiletimer v0.1.0 h1:Zq1WcdZhCMqXdsAVF1Vv95iTqKz7D54+hik7GDaAmJI=
github.com/ejoffe/profiletimer v0.1.0/go.mod h1:sv8+0PcNxJ5BLn+yCLMZ+B3+GmeQJDraZ2R3OIiB1uQ=
github.com/ejoffe/rake v0.2.3 h1:OAcW5ubJvqoB+mC6+35E7YYlzyKG8k8ib94hD2bLfjk=
Expand Down Expand Up @@ -112,8 +113,9 @@ github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs=
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
Expand Down Expand Up @@ -388,14 +390,16 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj
google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.3 h1:fvjTMHxHEw/mxHbtzPi3JCcKXQRAnQTBRo6YCJSVHKI=
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c h1:grhR+C34yXImVGp7EzNk+DTIk+323eIUWOmEevy6bDo=
gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
Expand Down
3 changes: 3 additions & 0 deletions hook/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/ejoffe/spr/config"
"github.com/ejoffe/spr/git"
"github.com/rs/zerolog/log"
)

const (
Expand All @@ -22,6 +23,8 @@ func InstallCommitHook(cfg *config.Config, gitcmd git.GitInterface) {
err = os.Chdir(rootdir)
check(err)

log.Debug().Str("rootdir", rootdir).Msg("InstallCommitHook")

info, err := os.Lstat(hookPath)
if err == nil {
if info.Mode()&os.ModeSymlink != 0 {
Expand Down
7 changes: 7 additions & 0 deletions spr/spr.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/ejoffe/spr/github"
"github.com/ejoffe/spr/github/githubclient"
"github.com/ejoffe/spr/hook"
"github.com/rs/zerolog/log"
)

// NewStackedPR constructs and returns a new stackediff instance.
Expand Down Expand Up @@ -353,13 +354,16 @@ func (sd *stackediff) parseLocalCommitStack(commitLog string) ([]git.Commit, boo
var scannedCommit git.Commit

lines := strings.Split(commitLog, "\n")
log.Debug().Int("lines", len(lines)).Msg("parseLocalCommitStack")
for index, line := range lines {

// match commit hash : start of a new commit
matches := commitHashRegex.FindStringSubmatch(line)
if matches != nil {
log.Debug().Interface("matches", matches).Msg("parseLocalCommitStack :: commitHashMatch")
if commitScanOn {
// missing the commit-id
log.Debug().Msg("parseLocalCommitStack :: missing commit id")
return nil, false
}
commitScanOn = true
Expand All @@ -372,6 +376,7 @@ func (sd *stackediff) parseLocalCommitStack(commitLog string) ([]git.Commit, boo
// match commit id : last thing in the commit
matches = commitIDRegex.FindStringSubmatch(line)
if matches != nil {
log.Debug().Interface("matches", matches).Msg("parseLocalCommitStack :: commitIdMatch")
scannedCommit.CommitID = matches[1]
scannedCommit.Body = strings.TrimSpace(scannedCommit.Body)

Expand Down Expand Up @@ -400,9 +405,11 @@ func (sd *stackediff) parseLocalCommitStack(commitLog string) ([]git.Commit, boo
// a commit-id
if commitScanOn {
// missing the commit-id
log.Debug().Msg("parseLocalCommitStack :: missing last commit id")
return nil, false
}

log.Debug().Interface("commits", commits).Msg("parseLocalCommitStack")
return commits, true
}

Expand Down

0 comments on commit 5fa7971

Please sign in to comment.