From d0824ee3b2ab8094a0091f516f58e565cf9a5fab Mon Sep 17 00:00:00 2001 From: Joris den Ouden Date: Tue, 26 Jul 2011 20:00:35 +0200 Subject: [PATCH 1/4] Detect Visual Studio project files, solution files and resource files as generated --- lib/linguist/blob_helper.rb | 2 +- test/test_blob.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/linguist/blob_helper.rb b/lib/linguist/blob_helper.rb index 559c593b..e98d6323 100644 --- a/lib/linguist/blob_helper.rb +++ b/lib/linguist/blob_helper.rb @@ -178,7 +178,7 @@ module Linguist # # Return true or false def generated? - if ['.xib', '.nib', '.pbxproj', '.xcworkspacedata', '.xcuserstate'].include?(extname) + if ['.xib', '.nib', '.pbxproj', '.xcworkspacedata', '.xcuserstate', '.csproj', '.dbproj', '.fsproj', '.pyproj', '.rbproj', '.vbproj', '.vcxproj', '.wixproj', '.resx', '.sln', '.vdproj', '.isproj'].include?(extname) true elsif generated_coffeescript? || minified_javascript? true diff --git a/test/test_blob.rb b/test/test_blob.rb index dbef035d..ced1e6dd 100644 --- a/test/test_blob.rb +++ b/test/test_blob.rb @@ -123,6 +123,19 @@ class TestBlob < Test::Unit::TestCase assert blob("MainMenu.nib").generated? assert blob("project.pbxproj").generated? + # Visual Studio Files + assert blob("project.csproj").generated? + assert blob("project.dbproj").generated? + assert blob("project.isproj").generated? + assert blob("project.pyproj").generated? + assert blob("project.rbproj").generated? + assert blob("project.vbproj").generated? + assert blob("project.vdproj").generated? + assert blob("project.vcxproj").generated? + assert blob("project.wixproj").generated? + assert blob("project.resx").generated? + assert blob("project.sln").generated? + # Long line assert !blob("uglify.js").generated? From f3457c1706a3d5d6d6b76a53c6cd000c5b87ae7c Mon Sep 17 00:00:00 2001 From: Joris den Ouden Date: Tue, 26 Jul 2011 20:02:05 +0200 Subject: [PATCH 2/4] Detect .config .settings .wxi .wxl .wxs and .xaml as XML --- lib/linguist/languages.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 4a068309..b0bac4c0 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -931,13 +931,19 @@ XML: type: markup primary_extension: .xml extensions: + - .config - .kml - .mxml - .plist - .rdf - .rss + - .settings - .svg + - .wxi + - .wxl + - .wxs - .wsdl + - .xaml - .xml - .xsd - .xsl From 0a842a5b5f3f4b49bd35ab5de9d2642523f60c9d Mon Sep 17 00:00:00 2001 From: Joris den Ouden Date: Tue, 26 Jul 2011 21:58:57 +0200 Subject: [PATCH 3/4] .settings and .config no longer detected as XML --- lib/linguist/languages.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index b0bac4c0..ac4178d4 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -931,13 +931,11 @@ XML: type: markup primary_extension: .xml extensions: - - .config - .kml - .mxml - .plist - .rdf - .rss - - .settings - .svg - .wxi - .wxl From 5eec0034d186ec35ca284d5e8346803c8f1a4525 Mon Sep 17 00:00:00 2001 From: Joris den Ouden Date: Tue, 26 Jul 2011 22:13:25 +0200 Subject: [PATCH 4/4] XCode and Visual Studio project detection in seperate methods --- lib/linguist/blob_helper.rb | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/lib/linguist/blob_helper.rb b/lib/linguist/blob_helper.rb index e98d6323..aa81aee1 100644 --- a/lib/linguist/blob_helper.rb +++ b/lib/linguist/blob_helper.rb @@ -171,6 +171,7 @@ module Linguist # # Includes: # - XCode project XML files + # - Visual Studio project XNL files # - Minified JavaScript # # Please add additional test coverage to @@ -178,7 +179,7 @@ module Linguist # # Return true or false def generated? - if ['.xib', '.nib', '.pbxproj', '.xcworkspacedata', '.xcuserstate', '.csproj', '.dbproj', '.fsproj', '.pyproj', '.rbproj', '.vbproj', '.vcxproj', '.wixproj', '.resx', '.sln', '.vdproj', '.isproj'].include?(extname) + if xcode_project_file? || visual_studio_project_file? true elsif generated_coffeescript? || minified_javascript? true @@ -187,6 +188,36 @@ module Linguist end end + # Internal: Is the blob an XCode project file? + # + # Generated if the file extension is an XCode project + # file extension. + # + # Returns true of false. + + def xcode_project_file? + if ['.xib', '.nib', '.pbxproj', '.xcworkspacedata', '.xcuserstate'].include?(extname) + true + else + false + end + end + + # Internal: Is the blob a Visual Studio project file? + # + # Generated if the file extension is a Visual Studio project + # file extension. + # + # Returns true of false. + + def visual_studio_project_file? + if ['.csproj', '.dbproj', '.fsproj', '.pyproj', '.rbproj', '.vbproj', '.vcxproj', '.wixproj', '.resx', '.sln', '.vdproj', '.isproj'].include?(extname) + true + else + false + end + end + # Internal: Is the blob minified JS? # # Consider JS minified if the average line length is