diff options
author | 6543 <6543@obermui.de> | 2020-10-16 07:06:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-16 01:06:27 -0400 |
commit | 12a1f914f443cc31af4bc54ab43802a75742cd57 (patch) | |
tree | 998e159281cf41de8b6d7bb1ab5075b3286ce5a9 /vendor/github.com/editorconfig | |
parent | 91f2afdb546364195ff909186983b94a61ab3181 (diff) | |
download | gitea-12a1f914f443cc31af4bc54ab43802a75742cd57.tar.gz gitea-12a1f914f443cc31af4bc54ab43802a75742cd57.zip |
Vendor Update Go Libs (#13166)
* update github.com/alecthomas/chroma v0.8.0 -> v0.8.1
* github.com/blevesearch/bleve v1.0.10 -> v1.0.12
* editorconfig-core-go v2.1.1 -> v2.3.7
* github.com/gliderlabs/ssh v0.2.2 -> v0.3.1
* migrate editorconfig.ParseBytes to Parse
* github.com/shurcooL/vfsgen to 0d455de96546
* github.com/go-git/go-git/v5 v5.1.0 -> v5.2.0
* github.com/google/uuid v1.1.1 -> v1.1.2
* github.com/huandu/xstrings v1.3.0 -> v1.3.2
* github.com/klauspost/compress v1.10.11 -> v1.11.1
* github.com/markbates/goth v1.61.2 -> v1.65.0
* github.com/mattn/go-sqlite3 v1.14.0 -> v1.14.4
* github.com/mholt/archiver v3.3.0 -> v3.3.2
* github.com/microcosm-cc/bluemonday 4f7140c49acb -> v1.0.4
* github.com/minio/minio-go v7.0.4 -> v7.0.5
* github.com/olivere/elastic v7.0.9 -> v7.0.20
* github.com/urfave/cli v1.20.0 -> v1.22.4
* github.com/prometheus/client_golang v1.1.0 -> v1.8.0
* github.com/xanzy/go-gitlab v0.37.0 -> v0.38.1
* mvdan.cc/xurls v2.1.0 -> v2.2.0
Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'vendor/github.com/editorconfig')
19 files changed, 846 insertions, 282 deletions
diff --git a/vendor/github.com/editorconfig/editorconfig-core-go/v2/.editorconfig b/vendor/github.com/editorconfig/editorconfig-core-go/v2/.editorconfig index aca7129072..c664663bbe 100644 --- a/vendor/github.com/editorconfig/editorconfig-core-go/v2/.editorconfig +++ b/vendor/github.com/editorconfig/editorconfig-core-go/v2/.editorconfig @@ -1,4 +1,4 @@ -; http://editorconfig.org/ +; https://editorconfig.org/ root = true @@ -9,6 +9,15 @@ trim_trailing_whitespace = true indent_style = space indent_size = 2 -[{Makefile,go.mod,go.sum,*.go}] +[{Makefile,go.mod,go.sum,*.go,.gitmodules}] indent_style = tab indent_size = 8 + +[*.md] +indent_size = 4 +trim_trailing_whitespace = false + +eclint_indent_style = unset + +[Dockerfile] +indent_size = 4 diff --git a/vendor/github.com/editorconfig/editorconfig-core-go/v2/.golangci.yml b/vendor/github.com/editorconfig/editorconfig-core-go/v2/.golangci.yml new file mode 100644 index 0000000000..f8ec52a586 --- /dev/null +++ b/vendor/github.com/editorconfig/editorconfig-core-go/v2/.golangci.yml @@ -0,0 +1,19 @@ +linters-settings: + golint: + min-confidence: 0.3 + +linters: + enable: + - goconst + - gocyclo + - goerr113 + - gofmt + - godox + - golint + - gocritic + - megacheck + - misspell + - prealloc + - unparam + - scopelint + - wsl diff --git a/vendor/github.com/editorconfig/editorconfig-core-go/v2/.goreleaser.yml b/vendor/github.com/editorconfig/editorconfig-core-go/v2/.goreleaser.yml new file mode 100644 index 0000000000..0ba62f8e5a --- /dev/null +++ b/vendor/github.com/editorconfig/editorconfig-core-go/v2/.goreleaser.yml @@ -0,0 +1,74 @@ +project_name: editorconfig-core-go + +before: + hooks: + - go mod tidy + +builds: +- id: editorconfig + main: ./cmd/editorconfig/main.go + binary: editorconfig + env: + - CGO_ENABLED=0 + goos: + - linux + - darwin + - windows + +archives: +- id: tarball + builds: + - editorconfig + format_overrides: + - goos: windows + format: zip + files: + - none* + +dockers: +- image_templates: + - docker.pkg.github.com/editorconfig/editorconfig-core-go/editorconfig:latest + - docker.pkg.github.com/editorconfig/editorconfig-core-go/editorconfig:{{ .Tag }} + - docker.pkg.github.com/editorconfig/editorconfig-core-go/editorconfig:v{{ .Major }} + - docker.pkg.github.com/editorconfig/editorconfig-core-go/editorconfig:v{{ .Major }}.{{ .Minor }} + goos: linux + goarch: amd64 + binaries: + - editorconfig + build_flag_templates: + - "--pull" + - "--label=org.label-schema.schema-version=1.0" + - "--label=org.label-schema.version={{ .Version }}" + - "--label=org.label-schema.name={{ .ProjectName }}" + +nfpms: +- vendor: EditorConfig + homepage: https://github.com/editorconfig/editorconfig-core-go + maintainer: Yoan Blanc <yoan@dosimple.ch> + formats: + - deb + - rpm + epoch: 1 + release: 1 + +checksum: + name_template: 'checksums.txt' + +signs: +- artifacts: checksum + +snapshot: + name_template: "{{ .Tag }}-development" + +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' + +release: + github: + owner: editorconfig + name: editorconfig-core-go + draft: true diff --git a/vendor/github.com/editorconfig/editorconfig-core-go/v2/.travis.yml b/vendor/github.com/editorconfig/editorconfig-core-go/v2/.travis.yml deleted file mode 100644 index 9a1fdf77df..0000000000 --- a/vendor/github.com/editorconfig/editorconfig-core-go/v2/.travis.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -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 diff --git a/vendor/github.com/editorconfig/editorconfig-core-go/v2/CHANGELOG.md b/vendor/github.com/editorconfig/editorconfig-core-go/v2/CHANGELOG.md index c09da69744..a508b5bf77 100644 --- a/vendor/github.com/editorconfig/editorconfig-core-go/v2/CHANGELOG.md +++ b/vendor/github.com/editorconfig/editorconfig-core-go/v2/CHANGELOG.md @@ -1,5 +1,104 @@ # Change log +## v2.3.7 - 2020-09-05 + +- Upgrade go-ini v1.60.2, and go-cmp v0.5.2 + ([#81](https://github.com/editorconfig/editorconfig-core-go/pull/81)). + +## v2.3.6 - 2020-08-25 + +- Use goerr113 linter + ([#77](https://github.com/editorconfig/editorconfig-core-go/pull/77)); +- Upgrade go-ini v1.60.0 + ([#78](https://github.com/editorconfig/editorconfig-core-go/pull/78)); +- Upgrade go-ini v1.60.1 + ([#79](https://github.com/editorconfig/editorconfig-core-go/pull/79)). + +## v2.3.5 - 2020-08-20 + +- Upgrade go-cmp v0.5.1 + ([#73](https://github.com/editorconfig/editorconfig-core-go/pull/73)); +- Replace custom GitHub Action with official GolangCI Lint + ([#74](https://github.com/editorconfig/editorconfig-core-go/pull/74)); +- Upgrade go-ini v1.58.0 + ([#75](https://github.com/editorconfig/editorconfig-core-go/pull/75)). + +## v2.3.4 - 2020-06-22 + +- Wrap errors using Go 1.13 syntax + ([#61](https://github.com/editorconfig/editorconfig-core-go/pull/61)); +- Upgrade base Docker image + ([#68](https://github.com/editorconfig/editorconfig-core-go/pull/68)); +- Upgrade go-ini v1.57.0, go-cmp v0.5.0 + ([#70](https://github.com/editorconfig/editorconfig-core-go/pull/70)). + +## v2.3.3 - 2020-05-19 + +- Using goreleaser + ([#22](https://github.com/editorconfig/editorconfig-core-go/pull/22)); +- Upgrade go-cmp, go-ini, x/mod + ([#60](https://github.com/editorconfig/editorconfig-core-go/pull/65)); +- Update CI actions + ([#63](https://github.com/editorconfig/editorconfig-core-go/pull/63)); + +## v2.3.2 - 2020-04-21 + +- Upgrade go-ini v1.55.0 + ([#60](https://github.com/editorconfig/editorconfig-core-go/pull/60)); +- Build on latest Go + ([#54](https://github.com/editorconfig/editorconfig-core-go/pull/54)); +- Use GitHub action instead of Travis CI + ([#50](https://github.com/editorconfig/editorconfig-core-go/pull/50)); + +## v2.3.1 - 2020-03-16 + +- Use golang/x/mod/semver for semantic versioning checks + ([#55](https://github.com/editorconfig/editorconfig-core-go/pull/55)); +- Enable wsl (WhiteSpace linter) + ([#56](https://github.com/editorconfig/editorconfig-core-go/pull/56)); +- Replace testify dependency with Google's go-cmp + ([#57](https://github.com/editorconfig/editorconfig-core-go/pull/57)); +- Upgrade go-ini to v1.54.0 + ([#58](https://github.com/editorconfig/editorconfig-core-go/pull/58)). + +## v2.3.0 - 2020-02-14 + +- Implement a cached `Parser` to allow getting the definition of many files + at once without re-reading the `.editorconfig` or parsing the _globbing_ + expression more than once. + ([#51](https://github.com/editorconfig/editorconfig-core-go/pull/51)); +- Run golangci-lint on travis + ([#26](https://github.com/editorconfig/editorconfig-core-go/pull/26)). + +## v2.2.2 - 2020-01-19 + +- Bump core test to master + ([#42](https://github.com/editorconfig/editorconfig-core-go/pull/42)); +- Bugfix error mangled when reading a file which could create a panic + ([#47](https://github.com/editorconfig/editorconfig-core-go/pull/47)); +- Bugfix INI file generated would not show the correct value + ([#46](https://github.com/editorconfig/editorconfig-core-go/pull/46)). + +## v2.2.1 - 2019-11-10 + +- Implement pre 0.9.0 behavior + ([#39](https://github.com/editorconfig/editorconfig-core-go/pull/39)); +- Fix values inheritance (regression) + ([#43](https://github.com/editorconfig/editorconfig-core-go/pull/43)). + +## v2.2.0 - 2019-10-12 + +- Allow parsing from an `io.Reader`, effectively deprecating `ParseBytes` + by [@mvdan](https://github.com/mvdan) + ([#32](https://github.com/editorconfig/editorconfig-core-go/pull/32)); +- Add support for the special `unset` value by [@greut](https://github.com/greut) + ([#19](https://github.com/editorconfig/editorconfig-core-go/pull/19)); +- Skip values, properties or section that are considered too long + ([#35](https://github.com/editorconfig/editorconfig-core-go/pull/35)); +- Clean up and documentation work by [@mstruebing](https://github.com/mstruebing/) + ([#23](https://github.com/editorconfig/editorconfig-core-go/pull/23), + [#24](https://github.com/editorconfig/editorconfig-core-go/pull/24)). + ## v2.1.1 - 2019-08-18 - Fix a small path bug @@ -15,6 +114,6 @@ ## 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)). + ([#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`. diff --git a/vendor/github.com/editorconfig/editorconfig-core-go/v2/CMakeLists.txt b/vendor/github.com/editorconfig/editorconfig-core-go/v2/CMakeLists.txt index 1ebcf1d173..89c9608493 100644 --- a/vendor/github.com/editorconfig/editorconfig-core-go/v2/CMakeLists.txt +++ b/vendor/github.com/editorconfig/editorconfig-core-go/v2/CMakeLists.txt @@ -1,5 +1,5 @@ project(editorconfig-core-go) -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.13) enable_testing() set(EDITORCONFIG_CMD ${CMAKE_CURRENT_LIST_DIR}/editorconfig) add_subdirectory(core-test) diff --git a/vendor/github.com/editorconfig/editorconfig-core-go/v2/Dockerfile b/vendor/github.com/editorconfig/editorconfig-core-go/v2/Dockerfile new file mode 100644 index 0000000000..c913170ef2 --- /dev/null +++ b/vendor/github.com/editorconfig/editorconfig-core-go/v2/Dockerfile @@ -0,0 +1,5 @@ +FROM linuxkit/ca-certificates:v0.8 + +COPY editorconfig /usr/local/bin/ + +ENTRYPOINT [ "editorconfig" ] diff --git a/vendor/github.com/editorconfig/editorconfig-core-go/v2/Makefile b/vendor/github.com/editorconfig/editorconfig-core-go/v2/Makefile index eff4473ddf..94c5211149 100644 --- a/vendor/github.com/editorconfig/editorconfig-core-go/v2/Makefile +++ b/vendor/github.com/editorconfig/editorconfig-core-go/v2/Makefile @@ -1,7 +1,7 @@ PROJECT_ROOT_DIR := $(CURDIR) SRC := $(shell git ls-files *.go */*.go) -.PHONY: bin test test-go test-core submodule +.PHONY: bin test test-go test-core test-skipped submodule test: test-go test-core @@ -9,11 +9,27 @@ submodule: git submodule update --init editorconfig: $(SRC) - go build ./cmd/editorconfig + go build \ + -ldflags "-X main.version=1.99.99" \ + github.com/editorconfig/editorconfig-core-go/v2/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 . + cd core-test; \ + cmake .. + cd core-test; \ + ctest \ + -E "^octothorpe_in_value$$" \ + --output-on-failure \ + . + +test-skipped: editorconfig + cd core-test; \ + cmake .. + cd core-test; \ + ctest \ + -R "^octothorpe_in_value$$" \ + --show-only \ + . diff --git a/vendor/github.com/editorconfig/editorconfig-core-go/v2/README.md b/vendor/github.com/editorconfig/editorconfig-core-go/v2/README.md index 784e37cf54..31823b533e 100644 --- a/vendor/github.com/editorconfig/editorconfig-core-go/v2/README.md +++ b/vendor/github.com/editorconfig/editorconfig-core-go/v2/README.md @@ -1,5 +1,4 @@ -<!-- Currently tests against core-test are not done so hide build status badge for now --> -<!-- [![Build Status](https://travis-ci.org/editorconfig/editorconfig-core-go.svg?branch=master)](https://travis-ci.org/editorconfig/editorconfig-core-go) --> +![Build Status](https://github.com/editorconfig/editorconfig-core-go/workflows/.github/workflows/main.yml/badge.svg) [![GoDoc](https://godoc.org/github.com/editorconfig/editorconfig-core-go?status.svg)](https://godoc.org/github.com/editorconfig/editorconfig-core-go) [![Go Report Card](https://goreportcard.com/badge/github.com/editorconfig/editorconfig-core-go)](https://goreportcard.com/report/github.com/editorconfig/editorconfig-core-go) @@ -7,25 +6,19 @@ A [Editorconfig][editorconfig] file parser and manipulator for Go. -> Currently this package does some basic work but does not fully support -> EditorConfig specs, so using it in "real world" is not recommended. - ## Missing features -- `unset` - escaping comments in values, probably in [go-ini/ini](https://github.com/go-ini/ini) ## Installing -We recommend the use of Go 1.11+ modules for this package. +We recommend the use of Go 1.13+ modules for this package. Import by the same path. The package name you will use to access it is `editorconfig`. ```go -import ( - "github.com/editorconfig/editorconfig-core-go/v2" -) +import "github.com/editorconfig/editorconfig-core-go/v2" ``` ## Usage @@ -33,9 +26,15 @@ import ( ### Parse from file ```go -editorConfig, err := editorconfig.ParseFile("path/to/.editorconfig") +fp, err := os.Open("path/to/.editorconfig") +if err != nil { + log.Fatal(err) +} +defer fp.Close() + +editorConfig, err := editorconfig.Parse(fp) if err != nil { - log.Fatal(err) + log.Fatal(err) } ``` @@ -45,7 +44,7 @@ if err != nil { data := []byte("...") editorConfig, err := editorconfig.ParseBytes(data) if err != nil { - log.Fatal(err) + log.Fatal(err) } ``` @@ -71,8 +70,8 @@ type Definition struct { IndentSize string TabWidth int EndOfLine string - TrimTrailingWhitespace bool - InsertFinalNewline bool + TrimTrailingWhitespace *bool + InsertFinalNewline *bool Raw map[string]string } ``` @@ -104,13 +103,13 @@ You can easily convert a Editorconfig struct to a compatible INI file: // serialize to slice of bytes data, err := editorConfig.Serialize() if err != nil { - log.Fatal(err) + log.Fatal(err) } // save directly to file err := editorConfig.Save("path/to/.editorconfig") if err != nil { - log.Fatal(err) + log.Fatal(err) } ``` @@ -122,4 +121,10 @@ To run the tests: go test -v ./... ``` -[editorconfig]: http://editorconfig.org/ +To run the [integration tests](https://github.com/editorconfig/editorconfig-core-test): + +``` +make test-core +``` + +[editorconfig]: https://editorconfig.org/ diff --git a/vendor/github.com/editorconfig/editorconfig-core-go/v2/cached_parser.go b/vendor/github.com/editorconfig/editorconfig-core-go/v2/cached_parser.go new file mode 100644 index 0000000000..23ff80c45f --- /dev/null +++ b/vendor/github.com/editorconfig/editorconfig-core-go/v2/cached_parser.go @@ -0,0 +1,70 @@ +package editorconfig + +import ( + "fmt" + "os" + "regexp" + + "gopkg.in/ini.v1" +) + +// CachedParser implements the Parser interface but caches the definition and +// the regular expressions. +type CachedParser struct { + editorconfigs map[string]*Editorconfig + regexps map[string]*regexp.Regexp +} + +// NewCachedParser initializes the CachedParser. +func NewCachedParser() *CachedParser { + return &CachedParser{ + editorconfigs: make(map[string]*Editorconfig), + regexps: make(map[string]*regexp.Regexp), + } +} + +// ParseIni parses the given filename to a Definition and caches the result. +func (parser *CachedParser) ParseIni(filename string) (*Editorconfig, error) { + ec, ok := parser.editorconfigs[filename] + if !ok { + fp, err := os.Open(filename) + if err != nil { + return nil, err + } + + defer fp.Close() + + iniFile, err := ini.Load(fp) + if err != nil { + return nil, err + } + + ec, err = newEditorconfig(iniFile) + if err != nil { + return nil, err + } + + parser.editorconfigs[filename] = ec + } + + return ec, nil +} + +// FnmatchCase calls the module's FnmatchCase and caches the parsed selector. +func (parser *CachedParser) FnmatchCase(selector string, filename string) (bool, error) { + r, ok := parser.regexps[selector] + if !ok { + p := translate(selector) + + var err error + + r, err = regexp.Compile(fmt.Sprintf("^%s$", p)) + if err != nil { + return false, err + } + + parser.regexps[selector] = r + } + + return r.MatchString(filename), nil +} diff --git a/vendor/github.com/editorconfig/editorconfig-core-go/v2/config.go b/vendor/github.com/editorconfig/editorconfig-core-go/v2/config.go new file mode 100644 index 0000000000..b822a81e1c --- /dev/null +++ b/vendor/github.com/editorconfig/editorconfig-core-go/v2/config.go @@ -0,0 +1,91 @@ +package editorconfig + +import ( + "errors" + "fmt" + "os" + "path/filepath" + "strings" + + "golang.org/x/mod/semver" +) + +// ErrInvalidVersion represents a standard error with the semantic version. +var ErrInvalidVersion = errors.New("invalid semantic version") + +// Config holds the configuration +type Config struct { + Path string + Name string + Version string + Parser Parser +} + +// Load loads definition of a given file. +func (config *Config) Load(filename string) (*Definition, error) { + // idiomatic go allows empty struct + if config.Parser == nil { + config.Parser = new(SimpleParser) + } + + filename, err := filepath.Abs(filename) + if err != nil { + return nil, err + } + + ecFile := config.Name + if ecFile == "" { + ecFile = ConfigNameDefault + } + + definition := &Definition{} + definition.Raw = make(map[string]string) + + if config.Version != "" { + version := config.Version + if !strings.HasPrefix(version, "v") { + version = "v" + version + } + + if ok := semver.IsValid(version); !ok { + return nil, fmt.Errorf("version %s error: %w", config.Version, ErrInvalidVersion) + } + + definition.version = version + } + + dir := filename + for dir != filepath.Dir(dir) { + dir = filepath.Dir(dir) + + ec, err := config.Parser.ParseIni(filepath.Join(dir, ecFile)) + if err != nil { + if os.IsNotExist(err) { + continue + } + + return nil, err + } + + // give it the current config. + ec.config = config + + relativeFilename := filename + if len(dir) < len(relativeFilename) { + relativeFilename = relativeFilename[len(dir):] + } + + def, err := ec.GetDefinitionForFilename(relativeFilename) + if err != nil { + return nil, err + } + + definition.merge(def) + + if ec.Root { + break + } + } + + return definition, nil +} diff --git a/vendor/github.com/editorconfig/editorconfig-core-go/v2/definition.go b/vendor/github.com/editorconfig/editorconfig-core-go/v2/definition.go new file mode 100644 index 0000000000..527a1f131e --- /dev/null +++ b/vendor/github.com/editorconfig/editorconfig-core-go/v2/definition.go @@ -0,0 +1,194 @@ +package editorconfig + +import ( + "fmt" + "strconv" + "strings" + + "golang.org/x/mod/semver" + "gopkg.in/ini.v1" +) + +// Definition represents a definition inside the .editorconfig file. +// E.g. a section of the file. +// The definition is composed of the selector ("*", "*.go", "*.{js.css}", etc), +// plus the properties of the selected files. +type Definition struct { + Selector string `ini:"-" json:"-"` + + Charset string `ini:"charset" json:"charset,omitempty"` + IndentStyle string `ini:"indent_style" json:"indent_style,omitempty"` + IndentSize string `ini:"indent_size" json:"indent_size,omitempty"` + TabWidth int `ini:"-" json:"-"` + EndOfLine string `ini:"end_of_line" json:"end_of_line,omitempty"` + TrimTrailingWhitespace *bool `ini:"-" json:"-"` + InsertFinalNewline *bool `ini:"-" json:"-"` + Raw map[string]string `ini:"-" json:"-"` + version string +} + +// NewDefinition builds a definition from a given config. +func NewDefinition(config Config) (*Definition, error) { + return config.Load(config.Path) +} + +// normalize fixes some values to their lowercase value. +func (d *Definition) normalize() error { + d.Charset = strings.ToLower(d.Charset) + d.EndOfLine = strings.ToLower(d.Raw["end_of_line"]) + d.IndentStyle = strings.ToLower(d.Raw["indent_style"]) + + trimTrailingWhitespace, ok := d.Raw["trim_trailing_whitespace"] + if ok && trimTrailingWhitespace != UnsetValue { + trim, err := strconv.ParseBool(trimTrailingWhitespace) + if err != nil { + return fmt.Errorf("trim_trailing_whitespace=%s is not an acceptable value. %w", trimTrailingWhitespace, err) + } + + d.TrimTrailingWhitespace = &trim + } + + insertFinalNewline, ok := d.Raw["insert_final_newline"] + if ok && insertFinalNewline != UnsetValue { + insert, err := strconv.ParseBool(insertFinalNewline) + if err != nil { + return fmt.Errorf("insert_final_newline=%s is not an acceptable value. %w", insertFinalNewline, err) + } + + d.InsertFinalNewline = &insert + } + + // tab_width from Raw + tabWidth, ok := d.Raw["tab_width"] + if ok && tabWidth != UnsetValue { + num, err := strconv.Atoi(tabWidth) + if err != nil { + return fmt.Errorf("tab_width=%s is not an acceptable value. %w", tabWidth, err) + } + + d.TabWidth = num + } + + // tab_width defaults to indent_size: + // https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties#tab_width + num, err := strconv.Atoi(d.IndentSize) + if err == nil && d.TabWidth <= 0 { + d.TabWidth = num + } + + return nil +} + +// merge the parent definition into the child definition. +func (d *Definition) merge(md *Definition) { + if len(d.Charset) == 0 { + d.Charset = md.Charset + } + + if len(d.IndentStyle) == 0 { + d.IndentStyle = md.IndentStyle + } + + if len(d.IndentSize) == 0 { + d.IndentSize = md.IndentSize + } + + if d.TabWidth <= 0 { + d.TabWidth = md.TabWidth + } + + if len(d.EndOfLine) == 0 { + d.EndOfLine = md.EndOfLine + } + + if trimTrailingWhitespace, ok := d.Raw["trim_trailing_whitespace"]; !ok || trimTrailingWhitespace != UnsetValue { + if d.TrimTrailingWhitespace == nil { + d.TrimTrailingWhitespace = md.TrimTrailingWhitespace + } + } + + if insertFinalNewline, ok := d.Raw["insert_final_newline"]; !ok || insertFinalNewline != UnsetValue { + if d.InsertFinalNewline == nil { + d.InsertFinalNewline = md.InsertFinalNewline + } + } + + for k, v := range md.Raw { + if _, ok := d.Raw[k]; !ok { + d.Raw[k] = v + } + } +} + +// InsertToIniFile writes the definition into a ini file. +func (d *Definition) InsertToIniFile(iniFile *ini.File) { + iniSec := iniFile.Section(d.Selector) + + for k, v := range d.Raw { + switch k { + case "insert_final_newline": + if d.InsertFinalNewline != nil { + v = strconv.FormatBool(*d.InsertFinalNewline) + } else { + insertFinalNewline, ok := d.Raw["insert_final_newline"] + if !ok { + break + } + + v = strings.ToLower(insertFinalNewline) + } + case "trim_trailing_whitespace": + if d.TrimTrailingWhitespace != nil { + v = strconv.FormatBool(*d.TrimTrailingWhitespace) + } else { + trimTrailingWhitespace, ok := d.Raw["trim_trailing_whitespace"] + if !ok { + break + } + + v = strings.ToLower(trimTrailingWhitespace) + } + case "charset": + v = d.Charset + case "end_of_line": + v = d.EndOfLine + case "indent_style": + v = d.IndentStyle + case "tab_width": + tabWidth, ok := d.Raw["tab_width"] + if ok && tabWidth == UnsetValue { + v = tabWidth + } else { + v = strconv.Itoa(d.TabWidth) + } + case "indent_size": + v = d.IndentSize + } + + iniSec.NewKey(k, v) // nolint: errcheck + } + + if _, ok := d.Raw["indent_size"]; !ok { + tabWidth, ok := d.Raw["tab_width"] + + switch { + case ok && tabWidth == UnsetValue: + // do nothing + case d.TabWidth > 0: + iniSec.NewKey("indent_size", strconv.Itoa(d.TabWidth)) // nolint: errcheck + case d.IndentStyle == IndentStyleTab && (d.version == "" || semver.Compare(d.version, "v0.9.0") >= 0): + iniSec.NewKey("indent_size", IndentStyleTab) // nolint: errcheck + } + } + + if _, ok := d.Raw["tab_width"]; !ok { + if d.IndentSize == UnsetValue { + iniSec.NewKey("tab_width", d.IndentSize) // nolint: errcheck + } else { + _, err := strconv.Atoi(d.IndentSize) + if err == nil { + iniSec.NewKey("tab_width", d.Raw["indent_size"]) // nolint: errcheck + } + } + } +} diff --git a/vendor/github.com/editorconfig/editorconfig-core-go/v2/editorconfig.go b/vendor/github.com/editorconfig/editorconfig-core-go/v2/editorconfig.go index 1122612b49..7021c0b8c3 100644 --- a/vendor/github.com/editorconfig/editorconfig-core-go/v2/editorconfig.go +++ b/vendor/github.com/editorconfig/editorconfig-core-go/v2/editorconfig.go @@ -1,14 +1,9 @@ -// Package editorconfig can be used to parse and generate editorconfig files. -// For more information about editorconfig, see http://editorconfig.org/ package editorconfig import ( "bytes" - "io/ioutil" + "io" "os" - "path/filepath" - "regexp" - "strconv" "strings" "gopkg.in/ini.v1" @@ -17,6 +12,8 @@ import ( const ( // ConfigNameDefault represents the name of the configuration file ConfigNameDefault = ".editorconfig" + // UnsetValue is the value that unsets a preexisting variable + UnsetValue = "unset" ) // IndentStyle possible values @@ -41,172 +38,81 @@ const ( CharsetUTF8BOM = "utf-8 bom" ) -// Definition represents a definition inside the .editorconfig file. -// E.g. a section of the file. -// The definition is composed of the selector ("*", "*.go", "*.{js.css}", etc), -// plus the properties of the selected files. -type Definition struct { - Selector string `ini:"-" json:"-"` - - Charset string `ini:"charset" json:"charset,omitempty"` - IndentStyle string `ini:"indent_style" json:"indent_style,omitempty"` - IndentSize string `ini:"indent_size" json:"indent_size,omitempty"` - TabWidth int `ini:"tab_width" json:"tab_width,omitempty"` - EndOfLine string `ini:"end_of_line" json:"end_of_line,omitempty"` - TrimTrailingWhitespace bool `ini:"trim_trailing_whitespace" json:"trim_trailing_whitespace,omitempty"` - InsertFinalNewline bool `ini:"insert_final_newline" json:"insert_final_newline,omitempty"` - - Raw map[string]string `ini:"-" json:"-"` -} +// Limits for section name, properties, and values. +const ( + MaxPropertyLength = 50 + MaxSectionLength = 4096 + MaxValueLength = 255 +) // Editorconfig represents a .editorconfig file. +// // It is composed by a "root" property, plus the definitions defined in the // file. type Editorconfig struct { Root bool Definitions []*Definition + config *Config } -// ParseBytes parses from a slice of bytes. -func ParseBytes(data []byte) (*Editorconfig, error) { - iniFile, err := ini.Load(data) - if err != nil { - return nil, err - } - +// newEditorconfig builds the configuration from an INI file. +func newEditorconfig(iniFile *ini.File) (*Editorconfig, error) { editorConfig := &Editorconfig{} - editorConfig.Root = iniFile.Section(ini.DEFAULT_SECTION).Key("root").MustBool(false) + + // Consider mixed-case values for true and false. + rootKey := iniFile.Section(ini.DefaultSection).Key("root") + rootKey.SetValue(strings.ToLower(rootKey.Value())) + editorConfig.Root = rootKey.MustBool(false) + for _, sectionStr := range iniFile.SectionStrings() { - if sectionStr == ini.DEFAULT_SECTION { + if sectionStr == ini.DefaultSection || len(sectionStr) > MaxSectionLength { continue } - var ( - iniSection = iniFile.Section(sectionStr) - definition = &Definition{} - raw = make(map[string]string) - ) - err := iniSection.MapTo(&definition) - if err != nil { + + iniSection := iniFile.Section(sectionStr) + definition := &Definition{} + raw := make(map[string]string) + + if err := iniSection.MapTo(&definition); err != nil { return nil, err } - // Shallow copy all properties + // Shallow copy all the properties for k, v := range iniSection.KeysHash() { + if len(k) > MaxPropertyLength || len(v) > MaxValueLength { + continue + } + raw[strings.ToLower(k)] = v } - definition.Selector = sectionStr definition.Raw = raw - definition.normalize() - editorConfig.Definitions = append(editorConfig.Definitions, definition) - } - return editorConfig, nil -} - -// ParseFile parses from a file. -func ParseFile(f string) (*Editorconfig, error) { - data, err := ioutil.ReadFile(f) - if err != nil { - return nil, err - } - - return ParseBytes(data) -} - -var ( - regexpBraces = regexp.MustCompile("{.*}") -) - -// normalize fixes some values to their lowercaes value -func (d *Definition) normalize() { - d.Charset = strings.ToLower(d.Charset) - d.EndOfLine = strings.ToLower(d.EndOfLine) - d.IndentStyle = strings.ToLower(d.IndentStyle) - - // tab_width defaults to indent_size: - // https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties#tab_width - num, err := strconv.Atoi(d.IndentSize) - if err == nil && d.TabWidth <= 0 { - d.TabWidth = num - } -} - -func (d *Definition) merge(md *Definition) { - if len(d.Charset) == 0 { - d.Charset = md.Charset - } - if len(d.IndentStyle) == 0 { - d.IndentStyle = md.IndentStyle - } - if len(d.IndentSize) == 0 { - d.IndentSize = md.IndentSize - } - if d.TabWidth <= 0 { - d.TabWidth = md.TabWidth - } - if len(d.EndOfLine) == 0 { - d.EndOfLine = md.EndOfLine - } - if !d.TrimTrailingWhitespace { - d.TrimTrailingWhitespace = md.TrimTrailingWhitespace - } - if !d.InsertFinalNewline { - d.InsertFinalNewline = md.InsertFinalNewline - } + definition.Selector = sectionStr - for k, v := range md.Raw { - if _, ok := d.Raw[k]; !ok { - d.Raw[k] = v + if err := definition.normalize(); err != nil { + return nil, err } - } -} -// InsertToIniFile ... TODO -func (d *Definition) InsertToIniFile(iniFile *ini.File) { - iniSec := iniFile.Section(d.Selector) - for k, v := range d.Raw { - if k == "insert_final_newline" { - iniSec.Key(k).SetValue(strconv.FormatBool(d.InsertFinalNewline)) - } else if k == "trim_trailing_whitespace" { - iniSec.Key(k).SetValue(strconv.FormatBool(d.TrimTrailingWhitespace)) - } else if k == "charset" { - iniSec.Key(k).SetValue(d.Charset) - } else if k == "end_of_line" { - iniSec.Key(k).SetValue(d.EndOfLine) - } else if k == "indent_style" { - iniSec.Key(k).SetValue(d.IndentStyle) - } else if k == "tab_width" { - iniSec.Key(k).SetValue(strconv.Itoa(d.TabWidth)) - } else if k == "indent_size" { - iniSec.Key(k).SetValue(d.IndentSize) - } else { - iniSec.Key(k).SetValue(v) - } - } - if _, ok := d.Raw["indent_size"]; !ok { - if d.TabWidth > 0 { - iniSec.Key("indent_size").SetValue(strconv.Itoa(d.TabWidth)) - } else if d.IndentStyle == IndentStyleTab { - iniSec.Key("indent_size").SetValue(IndentStyleTab) - } + editorConfig.Definitions = append(editorConfig.Definitions, definition) } - if _, ok := d.Raw["tab_width"]; !ok && len(d.IndentSize) > 0 { - if _, err := strconv.Atoi(d.IndentSize); err == nil { - iniSec.Key("tab_width").SetValue(d.IndentSize) - } - } + return editorConfig, nil } // GetDefinitionForFilename returns a definition for the given filename. +// // The result is a merge of the selectors that matched the file. // The last section has preference over the priors. func (e *Editorconfig) GetDefinitionForFilename(name string) (*Definition, error) { - def := &Definition{} - def.Raw = make(map[string]string) + def := &Definition{ + Raw: make(map[string]string), + } + + // The last section has preference over the priors. for i := len(e.Definitions) - 1; i >= 0; i-- { actualDef := e.Definitions[i] selector := actualDef.Selector + if !strings.HasPrefix(selector, "/") { if strings.ContainsRune(selector, '/') { selector = "/" + selector @@ -214,102 +120,138 @@ func (e *Editorconfig) GetDefinitionForFilename(name string) (*Definition, error selector = "/**/" + selector } } + if !strings.HasPrefix(name, "/") { name = "/" + name } - ok, err := FnmatchCase(selector, name) + + ok, err := e.FnmatchCase(selector, name) if err != nil { return nil, err } + if ok { def.merge(actualDef) } } + return def, nil } -func boolToString(b bool) string { - if b { - return "true" +// FnmatchCase calls the matcher from the config's parser or the vanilla's. +func (e *Editorconfig) FnmatchCase(selector string, filename string) (bool, error) { + if e.config != nil && e.config.Parser != nil { + return e.config.Parser.FnmatchCase(selector, filename) } - return "false" + + return FnmatchCase(selector, filename) } // Serialize converts the Editorconfig to a slice of bytes, containing the // content of the file in the INI format. func (e *Editorconfig) Serialize() ([]byte, error) { + buffer := bytes.NewBuffer(nil) + + err := e.Write(buffer) + if err != nil { + return nil, err + } + + return buffer.Bytes(), nil +} + +// Write writes the Editorconfig to the Writer in a compatible INI file. +func (e *Editorconfig) Write(w io.Writer) error { var ( iniFile = ini.Empty() - buffer = bytes.NewBuffer(nil) ) - iniFile.Section(ini.DEFAULT_SECTION).Comment = "http://editorconfig.org" + + iniFile.Section(ini.DefaultSection).Comment = "https://editorconfig.org" + if e.Root { - iniFile.Section(ini.DEFAULT_SECTION).Key("root").SetValue(boolToString(e.Root)) + iniFile.Section(ini.DefaultSection).Key("root").SetValue(boolToString(e.Root)) } + for _, d := range e.Definitions { d.InsertToIniFile(iniFile) } - _, err := iniFile.WriteTo(buffer) - if err != nil { - return nil, err - } - return buffer.Bytes(), nil + + _, err := iniFile.WriteTo(w) + + return err } // Save saves the Editorconfig to a compatible INI file. func (e *Editorconfig) Save(filename string) error { - data, err := e.Serialize() + f, err := os.OpenFile(filename, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644) if err != nil { return err } - return ioutil.WriteFile(filename, data, 0666) + + return e.Write(f) } -// GetDefinitionForFilename given a filename, searches -// for .editorconfig files, starting from the file folder, -// walking through the previous folders, until it reaches a -// folder with `root = true`, and returns the right editorconfig -// definition for the given file. -func GetDefinitionForFilename(filename string) (*Definition, error) { - return GetDefinitionForFilenameWithConfigname(filename, ConfigNameDefault) +func boolToString(b bool) string { + if b { + return "true" + } + + return "false" } -func GetDefinitionForFilenameWithConfigname(filename string, configname string) (*Definition, error) { - abs, err := filepath.Abs(filename) +// Parse parses from a reader. +func Parse(r io.Reader) (*Editorconfig, error) { + iniFile, err := ini.Load(r) if err != nil { return nil, err } - definition := &Definition{} - definition.Raw = make(map[string]string) - - dir := abs - for dir != filepath.Dir(dir) { - dir = filepath.Dir(dir) - ecFile := filepath.Join(dir, configname) - if _, err := os.Stat(ecFile); os.IsNotExist(err) { - continue - } - ec, err := ParseFile(ecFile) - if err != nil { - return nil, err - } - relativeFilename := filename - if len(dir) < len(abs) { - relativeFilename = abs[len(dir):] - } + return newEditorconfig(iniFile) +} - def, err := ec.GetDefinitionForFilename(relativeFilename) - if err != nil { - return nil, err - } +// ParseBytes parses from a slice of bytes. +// +// Deprecated: use Parse instead. +func ParseBytes(data []byte) (*Editorconfig, error) { + iniFile, err := ini.Load(data) + if err != nil { + return nil, err + } - definition.merge(def) + return newEditorconfig(iniFile) +} - if ec.Root { - break - } +// ParseFile parses from a file. +// +// Deprecated: use Parse instead. +func ParseFile(path string) (*Editorconfig, error) { + iniFile, err := ini.Load(path) + if err != nil { + return nil, err + } + + return newEditorconfig(iniFile) +} + +// GetDefinitionForFilename given a filename, searches +// for .editorconfig files, starting from the file folder, +// walking through the previous folders, until it reaches a +// folder with `root = true`, and returns the right editorconfig +// definition for the given file. +func GetDefinitionForFilename(filename string) (*Definition, error) { + config := new(Config) + return config.Load(filename) +} + +// GetDefinitionForFilenameWithConfigname given a filename and a configname, +// searches for configname files, starting from the file folder, +// walking through the previous folders, until it reaches a +// folder with `root = true`, and returns the right editorconfig +// definition for the given file. +func GetDefinitionForFilenameWithConfigname(filename string, configname string) (*Definition, error) { + config := &Config{ + Name: configname, } - return definition, nil + return config.Load(filename) } diff --git a/vendor/github.com/editorconfig/editorconfig-core-go/v2/fnmatch.go b/vendor/github.com/editorconfig/editorconfig-core-go/v2/fnmatch.go index c33544cf78..e5eb09ef67 100644 --- a/vendor/github.com/editorconfig/editorconfig-core-go/v2/fnmatch.go +++ b/vendor/github.com/editorconfig/editorconfig-core-go/v2/fnmatch.go @@ -18,10 +18,7 @@ var ( // 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 - } + p := translate(pattern) r, err := regexp.Compile(fmt.Sprintf("^%s$", p)) if err != nil { @@ -31,7 +28,7 @@ func FnmatchCase(pattern, name string) (bool, error) { return r.MatchString(name), nil } -func translate(pattern string) (string, error) { +func translate(pattern string) string { // nolint: gocyclo index := 0 pat := []rune(pattern) length := len(pat) @@ -48,7 +45,8 @@ func translate(pattern string) (string, error) { r := pat[index] index++ - if r == '*' { + switch r { + case '*': p := index if p < length && pat[p] == '*' { result.WriteString(".*") @@ -56,17 +54,18 @@ func translate(pattern string) (string, error) { } else { result.WriteString("[^/]*") } - } else if r == '/' { + case '/': 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 == '?' { + case '?': result.WriteString("[^/]") - } else if r == '[' { + case '[': if inBrackets { result.WriteString("\\[") } else { @@ -98,14 +97,14 @@ func translate(pattern string) (string, error) { } } } - } else if r == ']' { + case ']': if inBrackets && pat[index-2] == '\\' { result.WriteString("\\]") } else { result.WriteRune(r) inBrackets = false } - } else if r == '{' { + case '{': hasComma := false p := index res := strings.Builder{} @@ -114,7 +113,9 @@ func translate(pattern string) (string, error) { if pat[p] == '}' && pat[p-1] != '\\' { break } + res.WriteRune(pat[p]) + if pat[p] == ',' && pat[p-1] != '\\' { hasComma = true break @@ -122,56 +123,68 @@ func translate(pattern string) (string, error) { p++ } - if !hasComma && p < length { + switch { + case !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) + r := translate(inner) + result.WriteString(fmt.Sprintf("\\{%s\\}", r)) } + index = p + 1 - } else if matchesBraces { + case matchesBraces: result.WriteString("(?:") braceLevel++ - } else { + default: result.WriteString("\\{") } - } else if r == '}' { + case '}': if braceLevel > 0 { if isEscaped { result.WriteRune('}') + isEscaped = false } else { result.WriteRune(')') + braceLevel-- } } else { result.WriteString("\\}") } - } else if r == ',' { + case ',': 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 + default: + if r != '\\' || isEscaped { + result.WriteString(regexp.QuoteMeta(string(r))) + + isEscaped = false + } else { + isEscaped = true + } } } - return result.String(), nil + return result.String() } diff --git a/vendor/github.com/editorconfig/editorconfig-core-go/v2/go.doc b/vendor/github.com/editorconfig/editorconfig-core-go/v2/go.doc new file mode 100644 index 0000000000..7c62ef2052 --- /dev/null +++ b/vendor/github.com/editorconfig/editorconfig-core-go/v2/go.doc @@ -0,0 +1,2 @@ +// Package editorconfig can be used to parse and generate editorconfig files. +// For more information about editorconfig, see https://editorconfig.org/ diff --git a/vendor/github.com/editorconfig/editorconfig-core-go/v2/go.mod b/vendor/github.com/editorconfig/editorconfig-core-go/v2/go.mod index e4364b8b45..66155fa6a0 100644 --- a/vendor/github.com/editorconfig/editorconfig-core-go/v2/go.mod +++ b/vendor/github.com/editorconfig/editorconfig-core-go/v2/go.mod @@ -1,9 +1,10 @@ module github.com/editorconfig/editorconfig-core-go/v2 -go 1.12 +go 1.13 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 + github.com/google/go-cmp v0.5.2 + github.com/smartystreets/goconvey v1.6.4 // indirect + golang.org/x/mod v0.3.0 + gopkg.in/ini.v1 v1.60.2 ) diff --git a/vendor/github.com/editorconfig/editorconfig-core-go/v2/go.sum b/vendor/github.com/editorconfig/editorconfig-core-go/v2/go.sum index 061cdf586b..5c5090689c 100644 --- a/vendor/github.com/editorconfig/editorconfig-core-go/v2/go.sum +++ b/vendor/github.com/editorconfig/editorconfig-core-go/v2/go.sum @@ -1,22 +1,31 @@ -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/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= +github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 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= +github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= +github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= 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= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e h1:aZzprAO9/8oim3qStq3wc1Xuxx4QmAGriC4VU4ojemQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/ini.v1 v1.60.2 h1:7i8mqModL63zqi8nQn8Q3+0zvSCZy1AxhBgthKfi4WU= +gopkg.in/ini.v1 v1.60.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= diff --git a/vendor/github.com/editorconfig/editorconfig-core-go/v2/parser.go b/vendor/github.com/editorconfig/editorconfig-core-go/v2/parser.go new file mode 100644 index 0000000000..33c07a0356 --- /dev/null +++ b/vendor/github.com/editorconfig/editorconfig-core-go/v2/parser.go @@ -0,0 +1,13 @@ +package editorconfig + +// Parser interface is responsible for the parsing of the ini file and the +// globbing patterns. +type Parser interface { + // ParseIni takes one .editorconfig (ini format) filename and returns its + // Editorconfig definition. + ParseIni(filename string) (*Editorconfig, error) + + // FnmatchCase takes a pattern, a filename, and tells wether the given filename + // matches the globbing pattern. + FnmatchCase(pattern string, filename string) (bool, error) +} diff --git a/vendor/github.com/editorconfig/editorconfig-core-go/v2/simple_parser.go b/vendor/github.com/editorconfig/editorconfig-core-go/v2/simple_parser.go new file mode 100644 index 0000000000..af6b097654 --- /dev/null +++ b/vendor/github.com/editorconfig/editorconfig-core-go/v2/simple_parser.go @@ -0,0 +1,32 @@ +package editorconfig + +import ( + "os" + + "gopkg.in/ini.v1" +) + +// SimpleParser implements the Parser interface but without doing any caching. +type SimpleParser struct{} + +// ParseIni calls go-ini's Load on the file. +func (parser *SimpleParser) ParseIni(filename string) (*Editorconfig, error) { + fp, err := os.Open(filename) + if err != nil { + return nil, err + } + + defer fp.Close() + + iniFile, err := ini.Load(fp) + if err != nil { + return nil, err + } + + return newEditorconfig(iniFile) +} + +// FnmatchCase calls the module's FnmatchCase. +func (parser *SimpleParser) FnmatchCase(selector string, filename string) (bool, error) { + return FnmatchCase(selector, filename) +} |