Merge pull request #130 from mcarmonaa/fix/get-header-footer

Fixing getHeaderAndFooter issues
This commit is contained in:
Alfredo Beaumont 2017-11-10 09:37:39 +01:00 committed by GitHub
commit c256de15c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 21 additions and 14 deletions

View File

@ -1,7 +1,7 @@
language: go
go:
- 1.8
- 1.9.x
- tip
addons:

View File

@ -158,6 +158,11 @@ var modelinesFunc = []Strategy{
func getHeaderAndFooter(content []byte) []byte {
const searchScope = 5
if len(content) == 0 {
return content
}
if bytes.Count(content, []byte("\n")) < 2*searchScope {
return content
}

View File

@ -157,6 +157,8 @@ func (s *EnryTestSuite) TestGetLanguagesByModeline() {
{name: "TestGetLanguagesByModeline_1", content: []byte(wrongVim), expected: nil},
{name: "TestGetLanguagesByModeline_2", content: []byte(rightVim), expected: []string{"Python"}},
{name: "TestGetLanguagesByModeline_3", content: []byte(noLangVim), expected: nil},
{name: "TestGetLanguagesByModeline_4", content: nil, expected: nil},
{name: "TestGetLanguagesByModeline_5", content: []byte{}, expected: nil},
}
for _, test := range tests {
@ -217,7 +219,7 @@ println("The shell script says ",vm.arglist.concat(" "));`
{name: "TestGetLanguagesByShebang_3", content: []byte(`#!/usr/bin/env`), expected: nil},
{name: "TestGetLanguagesByShebang_4", content: []byte(`#!/usr/bin/python -tt`), expected: []string{"Python"}},
{name: "TestGetLanguagesByShebang_5", content: []byte(`#!/usr/bin/env python2.6`), expected: []string{"Python"}},
{name: "TestGetLanguagesByShebang_6", content: []byte(`#!/usr/bin/env perl`), expected: []string{"Perl"}},
{name: "TestGetLanguagesByShebang_6", content: []byte(`#!/usr/bin/env perl`), expected: []string{"Perl", "Pod"}},
{name: "TestGetLanguagesByShebang_7", content: []byte(`#! /bin/sh`), expected: []string{"Shell"}},
{name: "TestGetLanguagesByShebang_8", content: []byte(`#!bash`), expected: []string{"Shell"}},
{name: "TestGetLanguagesByShebang_9", content: []byte(multilineExecHack), expected: []string{"Tcl"}},

View File

@ -2,7 +2,7 @@ package data
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
// THIS FILE SHOULD NOT BE EDITED BY HAND
// Extracted from github/linguist commit: e98728595bc2f3e72b0668d60e31cbe441c48799
// Extracted from github/linguist commit: 4cd558c37482e8d2c535d8107f2d11b49afbc5b5
// LanguagesByAlias keeps alias for different languages and use the name of the languages as an alias too.
// All the keys (alias or not) are written in lower case and the whitespaces has been replaced by underscores.

View File

@ -2,7 +2,7 @@ package data
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
// THIS FILE SHOULD NOT BE EDITED BY HAND
// Extracted from github/linguist commit: e98728595bc2f3e72b0668d60e31cbe441c48799
// Extracted from github/linguist commit: 4cd558c37482e8d2c535d8107f2d11b49afbc5b5
// linguist's commit from which files were generated.
var LinguistCommit = "e98728595bc2f3e72b0668d60e31cbe441c48799"
var LinguistCommit = "4cd558c37482e8d2c535d8107f2d11b49afbc5b5"

View File

@ -2,7 +2,7 @@ package data
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
// THIS FILE SHOULD NOT BE EDITED BY HAND
// Extracted from github/linguist commit: e98728595bc2f3e72b0668d60e31cbe441c48799
// Extracted from github/linguist commit: 4cd558c37482e8d2c535d8107f2d11b49afbc5b5
import "gopkg.in/toqueteos/substring.v1"

View File

@ -2,7 +2,7 @@ package data
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
// THIS FILE SHOULD NOT BE EDITED BY HAND
// Extracted from github/linguist commit: e98728595bc2f3e72b0668d60e31cbe441c48799
// Extracted from github/linguist commit: 4cd558c37482e8d2c535d8107f2d11b49afbc5b5
import "gopkg.in/toqueteos/substring.v1"

View File

@ -2,7 +2,7 @@ package data
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
// THIS FILE SHOULD NOT BE EDITED BY HAND
// Extracted from github/linguist commit: e98728595bc2f3e72b0668d60e31cbe441c48799
// Extracted from github/linguist commit: 4cd558c37482e8d2c535d8107f2d11b49afbc5b5
var LanguagesByExtension = map[string][]string{
".1": {"Roff"},

View File

@ -2,7 +2,7 @@ package data
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
// THIS FILE SHOULD NOT BE EDITED BY HAND
// Extracted from github/linguist commit: e98728595bc2f3e72b0668d60e31cbe441c48799
// Extracted from github/linguist commit: 4cd558c37482e8d2c535d8107f2d11b49afbc5b5
var LanguagesByFilename = map[string][]string{
".Rprofile": {"R"},

View File

@ -2,7 +2,7 @@ package data
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
// THIS FILE SHOULD NOT BE EDITED BY HAND
// Extracted from github/linguist commit: e98728595bc2f3e72b0668d60e31cbe441c48799
// Extracted from github/linguist commit: 4cd558c37482e8d2c535d8107f2d11b49afbc5b5
var LanguagesLogProbabilities = map[string]float64{
"1C Enterprise": -5.774552,

View File

@ -2,7 +2,7 @@ package data
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
// THIS FILE SHOULD NOT BE EDITED BY HAND
// Extracted from github/linguist commit: e98728595bc2f3e72b0668d60e31cbe441c48799
// Extracted from github/linguist commit: 4cd558c37482e8d2c535d8107f2d11b49afbc5b5
var LanguagesByInterpreter = map[string][]string{
"Rscript": {"R"},

View File

@ -2,7 +2,7 @@ package data
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
// THIS FILE SHOULD NOT BE EDITED BY HAND
// Extracted from github/linguist commit: e98728595bc2f3e72b0668d60e31cbe441c48799
// Extracted from github/linguist commit: 4cd558c37482e8d2c535d8107f2d11b49afbc5b5
var LanguagesMime = map[string]string{
"AGS Script": "text/x-c++src",

View File

@ -2,7 +2,7 @@ package data
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
// THIS FILE SHOULD NOT BE EDITED BY HAND
// Extracted from github/linguist commit: e98728595bc2f3e72b0668d60e31cbe441c48799
// Extracted from github/linguist commit: 4cd558c37482e8d2c535d8107f2d11b49afbc5b5
var LanguagesType = map[string]int{
"1C Enterprise": 2,

View File

@ -2,7 +2,7 @@ package data
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
// THIS FILE SHOULD NOT BE EDITED BY HAND
// Extracted from github/linguist commit: e98728595bc2f3e72b0668d60e31cbe441c48799
// Extracted from github/linguist commit: 4cd558c37482e8d2c535d8107f2d11b49afbc5b5
import "gopkg.in/toqueteos/substring.v1"