upgrade gopkg.in/editorconfig/editorconfig-core-go.v1 (#8501)
editorconfig-core-go made breaking api changes and has recently released v2.1.1. This change consumes the new api and fixes up any breaking references.lunny/display_deleted_branch2
parent
80655026d2
commit
66e99d722a
@ -0,0 +1 @@
|
|||||||
|
* text=auto
|
@ -0,0 +1,30 @@
|
|||||||
|
---
|
||||||
|
language: go
|
||||||
|
dist: xenial
|
||||||
|
sudo: true
|
||||||
|
|
||||||
|
go:
|
||||||
|
- '1.11.x'
|
||||||
|
- '1.12.x'
|
||||||
|
|
||||||
|
compiler:
|
||||||
|
- gcc
|
||||||
|
|
||||||
|
install:
|
||||||
|
# first we create a directory for the CMake binaries
|
||||||
|
- DEPS_DIR="${TRAVIS_BUILD_DIR}/deps"
|
||||||
|
- mkdir ${DEPS_DIR} && cd ${DEPS_DIR}
|
||||||
|
# we use wget to fetch the cmake binaries
|
||||||
|
- travis_retry wget --no-check-certificate https://cmake.org/files/v3.14/cmake-3.14.6-Linux-x86_64.tar.gz
|
||||||
|
- echo "82e08e50ba921035efa82b859c74c5fbe27d3e49a4003020e3c77618a4e912cd cmake-3.14.6-Linux-x86_64.tar.gz" > sha256sum.txt
|
||||||
|
- sha256sum -c sha256sum.txt
|
||||||
|
- tar -xvf cmake-3.14.6-Linux-x86_64.tar.gz > /dev/null
|
||||||
|
- mv cmake-3.14.6-Linux-x86_64 cmake-install
|
||||||
|
- PATH=${DEPS_DIR}/cmake-install:${DEPS_DIR}/cmake-install/bin:$PATH
|
||||||
|
- cd ${TRAVIS_BUILD_DIR}
|
||||||
|
|
||||||
|
env:
|
||||||
|
- GO111MODULE=on
|
||||||
|
|
||||||
|
script:
|
||||||
|
- make test
|
@ -0,0 +1,20 @@
|
|||||||
|
# Change log
|
||||||
|
|
||||||
|
## v2.1.1 - 2019-08-18
|
||||||
|
|
||||||
|
- Fix a small path bug
|
||||||
|
([#17](https://github.com/editorconfig/editorconfig-core-go/issues/17),
|
||||||
|
[#18](https://github.com/editorconfig/editorconfig-core-go/pull/18)).
|
||||||
|
|
||||||
|
## v2.1.0 - 2019-08-10
|
||||||
|
|
||||||
|
- This package is now *way* more compliant with the Editorconfig definition
|
||||||
|
thanks to a refactor work made by [@greut](https://github.com/greut)
|
||||||
|
([#15](https://github.com/editorconfig/editorconfig-core-go/pull/15)).
|
||||||
|
|
||||||
|
## v2.0.0 - 2019-07-14
|
||||||
|
|
||||||
|
- This project now uses [Go Modules](https://blog.golang.org/using-go-modules)
|
||||||
|
([#14](https://github.com/editorconfig/editorconfig-core-go/pull/14)).
|
||||||
|
- The import path has been changed from `gopkg.in/editorconfig/editorconfig-core-go.v1`
|
||||||
|
to `github.com/editorconfig/editorconfig-core-go/v2`.
|
@ -0,0 +1,5 @@
|
|||||||
|
project(editorconfig-core-go)
|
||||||
|
cmake_minimum_required(VERSION 3.14)
|
||||||
|
enable_testing()
|
||||||
|
set(EDITORCONFIG_CMD ${CMAKE_CURRENT_LIST_DIR}/editorconfig)
|
||||||
|
add_subdirectory(core-test)
|
@ -0,0 +1,19 @@
|
|||||||
|
PROJECT_ROOT_DIR := $(CURDIR)
|
||||||
|
SRC := $(shell git ls-files *.go */*.go)
|
||||||
|
|
||||||
|
.PHONY: bin test test-go test-core submodule
|
||||||
|
|
||||||
|
test: test-go test-core
|
||||||
|
|
||||||
|
submodule:
|
||||||
|
git submodule update --init
|
||||||
|
|
||||||
|
editorconfig: $(SRC)
|
||||||
|
go build ./cmd/editorconfig
|
||||||
|
|
||||||
|
test-go:
|
||||||
|
go test -v ./...
|
||||||
|
|
||||||
|
test-core: editorconfig
|
||||||
|
cd core-test; cmake ..
|
||||||
|
cd core-test; ctest -E "(comments_after_section|octothorpe|unset_|_pre_0.9.0|max_|root_file_mixed_case)" --output-on-failure .
|
@ -0,0 +1,177 @@
|
|||||||
|
package editorconfig
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"regexp"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// findLeftBrackets matches the opening left bracket {
|
||||||
|
findLeftBrackets = regexp.MustCompile(`(^|[^\\])\{`)
|
||||||
|
// findLeftBrackets matches the closing right bracket {
|
||||||
|
findRightBrackets = regexp.MustCompile(`(^|[^\\])\}`)
|
||||||
|
// findNumericRange matches a range of number, e.g. -2..5
|
||||||
|
findNumericRange = regexp.MustCompile(`^([+-]?\d+)\.\.([+-]?\d+)$`)
|
||||||
|
)
|
||||||
|
|
||||||
|
// FnmatchCase tests whether the name matches the given pattern case included.
|
||||||
|
func FnmatchCase(pattern, name string) (bool, error) {
|
||||||
|
p, err := translate(pattern)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
r, err := regexp.Compile(fmt.Sprintf("^%s$", p))
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return r.MatchString(name), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func translate(pattern string) (string, error) {
|
||||||
|
index := 0
|
||||||
|
pat := []rune(pattern)
|
||||||
|
length := len(pat)
|
||||||
|
|
||||||
|
result := strings.Builder{}
|
||||||
|
|
||||||
|
braceLevel := 0
|
||||||
|
isEscaped := false
|
||||||
|
inBrackets := false
|
||||||
|
|
||||||
|
matchesBraces := len(findLeftBrackets.FindAllString(pattern, -1)) == len(findRightBrackets.FindAllString(pattern, -1))
|
||||||
|
|
||||||
|
for index < length {
|
||||||
|
r := pat[index]
|
||||||
|
index++
|
||||||
|
|
||||||
|
if r == '*' {
|
||||||
|
p := index
|
||||||
|
if p < length && pat[p] == '*' {
|
||||||
|
result.WriteString(".*")
|
||||||
|
index++
|
||||||
|
} else {
|
||||||
|
result.WriteString("[^/]*")
|
||||||
|
}
|
||||||
|
} else if r == '/' {
|
||||||
|
p := index
|
||||||
|
if p+2 < length && pat[p] == '*' && pat[p+1] == '*' && pat[p+2] == '/' {
|
||||||
|
result.WriteString("(?:/|/.*/)")
|
||||||
|
index += 3
|
||||||
|
} else {
|
||||||
|
result.WriteRune(r)
|
||||||
|
}
|
||||||
|
} else if r == '?' {
|
||||||
|
result.WriteString("[^/]")
|
||||||
|
} else if r == '[' {
|
||||||
|
if inBrackets {
|
||||||
|
result.WriteString("\\[")
|
||||||
|
} else {
|
||||||
|
hasSlash := false
|
||||||
|
res := strings.Builder{}
|
||||||
|
|
||||||
|
p := index
|
||||||
|
for p < length {
|
||||||
|
if pat[p] == ']' && pat[p-1] != '\\' {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
res.WriteRune(pat[p])
|
||||||
|
if pat[p] == '/' && pat[p-1] != '\\' {
|
||||||
|
hasSlash = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
p++
|
||||||
|
}
|
||||||
|
if hasSlash {
|
||||||
|
result.WriteString("\\[" + res.String())
|
||||||
|
index = p + 1
|
||||||
|
} else {
|
||||||
|
inBrackets = true
|
||||||
|
if index < length && pat[index] == '!' || pat[index] == '^' {
|
||||||
|
index++
|
||||||
|
result.WriteString("[^")
|
||||||
|
} else {
|
||||||
|
result.WriteRune('[')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if r == ']' {
|
||||||
|
if inBrackets && pat[index-2] == '\\' {
|
||||||
|
result.WriteString("\\]")
|
||||||
|
} else {
|
||||||
|
result.WriteRune(r)
|
||||||
|
inBrackets = false
|
||||||
|
}
|
||||||
|
} else if r == '{' {
|
||||||
|
hasComma := false
|
||||||
|
p := index
|
||||||
|
res := strings.Builder{}
|
||||||
|
|
||||||
|
for p < length {
|
||||||
|
if pat[p] == '}' && pat[p-1] != '\\' {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
res.WriteRune(pat[p])
|
||||||
|
if pat[p] == ',' && pat[p-1] != '\\' {
|
||||||
|
hasComma = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
p++
|
||||||
|
}
|
||||||
|
|
||||||
|
if !hasComma && p < length {
|
||||||
|
inner := res.String()
|
||||||
|
sub := findNumericRange.FindStringSubmatch(inner)
|
||||||
|
if len(sub) == 3 {
|
||||||
|
from, _ := strconv.Atoi(sub[1])
|
||||||
|
to, _ := strconv.Atoi(sub[2])
|
||||||
|
result.WriteString("(?:")
|
||||||
|
// XXX does not scale well
|
||||||
|
for i := from; i < to; i++ {
|
||||||
|
result.WriteString(strconv.Itoa(i))
|
||||||
|
result.WriteRune('|')
|
||||||
|
}
|
||||||
|
result.WriteString(strconv.Itoa(to))
|
||||||
|
result.WriteRune(')')
|
||||||
|
} else {
|
||||||
|
r, _ := translate(inner)
|
||||||
|
result.WriteString(fmt.Sprintf("\\{%s\\}", r))
|
||||||
|
}
|
||||||
|
index = p + 1
|
||||||
|
} else if matchesBraces {
|
||||||
|
result.WriteString("(?:")
|
||||||
|
braceLevel++
|
||||||
|
} else {
|
||||||
|
result.WriteString("\\{")
|
||||||
|
}
|
||||||
|
} else if r == '}' {
|
||||||
|
if braceLevel > 0 {
|
||||||
|
if isEscaped {
|
||||||
|
result.WriteRune('}')
|
||||||
|
isEscaped = false
|
||||||
|
} else {
|
||||||
|
result.WriteRune(')')
|
||||||
|
braceLevel--
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result.WriteString("\\}")
|
||||||
|
}
|
||||||
|
} else if r == ',' {
|
||||||
|
if braceLevel == 0 || isEscaped {
|
||||||
|
result.WriteRune(r)
|
||||||
|
} else {
|
||||||
|
result.WriteRune('|')
|
||||||
|
}
|
||||||
|
} else if r != '\\' || isEscaped {
|
||||||
|
result.WriteString(regexp.QuoteMeta(string(r)))
|
||||||
|
isEscaped = false
|
||||||
|
} else {
|
||||||
|
isEscaped = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.String(), nil
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
module github.com/editorconfig/editorconfig-core-go/v2
|
||||||
|
|
||||||
|
go 1.12
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a // indirect
|
||||||
|
github.com/stretchr/testify v1.3.0
|
||||||
|
gopkg.in/ini.v1 v1.42.0
|
||||||
|
)
|
@ -0,0 +1,22 @@
|
|||||||
|
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||||
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
|
||||||
|
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||||
|
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
|
||||||
|
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
|
||||||
|
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||||
|
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a h1:pa8hGb/2YqsZKovtsgrwcDH1RZhVbTKCjLp47XpqCDs=
|
||||||
|
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||||
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
|
||||||
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
|
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
|
gopkg.in/ini.v1 v1.42.0 h1:7N3gPTt50s8GuLortA00n8AqRTk75qOP98+mTPpgzRk=
|
||||||
|
gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
@ -1,5 +0,0 @@
|
|||||||
* text eol=lf
|
|
||||||
*.jpg binary
|
|
||||||
*.jpeg binary
|
|
||||||
*.png binary
|
|
||||||
*.ico binary
|
|
@ -1,14 +0,0 @@
|
|||||||
---
|
|
||||||
language: go
|
|
||||||
sudo: false
|
|
||||||
go:
|
|
||||||
- '1.8'
|
|
||||||
- '1.9'
|
|
||||||
- '1.10'
|
|
||||||
go_import_path: gopkg.in/editorconfig/editorconfig-core-go.v1
|
|
||||||
|
|
||||||
install:
|
|
||||||
- make installdeps
|
|
||||||
|
|
||||||
script:
|
|
||||||
- make test
|
|
@ -1,25 +0,0 @@
|
|||||||
PROJECT_ROOT_DIR := $(CURDIR)
|
|
||||||
SRC := editorconfig.go cmd/editorconfig/main.go
|
|
||||||
|
|
||||||
.PHONY: bin test test-go test-core submodule installdeps
|
|
||||||
|
|
||||||
test: test-go test-core
|
|
||||||
|
|
||||||
submodule:
|
|
||||||
git submodule update --init
|
|
||||||
|
|
||||||
installdeps:
|
|
||||||
go get -t ./...
|
|
||||||
|
|
||||||
editorconfig: $(SRC)
|
|
||||||
go build ./cmd/editorconfig
|
|
||||||
|
|
||||||
test-go:
|
|
||||||
go test -v
|
|
||||||
|
|
||||||
test-core: editorconfig
|
|
||||||
cd $(PROJECT_ROOT_DIR)/core-test && \
|
|
||||||
cmake -DEDITORCONFIG_CMD="$(PROJECT_ROOT_DIR)/editorconfig" .
|
|
||||||
# Temporarily disable core-test
|
|
||||||
# cd $(PROJECT_ROOT_DIR)/core-test && \
|
|
||||||
# ctest --output-on-failure .
|
|
Loading…
Reference in new issue