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

Revert #4306 - Stop marking go.mod and go.sum generated #4340

Merged
merged 6 commits into from
Jan 16, 2019
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
8 changes: 0 additions & 8 deletions lib/linguist/generated.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def generated?
go_lock? ||
npm_shrinkwrap_or_package_lock? ||
godeps? ||
go_mod? ||
generated_by_zephir? ||
minified_files? ||
has_source_map? ||
Expand Down Expand Up @@ -379,13 +378,6 @@ def godeps?
!!name.match(/Godeps\//)
end

# Internal: Is the blob a Go module metadata file?
#
# Returns true or false.
def go_mod?
name.match(/go\.mod/) || name.match(/go\.sum/)
end

# Internal: Is the blob a generated php composer lock file?
#
# Returns true or false.
Expand Down
2 changes: 2 additions & 0 deletions lib/linguist/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4939,6 +4939,8 @@ Text:
- README.mysql
- click.me
- delete.me
- go.mod
- go.sum
- keep.me
- read.me
- readme.1st
Expand Down
10 changes: 10 additions & 0 deletions test/fixtures/Text/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
)
12 changes: 12 additions & 0 deletions test/fixtures/Text/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
cloud.google.com/go v0.34.0 h1:eOI3/cP2VTU6uZLDYAoic+eyzzB9YyGmJ7eIjl8rOPg=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
4 changes: 0 additions & 4 deletions test/test_generated.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@ def test_check_generated
generated_sample_without_loading_data("Godeps/Godeps.json")
generated_sample_without_loading_data("Godeps/_workspace/src/github.com/kr/s3/sign.go")

# Go module metadata files
generated_sample_without_loading_data("Dummy/go.mod")
generated_sample_without_loading_data("Dummy/go.sum")

# Generated by Zephir
generated_sample_without_loading_data("C/exception.zep.c")
generated_sample_without_loading_data("C/exception.zep.h")
Expand Down
12 changes: 12 additions & 0 deletions test/test_samples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ def test_filename_listed
end
end

# Some named files are deliberately classified as Text without a corresponding sample as including
# the sample would affect the classifier leading to incorrect analysis and classification.
# This test ensures samples aren't added for those specific cases.
def test_no_text_samples
no_text_samples = ["go.mod", "go.sum"]
Samples.each do |sample|
if sample[:language] == "Text"
refute_includes no_text_samples, sample[:filename], "#{sample[:filename]} should NOT be added as a sample for #{sample[:language]}"
end
end
end

pchaigno marked this conversation as resolved.
Show resolved Hide resolved
# Check that there aren't samples with extensions or interpreters that
# aren't explicitly defined in languages.yml
languages_yml = File.expand_path("../../lib/linguist/languages.yml", __FILE__)
Expand Down