Skip to content

Commit

Permalink
Merge pull request #130 from mcarmonaa/fix/get-header-footer
Browse files Browse the repository at this point in the history
Fixing getHeaderAndFooter issues
  • Loading branch information
abeaumont authored Nov 10, 2017
2 parents ce5adee + 0984e07 commit c256de1
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: go

go:
- 1.8
- 1.9.x
- tip

addons:
Expand Down
5 changes: 5 additions & 0 deletions common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 3 additions & 1 deletion common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"}},
Expand Down
2 changes: 1 addition & 1 deletion data/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions data/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion data/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion data/documentation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion data/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
2 changes: 1 addition & 1 deletion data/filename.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
2 changes: 1 addition & 1 deletion data/frequencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion data/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
2 changes: 1 addition & 1 deletion data/mimeType.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion data/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion data/vendor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit c256de1

Please sign in to comment.