Skip to content

Commit c272c46

Browse files
committed
BUILD/MAJOR: add option to run check locally
1 parent a567bc1 commit c272c46

File tree

5 files changed

+187
-5
lines changed

5 files changed

+187
-5
lines changed

check.go

Lines changed: 103 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"encoding/hex"
77
"errors"
88
"fmt"
9+
"io"
910
"log"
1011
"os"
1112
"path"
@@ -21,6 +22,9 @@ import (
2122

2223
"github.com/xanzy/go-gitlab"
2324
"golang.org/x/oauth2"
25+
git "gopkg.in/src-d/go-git.v4"
26+
"gopkg.in/src-d/go-git.v4/plumbing/format/diff"
27+
"gopkg.in/src-d/go-git.v4/plumbing/object"
2428
yaml "gopkg.in/yaml.v3"
2529
)
2630

@@ -84,6 +88,7 @@ TagOrder:
8488

8589
GITHUB = "Github"
8690
GITLAB = "Gitlab"
91+
LOCAL = "local"
8792
)
8893

8994
var ErrSubjectMessageFormat = errors.New("invalid subject message format")
@@ -222,6 +227,10 @@ func (c CommitPolicyConfig) IsEmpty() bool {
222227
var ErrGitEnvironment = errors.New("git environment error")
223228

224229
func readGitEnvironment() (string, error) {
230+
if os.Getenv("CHECK") == LOCAL {
231+
return LOCAL, nil
232+
}
233+
225234
url := os.Getenv("GITHUB_API_URL")
226235
if url != "" {
227236
log.Printf("detected %s environment\n", GITHUB)
@@ -336,6 +345,97 @@ func getGithubCommitData() ([]string, []string, []map[string]string, error) {
336345
}
337346
}
338347

348+
func getLocalCommitData() ([]string, []string, []map[string]string, error) {
349+
repo, err := git.PlainOpen(".")
350+
if err != nil {
351+
return nil, nil, nil, err
352+
}
353+
354+
iter, err := repo.Log(&git.LogOptions{
355+
Order: git.LogOrderCommitterTime,
356+
})
357+
if err != nil {
358+
return nil, nil, nil, err
359+
}
360+
361+
subjects := []string{}
362+
messages := []string{}
363+
diffs := []map[string]string{}
364+
committer := ""
365+
var commit1 *object.Commit
366+
var commit2 *object.Commit
367+
for {
368+
commit, err := iter.Next()
369+
if err == io.EOF {
370+
break
371+
}
372+
if err != nil {
373+
return nil, nil, nil, err
374+
}
375+
if committer == "" {
376+
committer = commit.Author.Name
377+
commit1 = commit
378+
}
379+
380+
if commit.Author.Name != committer {
381+
commit2 = commit
382+
break
383+
}
384+
385+
commitBody := commit.Message
386+
l := strings.SplitN(string(commitBody), "\n", 3)
387+
commitHash := commit.Hash.String()
388+
if len(commitHash) > 8 {
389+
commitHash = commitHash[:8]
390+
}
391+
if len(l) > 1 {
392+
if l[1] != "" {
393+
return nil, nil, nil, fmt.Errorf("empty line between subject and body is required: %s %s", commitHash, l[0])
394+
}
395+
}
396+
if len(l) > 0 {
397+
subjects = append(subjects, l[0])
398+
messages = append(messages, string(commitBody))
399+
}
400+
}
401+
402+
// Get the changes (diff) between the two commits
403+
tree1, _ := commit1.Tree()
404+
tree2, _ := commit2.Tree()
405+
changes, err := object.DiffTree(tree2, tree1)
406+
if err != nil {
407+
return nil, nil, nil, err
408+
}
409+
410+
// Print the list of changed files and their content (patch)
411+
for _, change := range changes {
412+
patch, err := change.Patch()
413+
if err != nil {
414+
return nil, nil, nil, err
415+
}
416+
for _, file := range patch.FilePatches() {
417+
chunks := file.Chunks()
418+
fileChanges := ``
419+
420+
for _, chunk := range chunks {
421+
if chunk.Type() == diff.Delete {
422+
continue
423+
}
424+
if chunk.Type() == diff.Equal {
425+
continue
426+
}
427+
fileChanges += chunk.Content() + "\n"
428+
}
429+
if fileChanges == "" {
430+
continue
431+
}
432+
433+
diffs = append(diffs, map[string]string{change.To.Name: fileChanges})
434+
}
435+
}
436+
return subjects, messages, diffs, nil
437+
}
438+
339439
func cleanGitPatch(patch string) string {
340440
var cleanedPatch strings.Builder
341441
scanner := bufio.NewScanner(strings.NewReader(patch))
@@ -413,6 +513,8 @@ func getCommitData(repoEnv string) ([]string, []string, []map[string]string, err
413513
return getGithubCommitData()
414514
} else if repoEnv == GITLAB {
415515
return getGitlabCommitData()
516+
} else if repoEnv == LOCAL {
517+
return getLocalCommitData()
416518
}
417519
return nil, nil, nil, fmt.Errorf("unrecognized git environment %s", repoEnv)
418520
}
@@ -471,7 +573,7 @@ func main() {
471573

472574
subjects, messages, content, err := getCommitData(gitEnv)
473575
if err != nil {
474-
log.Fatalf("error getting commit subjects: %s", err)
576+
log.Fatalf("error getting commit data: %s", err)
475577
}
476578

477579
if err := commitPolicy.CheckSubjectList(subjects); err != nil {

go.mod

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,25 @@ require (
77
github.com/google/go-github/v56 v56.0.0
88
github.com/xanzy/go-gitlab v0.107.0
99
golang.org/x/oauth2 v0.21.0
10+
gopkg.in/src-d/go-git.v4 v4.13.1
1011
gopkg.in/yaml.v3 v3.0.1
1112
)
1213

1314
require (
15+
github.com/emirpasic/gods v1.12.0 // indirect
1416
github.com/google/go-querystring v1.1.0 // indirect
1517
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
1618
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
19+
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
20+
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd // indirect
21+
github.com/mitchellh/go-homedir v1.1.0 // indirect
22+
github.com/sergi/go-diff v1.0.0 // indirect
23+
github.com/src-d/gcfg v1.4.0 // indirect
24+
github.com/xanzy/ssh-agent v0.2.1 // indirect
25+
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 // indirect
26+
golang.org/x/net v0.8.0 // indirect
1727
golang.org/x/sys v0.22.0 // indirect
1828
golang.org/x/time v0.5.0 // indirect
29+
gopkg.in/src-d/go-billy.v4 v4.3.2 // indirect
30+
gopkg.in/warnings.v0 v0.1.2 // indirect
1931
)

go.sum

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
1+
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs=
2+
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs=
3+
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA=
4+
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
5+
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
6+
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
7+
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
8+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
19
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
210
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
11+
github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=
12+
github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
313
github.com/fatih/camelcase v1.0.0 h1:hxNvNX/xYBp0ovncs8WyWZrOrpBNub/JfaMvbURyft8=
414
github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwoZc+/fpc=
515
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
616
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
17+
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
18+
github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0=
19+
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
20+
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
721
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
822
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
923
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
@@ -17,24 +31,78 @@ github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB1
1731
github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
1832
github.com/hashicorp/go-retryablehttp v0.7.7 h1:C8hUCYzor8PIfXHa4UrZkU4VvK8o9ISHxT2Q8+VepXU=
1933
github.com/hashicorp/go-retryablehttp v0.7.7/go.mod h1:pkQpWZeYWskR+D1tR2O5OcBFOxfA7DoAO6xtkuQnHTk=
34+
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
35+
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
36+
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
37+
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd h1:Coekwdh0v2wtGp9Gmz1Ze3eVRAWJMLokvN3QjdzCHLY=
38+
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
39+
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
40+
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
41+
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
42+
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
43+
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
44+
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
2045
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
2146
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
2247
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
2348
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
49+
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
50+
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
51+
github.com/pelletier/go-buffruneio v0.2.0/go.mod h1:JkE26KsDizTr40EUHkXVtNPvgGtbSNq5BcowyYOWdKo=
52+
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
53+
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
2454
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
2555
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
56+
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
57+
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
58+
github.com/src-d/gcfg v1.4.0 h1:xXbNR5AlLSA315x2UO+fTSSAXCDf+Ar38/6oyGbDKQ4=
59+
github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jWoI=
60+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
61+
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
62+
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
2663
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
2764
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
2865
github.com/xanzy/go-gitlab v0.107.0 h1:P2CT9Uy9yN9lJo3FLxpMZ4xj6uWcpnigXsjvqJ6nd2Y=
2966
github.com/xanzy/go-gitlab v0.107.0/go.mod h1:wKNKh3GkYDMOsGmnfuX+ITCmDuSDWFO0G+C4AygL9RY=
67+
github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70=
68+
github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
69+
golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
70+
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
71+
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 h1:HuIa8hRrWRSrqYzx1qI49NNxhdi2PrY7gxVSq1JjLDc=
72+
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
73+
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
74+
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
75+
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
76+
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
77+
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
3078
golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs=
3179
golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
80+
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
81+
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
82+
golang.org/x/sys v0.0.0-20190221075227-b4e8571b14e0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
83+
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
84+
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
3285
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
3386
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
87+
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
88+
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
89+
golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
90+
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
3491
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
3592
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
93+
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
94+
golang.org/x/tools v0.0.0-20190729092621-ff9f1409240a/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
3695
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
37-
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
3896
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
97+
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
98+
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
99+
gopkg.in/src-d/go-billy.v4 v4.3.2 h1:0SQA1pRztfTFx2miS8sA97XvooFeNOmvUenF4o0EcVg=
100+
gopkg.in/src-d/go-billy.v4 v4.3.2/go.mod h1:nDjArDMp+XMs1aFAESLRjfGSgfvoYN0hDfzEk0GjC98=
101+
gopkg.in/src-d/go-git-fixtures.v3 v3.5.0 h1:ivZFOIltbce2Mo8IjzUHAFoq/IylO9WHhNOAJK+LsJg=
102+
gopkg.in/src-d/go-git-fixtures.v3 v3.5.0/go.mod h1:dLBcvytrw/TYZsNTWCnkNF2DSIlzWYqTe3rJR56Ac7g=
103+
gopkg.in/src-d/go-git.v4 v4.13.1 h1:SRtFyV8Kxc0UP7aCHcijOMQGPxHSmMOPrzulQWolkYE=
104+
gopkg.in/src-d/go-git.v4 v4.13.1/go.mod h1:nx5NYcxdKxq5fpltdHnPa2Exj4Sx0EclMWZQbYDu2z8=
105+
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
106+
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
39107
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
40108
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

match/golang.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func GetImportWordsFromGoFile(filename string) []string {
4242
"Println", "Stdin", "stdout", "stderr", "Stdout", "Stderr",
4343
"errorf", "println", "Sprintf", "Printf", "Unmarshal", "args",
4444
"Getenv", "Errorf", "tt", "yml", "ok", "cmd", "utf", "Atoi",
45-
"oauth",
45+
"oauth", "EOF", "exec", "iter",
4646
)
4747
findImports(fileContent, "import (", ")", func(data string) {
4848
words := strings.FieldsFunc(data, func(r rune) bool {

match/golang_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func TestGetImportWordsFromFile(t *testing.T) {
2626
"Println", "Stdin", "stdout", "stderr", "Stdout", "Stderr",
2727
"errorf", "println", "Sprintf", "Printf", "Unmarshal", "args",
2828
"Getenv", "Errorf", "tt", "yml", "ok", "cmd", "utf", "Atoi",
29-
"oauth",
29+
"oauth", "EOF", "exec", "iter",
3030
"strings", "slices", "testing",
3131
}},
3232
{"test 2", "match.go", []string{
@@ -43,7 +43,7 @@ func TestGetImportWordsFromFile(t *testing.T) {
4343
"Println", "Stdin", "stdout", "stderr", "Stdout", "Stderr",
4444
"errorf", "println", "Sprintf", "Printf", "Unmarshal", "args",
4545
"Getenv", "Errorf", "tt", "yml", "ok", "cmd", "utf", "Atoi",
46-
"oauth",
46+
"oauth", "EOF", "exec", "iter",
4747
"filepath", "path", "strings", "regexp",
4848
}},
4949
}

0 commit comments

Comments
 (0)