From 3c5bcb434c68a2c6c6d3a346b70ec35961627e8e Mon Sep 17 00:00:00 2001 From: Keith Rarick Date: Thu, 3 Sep 2015 10:27:28 -0700 Subject: [PATCH 1/3] Add Go dependencies to generated.rb and test_blob.rb --- lib/linguist/generated.rb | 9 +++++++++ test/test_blob.rb | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/lib/linguist/generated.rb b/lib/linguist/generated.rb index f1fb2d19..cc64c824 100644 --- a/lib/linguist/generated.rb +++ b/lib/linguist/generated.rb @@ -56,6 +56,7 @@ module Linguist generated_net_specflow_feature_file? || composer_lock? || node_modules? || + go_vendor? || godeps? || generated_by_zephir? || minified_files? || @@ -280,6 +281,14 @@ module Linguist !!name.match(/node_modules\//) end + # Internal: Is the blob part of the Go vendor/ tree, + # not meant for humans in pull requests. + # + # Returns true or false. + def go_vendor? + !!name.match(/vendor\//) + end + # Internal: Is the blob part of Godeps/, # which are not meant for humans in pull requests. # diff --git a/test/test_blob.rb b/test/test_blob.rb index 1ba647b0..74cffc2b 100644 --- a/test/test_blob.rb +++ b/test/test_blob.rb @@ -245,6 +245,10 @@ class TestBlob < Minitest::Test assert sample_blob("node_modules/grunt/lib/grunt.js").generated? + # Go vendored dependencies + assert sample_blob("vendor/vendor.json").generated? + assert sample_blob("vendor/github.com/kr/s3/sign.go").generated? + # Godep saved dependencies assert sample_blob("Godeps/Godeps.json").generated? assert sample_blob("Godeps/_workspace/src/github.com/kr/s3/sign.go").generated? From d46530989c93e036721487dbfd16e9a9b8f1082c Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Thu, 18 Feb 2016 19:57:34 -0500 Subject: [PATCH 2/3] Only treat `.go` files in ^vendor/ as generated --- lib/linguist/generated.rb | 4 +++- test/fixtures/go/food_vendor/candy.go | 1 + test/test_blob.rb | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 test/fixtures/go/food_vendor/candy.go diff --git a/lib/linguist/generated.rb b/lib/linguist/generated.rb index cc64c824..8c2c1bcd 100644 --- a/lib/linguist/generated.rb +++ b/lib/linguist/generated.rb @@ -286,7 +286,9 @@ module Linguist # # Returns true or false. def go_vendor? - !!name.match(/vendor\//) + return false unless extname == '.go' + + !!name.match(/\Avendor\//) end # Internal: Is the blob part of Godeps/, diff --git a/test/fixtures/go/food_vendor/candy.go b/test/fixtures/go/food_vendor/candy.go new file mode 100644 index 00000000..ce65385b --- /dev/null +++ b/test/fixtures/go/food_vendor/candy.go @@ -0,0 +1 @@ +// empty file for testing that paths with vendor in them don't get ingored diff --git a/test/test_blob.rb b/test/test_blob.rb index 74cffc2b..2e50853d 100644 --- a/test/test_blob.rb +++ b/test/test_blob.rb @@ -246,8 +246,9 @@ class TestBlob < Minitest::Test assert sample_blob("node_modules/grunt/lib/grunt.js").generated? # Go vendored dependencies - assert sample_blob("vendor/vendor.json").generated? + refute sample_blob("vendor/vendor.json").generated? assert sample_blob("vendor/github.com/kr/s3/sign.go").generated? + refute fixture_blob("go/food_vendor/candy.go").generated? # Godep saved dependencies assert sample_blob("Godeps/Godeps.json").generated? From a29f5b2d4642593c3f35529ec1c271cad4c9ed3e Mon Sep 17 00:00:00 2001 From: Arfon Smith Date: Thu, 27 Oct 2016 13:59:09 -0400 Subject: [PATCH 3/3] Adding Go-specific vendor paths --- lib/linguist/generated.rb | 4 +--- test/test_generated.rb | 5 +++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/linguist/generated.rb b/lib/linguist/generated.rb index fd6a9e76..a9ca4914 100644 --- a/lib/linguist/generated.rb +++ b/lib/linguist/generated.rb @@ -310,9 +310,7 @@ module Linguist # # Returns true or false. def go_vendor? - return false unless extname == '.go' - - !!name.match(/\Avendor\//) + !!name.match(/vendor\/((?!-)[-0-9A-Za-z]+(?