From c5344da2ba307524ed6ac69d19eaa7f5ec762aed Mon Sep 17 00:00:00 2001 From: Arfon Smith Date: Mon, 17 Nov 2014 16:44:39 -0600 Subject: [PATCH 1/4] Removing extensions when they should be filenames --- lib/linguist/languages.yml | 2 - samples/Ant Build System/filenames/ant.xml | 110 +++++++++++ samples/Maven POM/example.pom.xml | 207 --------------------- 3 files changed, 110 insertions(+), 209 deletions(-) create mode 100644 samples/Ant Build System/filenames/ant.xml delete mode 100644 samples/Maven POM/example.pom.xml diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 022918e6..478aca2e 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -37,7 +37,6 @@ Ant Build System: type: data tm_scope: text.xml.ant extensions: - - .ant.xml filenames: - build.xml - ant.xml @@ -1527,7 +1526,6 @@ Maven POM: type: data tm_scope: text.xml.pom extensions: - - .pom.xml filenames: - pom.xml diff --git a/samples/Ant Build System/filenames/ant.xml b/samples/Ant Build System/filenames/ant.xml new file mode 100644 index 00000000..54e96ddc --- /dev/null +++ b/samples/Ant Build System/filenames/ant.xml @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/Maven POM/example.pom.xml b/samples/Maven POM/example.pom.xml deleted file mode 100644 index 6e329fd9..00000000 --- a/samples/Maven POM/example.pom.xml +++ /dev/null @@ -1,207 +0,0 @@ - - - 4.0.0 - renpengben - spring4mvc-jpa - war - 0.0.1-SNAPSHOT - spring4mvc-jpa Maven Webapp - - https://renpengben.github.io - - spring4mvc-jpa - - - UTF-8 - 1.7 - 4.11 - 1.7.7 - 1.2.17 - - 4.0.5.RELEASE - 1.6.0.RELEASE - 2.1_3 - - 5.1.31 - 4.3.5.Final - 5.1.1.Final - 1.0.6 - - - - - - - - junit - junit - ${junit.version} - test - - - - org.slf4j - slf4j-api - ${slf4j.version} - - - org.slf4j - slf4j-log4j12 - ${slf4j.version} - - - log4j - log4j - ${log4j.version} - - - - - - org.springframework - spring-core - ${spring.version} - - - commons-logging - commons-logging - - - - - - org.springframework - spring-beans - ${spring.version} - - - org.springframework - spring-context - ${spring.version} - - - - org.springframework - spring-aop - ${spring.version} - - - - org.springframework - spring-expression - ${spring.version} - - - org.springframework - spring-tx - ${spring.version} - - - - - org.springframework - spring-aspects - ${spring.version} - - - org.springframework - spring-context-support - ${spring.version} - - - org.springframework - spring-jdbc - ${spring.version} - - - org.springframework - spring-orm - ${spring.version} - - - - org.springframework - spring-web - ${spring.version} - - - org.springframework - spring-webmvc - ${spring.version} - - - org.springframework - spring-test - ${spring.version} - test - - - - org.springframework.data - spring-data-jpa - ${spring.data.jpa.version} - - - junit-dep - junit - - - - - cglib - cglib-nodep - ${cglib.version} - - - - - - - - org.hibernate - hibernate-core - ${hibernate.version} - - - org.hibernate - hibernate-entitymanager - ${hibernate.version} - - - org.hibernate - hibernate-validator - ${hibernate-validator.version} - compile - - - - - - mysql - mysql-connector-java - ${mysql.version} - runtime - - - com.alibaba - druid - ${druid-version} - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.0.2 - - 1.7 - 1.7 - - - - - From b8e426d3a3d751410ff56474630d2342716edd2f Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Mon, 17 Nov 2014 18:52:53 -0500 Subject: [PATCH 2/4] Make pedantic test actually pedantic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit What do you call someone that thinks they are pedantic but actually aren’t? All the crazy custom parsing in this test was making so it wasn’t actually doing anything. --- test/test_pedantic.rb | 49 ++++++++++--------------------------------- 1 file changed, 11 insertions(+), 38 deletions(-) diff --git a/test/test_pedantic.rb b/test/test_pedantic.rb index 264c54f3..c1819fb6 100644 --- a/test/test_pedantic.rb +++ b/test/test_pedantic.rb @@ -1,57 +1,30 @@ require 'test/unit' +require 'yaml' class TestPedantic < Test::Unit::TestCase - Lib = File.expand_path("../../lib/linguist", __FILE__) - - def file(name) - File.read(File.join(Lib, name)) - end + filename = File.expand_path("../../lib/linguist/languages.yml", __FILE__) + LANGUAGES = YAML.load(File.read(filename)) def test_language_names_are_sorted - languages = [] - file("languages.yml").lines.each do |line| - if line =~ /^(\w+):$/ - languages << $1 - end - end - assert_sorted languages + assert_sorted LANGUAGES.keys end def test_extensions_are_sorted - extensions = nil - file("languages.yml").lines.each do |line| - if line =~ /^ extensions:$/ - extensions = [] - elsif extensions && line =~ /^ - \.([\w\-\.]+)( *#.*)?$/ - extensions << $1 - else - assert_sorted extensions[1..-1] if extensions - extensions = nil - end + LANGUAGES.each do |name, language| + extensions = language['extensions'] + assert_sorted extensions[1..-1] if extensions && extensions.size > 1 end end def test_filenames_are_sorted - filenames = nil - file("languages.yml").lines.each do |line| - if line =~ /^ filenames:$/ - filenames = [] - elsif filenames && line =~ /^ - \.(\w+)$/ - filenames << $1 - else - assert_sorted filenames if filenames - filenames = nil - end + LANGUAGES.each do |name, language| + assert_sorted language['filenames'] if language['filenames'] end end def assert_sorted(list) - previous = nil - list.each do |item| - if previous && previous > item - flunk "#{previous} should come after #{item}" - end - previous = item + list.each_cons(2) do |previous, item| + flunk "#{previous} should come after #{item}" if previous > item end end end From 63c83d014b138d0595ce26fad866a92181e5edaa Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Mon, 17 Nov 2014 18:53:14 -0500 Subject: [PATCH 3/4] Fix errors from pedantic test --- lib/linguist/languages.yml | 98 ++++++++++++++++++-------------------- 1 file changed, 47 insertions(+), 51 deletions(-) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 478aca2e..bdaf66fe 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -33,14 +33,6 @@ AGS Script: - .ash tm_scope: source.c++ -Ant Build System: - type: data - tm_scope: text.xml.ant - extensions: - filenames: - - build.xml - - ant.xml - ANTLR: type: programming color: "#9DC3FF" @@ -116,6 +108,14 @@ Alloy: extensions: - .als +Ant Build System: + type: data + tm_scope: text.xml.ant + extensions: + filenames: + - ant.xml + - build.xml + ApacheConf: type: markup aliases: @@ -648,13 +648,6 @@ E: extensions: - .E -Ecere Projects: - type: data - group: JavaScript - extensions: - - .epj - tm_scope: source.json - ECL: type: programming color: "#8a1267" @@ -670,6 +663,13 @@ Eagle: - .brd tm_scope: text.xml +Ecere Projects: + type: data + group: JavaScript + extensions: + - .epj + tm_scope: source.json + Eiffel: type: programming color: "#946d57" @@ -766,8 +766,8 @@ Factor: extensions: - .factor filenames: - - .factor-rc - .factor-boot-rc + - .factor-rc Fancy: type: programming @@ -808,13 +808,6 @@ G-code: - .gco - .gcode -Game Maker Language: - type: programming - color: "#8ad353" - extensions: - - .gml - tm_scope: source.js - GAMS: type: programming extensions: @@ -859,6 +852,13 @@ GLSL: - .vrx - .vshader +Game Maker Language: + type: programming + color: "#8ad353" + extensions: + - .gml + tm_scope: source.js + Genshi: extensions: - .kid @@ -1118,9 +1118,14 @@ INI: aliases: - dosini -Inno Setup: +IRC log: + search_term: irc + aliases: + - irc + - irc logs extensions: - - .iss + - .irclog + - .weechatlog Idris: type: programming @@ -1143,15 +1148,6 @@ Inno Setup: extensions: - .iss -IRC log: - search_term: irc - aliases: - - irc - - irc logs - extensions: - - .irclog - - .weechatlog - Io: type: programming color: "#a9188d" @@ -1470,9 +1466,9 @@ Makefile: - .mak - .mk filenames: - - makefile - - Makefile - GNUmakefile + - Makefile + - makefile interpreters: - make @@ -1827,6 +1823,14 @@ Parrot: extensions: - .parrot # Dummy extension +Parrot Assembly: + group: Parrot + type: programming + aliases: + - pasm + extensions: + - .pasm + Parrot Internal Representation: group: Parrot tm_scope: source.parrot.pir @@ -1836,14 +1840,6 @@ Parrot Internal Representation: extensions: - .pir -Parrot Assembly: - group: Parrot - type: programming - aliases: - - pasm - extensions: - - .pasm - Pascal: type: programming color: "#b0ce4e" @@ -2000,10 +1996,10 @@ Python: - .wsgi - .xpy filenames: - - wscript - - SConstruct - - SConscript - BUILD + - SConscript + - SConstruct + - wscript interpreters: - python @@ -2583,8 +2579,8 @@ VimL: filenames: - .vimrc - _vimrc - - vimrc - gvimrc + - vimrc Visual Basic: type: programming @@ -2686,12 +2682,12 @@ XML: filenames: - .classpath - .project + - Web.Debug.config + - Web.Release.config + - Web.config - build.xml.dist - packages.config - phpunit.xml.dist - - Web.config - - Web.Debug.config - - Web.Release.config XProc: type: programming From cd7549390e107d11e54d62d723001e7a0416015c Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Mon, 17 Nov 2014 20:00:09 -0500 Subject: [PATCH 4/4] Extensions aren't actually required --- lib/linguist/language.rb | 4 ++-- test/test_language.rb | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/linguist/language.rb b/lib/linguist/language.rb index 507ae71a..c40e28b5 100644 --- a/lib/linguist/language.rb +++ b/lib/linguist/language.rb @@ -595,9 +595,9 @@ module Linguist :ace_mode => options['ace_mode'], :wrap => options['wrap'], :group_name => options['group'], - :searchable => options.key?('searchable') ? options['searchable'] : true, + :searchable => options.fetch('searchable', true), :search_term => options['search_term'], - :extensions => [options['extensions'].first] + options['extensions'][1..-1].sort, + :extensions => Array(options['extensions']), :interpreters => options['interpreters'].sort, :filenames => options['filenames'], :popular => popular.include?(name) diff --git a/test/test_language.rb b/test/test_language.rb index aeb1fce9..a23715d2 100644 --- a/test/test_language.rb +++ b/test/test_language.rb @@ -349,12 +349,6 @@ class TestLanguage < Test::Unit::TestCase assert_equal '.coffee', Language['CoffeeScript'].primary_extension assert_equal '.t', Language['Turing'].primary_extension assert_equal '.ts', Language['TypeScript'].primary_extension - - # This is a nasty requirement, but there's some code in GitHub that - # expects this. Really want to drop this. - Language.all.each do |language| - assert language.primary_extension, "#{language} has no primary extension" - end end def test_eql