Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add go.mod heuristics #6996

Closed
wants to merge 1 commit into from
Closed
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: 2 additions & 0 deletions lib/linguist/heuristics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,8 @@ disambiguations:
pattern: '<!ENTITY '
- language: NMODL
pattern: '\b(NEURON|INITIAL|UNITS)\b'
- language: Go Module
pattern: '^\s*module\s+(\(|[\w\-./]+|"[^"]*")\s*$'
- language: Modula-2
pattern: '^\s*(?i:MODULE|END) [\w\.]+;'
- language: [Linux Kernel Module, AMPL]
Expand Down
12 changes: 12 additions & 0 deletions test/fixtures/Go Module/multiline/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module (
golang.org/x/oauth2
)

go 1.11

require (
cloud.google.com/go v0.34.0
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 // indirect
google.golang.org/appengine v1.4.0
)
10 changes: 10 additions & 0 deletions test/fixtures/Go Module/quoted/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module "golang.org/x/oauth2"

go 1.11

require (
cloud.google.com/go v0.34.0
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 // indirect
google.golang.org/appengine v1.4.0
)
10 changes: 10 additions & 0 deletions test/fixtures/Go Module/unquoted/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module golang.org/x/oauth2

go 1.11

require (
cloud.google.com/go v0.34.0
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 // indirect
google.golang.org/appengine v1.4.0
)
3 changes: 3 additions & 0 deletions test/test_heuristics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,9 @@ def test_mod_by_heuristics
"Modula-2" => all_fixtures("Modula-2", "*.mod"),
"NMODL" => all_fixtures("NMODL", "*.mod"),
"XML" => all_fixtures("XML", "*.mod"),
"Go Module" => Dir.glob("#{fixtures_path}/Go Module/multiline/go.mod") +
Dir.glob("#{fixtures_path}/Go Module/quoted/go.mod") +
Dir.glob("#{fixtures_path}/Go Module/unquoted/go.mod"),
["Linux Kernel Module", "AMPL"] => all_fixtures("Linux Kernel Module", "*.mod"),
["Linux Kernel Module", "AMPL"] => all_fixtures("AMPL", "*.mod"),
})
Expand Down
Loading