mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	Remove samples/LANG/filenames as a source of truth (#4078)
All filenames must now be explicitly listed in languages.yml. A test makes sure they are.
This commit is contained in:
		@@ -539,14 +539,6 @@ module Linguist
 | 
				
			|||||||
      end
 | 
					      end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if fns = filenames[name]
 | 
					 | 
				
			||||||
      fns.each do |filename|
 | 
					 | 
				
			||||||
        if !options['filenames'].include?(filename)
 | 
					 | 
				
			||||||
          options['filenames'] << filename
 | 
					 | 
				
			||||||
        end
 | 
					 | 
				
			||||||
      end
 | 
					 | 
				
			||||||
    end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    Language.create(
 | 
					    Language.create(
 | 
				
			||||||
      :name              => name,
 | 
					      :name              => name,
 | 
				
			||||||
      :color             => options['color'],
 | 
					      :color             => options['color'],
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -239,6 +239,10 @@ ApacheConf:
 | 
				
			|||||||
  extensions:
 | 
					  extensions:
 | 
				
			||||||
  - ".apacheconf"
 | 
					  - ".apacheconf"
 | 
				
			||||||
  - ".vhost"
 | 
					  - ".vhost"
 | 
				
			||||||
 | 
					  filenames:
 | 
				
			||||||
 | 
					  - ".htaccess"
 | 
				
			||||||
 | 
					  - apache2.conf
 | 
				
			||||||
 | 
					  - httpd.conf
 | 
				
			||||||
  tm_scope: source.apache-config
 | 
					  tm_scope: source.apache-config
 | 
				
			||||||
  ace_mode: apache_conf
 | 
					  ace_mode: apache_conf
 | 
				
			||||||
  language_id: 16
 | 
					  language_id: 16
 | 
				
			||||||
@@ -1467,6 +1471,8 @@ GN:
 | 
				
			|||||||
  - ".gni"
 | 
					  - ".gni"
 | 
				
			||||||
  interpreters:
 | 
					  interpreters:
 | 
				
			||||||
  - gn
 | 
					  - gn
 | 
				
			||||||
 | 
					  filenames:
 | 
				
			||||||
 | 
					  - ".gn"
 | 
				
			||||||
  tm_scope: source.gn
 | 
					  tm_scope: source.gn
 | 
				
			||||||
  ace_mode: python
 | 
					  ace_mode: python
 | 
				
			||||||
  codemirror_mode: python
 | 
					  codemirror_mode: python
 | 
				
			||||||
@@ -1925,6 +1931,8 @@ INI:
 | 
				
			|||||||
  - ".pro"
 | 
					  - ".pro"
 | 
				
			||||||
  - ".properties"
 | 
					  - ".properties"
 | 
				
			||||||
  filenames:
 | 
					  filenames:
 | 
				
			||||||
 | 
					  - ".editorconfig"
 | 
				
			||||||
 | 
					  - ".gitconfig"
 | 
				
			||||||
  - buildozer.spec
 | 
					  - buildozer.spec
 | 
				
			||||||
  tm_scope: source.ini
 | 
					  tm_scope: source.ini
 | 
				
			||||||
  aliases:
 | 
					  aliases:
 | 
				
			||||||
@@ -3226,6 +3234,7 @@ PHP:
 | 
				
			|||||||
  - ".phps"
 | 
					  - ".phps"
 | 
				
			||||||
  - ".phpt"
 | 
					  - ".phpt"
 | 
				
			||||||
  filenames:
 | 
					  filenames:
 | 
				
			||||||
 | 
					  - ".php"
 | 
				
			||||||
  - ".php_cs"
 | 
					  - ".php_cs"
 | 
				
			||||||
  - ".php_cs.dist"
 | 
					  - ".php_cs.dist"
 | 
				
			||||||
  - Phakefile
 | 
					  - Phakefile
 | 
				
			||||||
@@ -3370,6 +3379,7 @@ Perl:
 | 
				
			|||||||
  - ".psgi"
 | 
					  - ".psgi"
 | 
				
			||||||
  - ".t"
 | 
					  - ".t"
 | 
				
			||||||
  filenames:
 | 
					  filenames:
 | 
				
			||||||
 | 
					  - ack
 | 
				
			||||||
  - cpanfile
 | 
					  - cpanfile
 | 
				
			||||||
  interpreters:
 | 
					  interpreters:
 | 
				
			||||||
  - perl
 | 
					  - perl
 | 
				
			||||||
@@ -3709,6 +3719,7 @@ R:
 | 
				
			|||||||
  - ".rsx"
 | 
					  - ".rsx"
 | 
				
			||||||
  filenames:
 | 
					  filenames:
 | 
				
			||||||
  - ".Rprofile"
 | 
					  - ".Rprofile"
 | 
				
			||||||
 | 
					  - expr-dist
 | 
				
			||||||
  interpreters:
 | 
					  interpreters:
 | 
				
			||||||
  - Rscript
 | 
					  - Rscript
 | 
				
			||||||
  ace_mode: r
 | 
					  ace_mode: r
 | 
				
			||||||
@@ -4035,6 +4046,7 @@ Ruby:
 | 
				
			|||||||
  - Berksfile
 | 
					  - Berksfile
 | 
				
			||||||
  - Brewfile
 | 
					  - Brewfile
 | 
				
			||||||
  - Buildfile
 | 
					  - Buildfile
 | 
				
			||||||
 | 
					  - Capfile
 | 
				
			||||||
  - Dangerfile
 | 
					  - Dangerfile
 | 
				
			||||||
  - Deliverfile
 | 
					  - Deliverfile
 | 
				
			||||||
  - Fastfile
 | 
					  - Fastfile
 | 
				
			||||||
@@ -4298,8 +4310,29 @@ Shell:
 | 
				
			|||||||
  - ".bash_logout"
 | 
					  - ".bash_logout"
 | 
				
			||||||
  - ".bash_profile"
 | 
					  - ".bash_profile"
 | 
				
			||||||
  - ".bashrc"
 | 
					  - ".bashrc"
 | 
				
			||||||
 | 
					  - ".cshrc"
 | 
				
			||||||
 | 
					  - ".login"
 | 
				
			||||||
 | 
					  - ".profile"
 | 
				
			||||||
 | 
					  - ".zlogin"
 | 
				
			||||||
 | 
					  - ".zlogout"
 | 
				
			||||||
 | 
					  - ".zprofile"
 | 
				
			||||||
 | 
					  - ".zshenv"
 | 
				
			||||||
 | 
					  - ".zshrc"
 | 
				
			||||||
 | 
					  - 9fs
 | 
				
			||||||
  - PKGBUILD
 | 
					  - PKGBUILD
 | 
				
			||||||
 | 
					  - bash_logout
 | 
				
			||||||
 | 
					  - bash_profile
 | 
				
			||||||
 | 
					  - bashrc
 | 
				
			||||||
 | 
					  - cshrc
 | 
				
			||||||
  - gradlew
 | 
					  - gradlew
 | 
				
			||||||
 | 
					  - login
 | 
				
			||||||
 | 
					  - man
 | 
				
			||||||
 | 
					  - profile
 | 
				
			||||||
 | 
					  - zlogin
 | 
				
			||||||
 | 
					  - zlogout
 | 
				
			||||||
 | 
					  - zprofile
 | 
				
			||||||
 | 
					  - zshenv
 | 
				
			||||||
 | 
					  - zshrc
 | 
				
			||||||
  interpreters:
 | 
					  interpreters:
 | 
				
			||||||
  - ash
 | 
					  - ash
 | 
				
			||||||
  - bash
 | 
					  - bash
 | 
				
			||||||
@@ -4568,6 +4601,9 @@ Tcl:
 | 
				
			|||||||
  - ".tcl"
 | 
					  - ".tcl"
 | 
				
			||||||
  - ".adp"
 | 
					  - ".adp"
 | 
				
			||||||
  - ".tm"
 | 
					  - ".tm"
 | 
				
			||||||
 | 
					  filenames:
 | 
				
			||||||
 | 
					  - owh
 | 
				
			||||||
 | 
					  - starfield
 | 
				
			||||||
  interpreters:
 | 
					  interpreters:
 | 
				
			||||||
  - tclsh
 | 
					  - tclsh
 | 
				
			||||||
  - wish
 | 
					  - wish
 | 
				
			||||||
@@ -4643,6 +4679,7 @@ Text:
 | 
				
			|||||||
  - ".no"
 | 
					  - ".no"
 | 
				
			||||||
  filenames:
 | 
					  filenames:
 | 
				
			||||||
  - COPYING
 | 
					  - COPYING
 | 
				
			||||||
 | 
					  - COPYING.regex
 | 
				
			||||||
  - COPYRIGHT.regex
 | 
					  - COPYRIGHT.regex
 | 
				
			||||||
  - FONTLOG
 | 
					  - FONTLOG
 | 
				
			||||||
  - INSTALL
 | 
					  - INSTALL
 | 
				
			||||||
@@ -4657,6 +4694,7 @@ Text:
 | 
				
			|||||||
  - delete.me
 | 
					  - delete.me
 | 
				
			||||||
  - keep.me
 | 
					  - keep.me
 | 
				
			||||||
  - read.me
 | 
					  - read.me
 | 
				
			||||||
 | 
					  - readme.1st
 | 
				
			||||||
  - test.me
 | 
					  - test.me
 | 
				
			||||||
  tm_scope: none
 | 
					  tm_scope: none
 | 
				
			||||||
  ace_mode: text
 | 
					  ace_mode: text
 | 
				
			||||||
@@ -4844,6 +4882,7 @@ Vim script:
 | 
				
			|||||||
  extensions:
 | 
					  extensions:
 | 
				
			||||||
  - ".vim"
 | 
					  - ".vim"
 | 
				
			||||||
  filenames:
 | 
					  filenames:
 | 
				
			||||||
 | 
					  - ".gvimrc"
 | 
				
			||||||
  - ".nvimrc"
 | 
					  - ".nvimrc"
 | 
				
			||||||
  - ".vimrc"
 | 
					  - ".vimrc"
 | 
				
			||||||
  - _vimrc
 | 
					  - _vimrc
 | 
				
			||||||
@@ -5082,6 +5121,7 @@ XML:
 | 
				
			|||||||
  - ".zcml"
 | 
					  - ".zcml"
 | 
				
			||||||
  filenames:
 | 
					  filenames:
 | 
				
			||||||
  - ".classpath"
 | 
					  - ".classpath"
 | 
				
			||||||
 | 
					  - ".cproject"
 | 
				
			||||||
  - ".project"
 | 
					  - ".project"
 | 
				
			||||||
  - App.config
 | 
					  - App.config
 | 
				
			||||||
  - NuGet.config
 | 
					  - NuGet.config
 | 
				
			||||||
@@ -5190,6 +5230,7 @@ YAML:
 | 
				
			|||||||
  filenames:
 | 
					  filenames:
 | 
				
			||||||
  - ".clang-format"
 | 
					  - ".clang-format"
 | 
				
			||||||
  - ".clang-tidy"
 | 
					  - ".clang-tidy"
 | 
				
			||||||
 | 
					  - ".gemrc"
 | 
				
			||||||
  ace_mode: yaml
 | 
					  ace_mode: yaml
 | 
				
			||||||
  codemirror_mode: yaml
 | 
					  codemirror_mode: yaml
 | 
				
			||||||
  codemirror_mime_type: text/x-yaml
 | 
					  codemirror_mime_type: text/x-yaml
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -42,6 +42,15 @@ class TestSamples < Minitest::Test
 | 
				
			|||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def test_filename_listed
 | 
				
			||||||
 | 
					    Samples.each do |sample|
 | 
				
			||||||
 | 
					      if sample[:filename]
 | 
				
			||||||
 | 
					        listed_filenames = Language[sample[:language]].filenames
 | 
				
			||||||
 | 
					        assert_includes listed_filenames, sample[:filename], "#{sample[:path]} isn't listed as a filename for #{sample[:language]} in languages.yml"
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  # Check that there aren't samples with extensions or interpreters that
 | 
					  # Check that there aren't samples with extensions or interpreters that
 | 
				
			||||||
  # aren't explicitly defined in languages.yml
 | 
					  # aren't explicitly defined in languages.yml
 | 
				
			||||||
  languages_yml = File.expand_path("../../lib/linguist/languages.yml", __FILE__)
 | 
					  languages_yml = File.expand_path("../../lib/linguist/languages.yml", __FILE__)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user