deps: Upgrade gopkg.in/editorconfig/editorconfig-core-go.v1 (#7749)

* deps: Upgrade gopkg.in/editorconfig/editorconfig-core-go.v1 from 1.2.0 to 1.3.0

* deps: vendor updates
This commit is contained in:
Antoine GIRARD 2019-08-05 09:52:41 +02:00 committed by Lunny Xiao
parent cd238bc415
commit 52feff5a5c
10 changed files with 86 additions and 29 deletions

2
go.mod
View file

@ -115,7 +115,7 @@ require (
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
gopkg.in/asn1-ber.v1 v1.0.0-20150924051756-4e86f4367175 // indirect gopkg.in/asn1-ber.v1 v1.0.0-20150924051756-4e86f4367175 // indirect
gopkg.in/bufio.v1 v1.0.0-20140618132640-567b2bfa514e // indirect gopkg.in/bufio.v1 v1.0.0-20140618132640-567b2bfa514e // indirect
gopkg.in/editorconfig/editorconfig-core-go.v1 v1.2.0 gopkg.in/editorconfig/editorconfig-core-go.v1 v1.3.0
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
gopkg.in/ini.v1 v1.42.0 gopkg.in/ini.v1 v1.42.0
gopkg.in/ldap.v3 v3.0.2 gopkg.in/ldap.v3 v3.0.2

4
go.sum
View file

@ -451,8 +451,8 @@ gopkg.in/bufio.v1 v1.0.0-20140618132640-567b2bfa514e/go.mod h1:xsQCaysVCudhrYTfz
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/editorconfig/editorconfig-core-go.v1 v1.2.0 h1:CO465/foR4+bY1xNYjZEl6l8By1g/iMsImoruxfEt84= gopkg.in/editorconfig/editorconfig-core-go.v1 v1.3.0 h1:oxOEwvhxLMpWpN+0pb2r9TWrM0DCFBHxbuIlS27tmFg=
gopkg.in/editorconfig/editorconfig-core-go.v1 v1.2.0/go.mod h1:s2mQFI9McjArkyCwyEwU//+luQENTnD/Lfb/7Sj3/kQ= gopkg.in/editorconfig/editorconfig-core-go.v1 v1.3.0/go.mod h1:s2mQFI9McjArkyCwyEwU//+luQENTnD/Lfb/7Sj3/kQ=
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df h1:n7WqCuqOuCbNr617RXOY0AWRXxgwEyPp2z+p0+hgMuE= gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df h1:n7WqCuqOuCbNr617RXOY0AWRXxgwEyPp2z+p0+hgMuE=

View file

@ -10,4 +10,4 @@ trim_trailing_whitespace = true
[*.go] [*.go]
indent_style = tab indent_style = tab
indent_size = 4 indent_size = 8

View file

@ -24,3 +24,6 @@ _testmain.go
*.test *.test
*.prof *.prof
# EditorConfig
/editorconfig

View file

@ -0,0 +1,3 @@
[submodule "core-test"]
path = core-test
url = https://github.com/editorconfig/editorconfig-core-test.git

View file

@ -0,0 +1,14 @@
---
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

View file

@ -0,0 +1,25 @@
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 .

View file

@ -1,3 +1,4 @@
[![Build Status](https://travis-ci.org/editorconfig/editorconfig-core-go.svg?branch=master)](https://travis-ci.org/editorconfig/editorconfig-core-go)
[![GoDoc](https://godoc.org/gopkg.in/editorconfig/editorconfig-core-go.v1?status.svg)](https://godoc.org/gopkg.in/editorconfig/editorconfig-core-go.v1) [![GoDoc](https://godoc.org/gopkg.in/editorconfig/editorconfig-core-go.v1?status.svg)](https://godoc.org/gopkg.in/editorconfig/editorconfig-core-go.v1)
[![Go Report Card](https://goreportcard.com/badge/gopkg.in/editorconfig/editorconfig-core-go.v1)](https://goreportcard.com/report/gopkg.in/editorconfig/editorconfig-core-go.v1) [![Go Report Card](https://goreportcard.com/badge/gopkg.in/editorconfig/editorconfig-core-go.v1)](https://goreportcard.com/report/gopkg.in/editorconfig/editorconfig-core-go.v1)
@ -15,7 +16,7 @@ We recommend the use of [gopkg.in][gopkg] for this package:
go get -u gopkg.in/editorconfig/editorconfig-core-go.v1 go get -u gopkg.in/editorconfig/editorconfig-core-go.v1
``` ```
Import by the same path. Tha package name you will use to access it is Import by the same path. The package name you will use to access it is
`editorconfig`. `editorconfig`.
```go ```go

View file

@ -14,6 +14,10 @@ import (
"gopkg.in/ini.v1" "gopkg.in/ini.v1"
) )
const (
ConfigNameDefault = ".editorconfig"
)
// IndentStyle possible values // IndentStyle possible values
const ( const (
IndentStyleTab = "tab" IndentStyleTab = "tab"
@ -49,6 +53,8 @@ type Definition struct {
EndOfLine string `ini:"end_of_line" json:"end_of_line,omitempty"` EndOfLine string `ini:"end_of_line" json:"end_of_line,omitempty"`
TrimTrailingWhitespace bool `ini:"trim_trailing_whitespace" json:"trim_trailing_whitespace,omitempty"` TrimTrailingWhitespace bool `ini:"trim_trailing_whitespace" json:"trim_trailing_whitespace,omitempty"`
InsertFinalNewline bool `ini:"insert_final_newline" json:"insert_final_newline,omitempty"` InsertFinalNewline bool `ini:"insert_final_newline" json:"insert_final_newline,omitempty"`
Raw map[string]string `ini:"-" json:"-"`
} }
// Editorconfig represents a .editorconfig file. // Editorconfig represents a .editorconfig file.
@ -75,6 +81,7 @@ func ParseBytes(data []byte) (*Editorconfig, error) {
var ( var (
iniSection = iniFile.Section(sectionStr) iniSection = iniFile.Section(sectionStr)
definition = &Definition{} definition = &Definition{}
raw = make(map[string]string)
) )
err := iniSection.MapTo(&definition) err := iniSection.MapTo(&definition)
if err != nil { if err != nil {
@ -89,7 +96,13 @@ func ParseBytes(data []byte) (*Editorconfig, error) {
} }
} }
// Shallow copy all properties
for k, v := range iniSection.KeysHash() {
raw[k] = v
}
definition.Selector = sectionStr definition.Selector = sectionStr
definition.Raw = raw
editorConfig.Definitions = append(editorConfig.Definitions, definition) editorConfig.Definitions = append(editorConfig.Definitions, definition)
} }
return editorConfig, nil return editorConfig, nil
@ -171,6 +184,19 @@ func (d *Definition) merge(md *Definition) {
if !d.InsertFinalNewline { if !d.InsertFinalNewline {
d.InsertFinalNewline = md.InsertFinalNewline d.InsertFinalNewline = md.InsertFinalNewline
} }
for k, v := range md.Raw {
if _, ok := d.Raw[k]; !ok {
d.Raw[k] = v
}
}
}
func (d *Definition) InsertToIniFile(iniFile *ini.File) {
iniSec := iniFile.Section(d.Selector)
for k, v := range d.Raw {
iniSec.Key(k).SetValue(v)
}
} }
// GetDefinitionForFilename returns a definition for the given filename. // GetDefinitionForFilename returns a definition for the given filename.
@ -178,6 +204,7 @@ func (d *Definition) merge(md *Definition) {
// The last section has preference over the priors. // The last section has preference over the priors.
func (e *Editorconfig) GetDefinitionForFilename(name string) *Definition { func (e *Editorconfig) GetDefinitionForFilename(name string) *Definition {
def := &Definition{} def := &Definition{}
def.Raw = make(map[string]string)
for i := len(e.Definitions) - 1; i >= 0; i-- { for i := len(e.Definitions) - 1; i >= 0; i-- {
actualDef := e.Definitions[i] actualDef := e.Definitions[i]
if filenameMatches(actualDef.Selector, name) { if filenameMatches(actualDef.Selector, name) {
@ -206,28 +233,7 @@ func (e *Editorconfig) Serialize() ([]byte, error) {
iniFile.Section(ini.DEFAULT_SECTION).Key("root").SetValue(boolToString(e.Root)) iniFile.Section(ini.DEFAULT_SECTION).Key("root").SetValue(boolToString(e.Root))
} }
for _, d := range e.Definitions { for _, d := range e.Definitions {
iniSec := iniFile.Section(d.Selector) d.InsertToIniFile(iniFile)
if len(d.Charset) > 0 {
iniSec.Key("charset").SetValue(d.Charset)
}
if len(d.IndentStyle) > 0 {
iniSec.Key("indent_style").SetValue(d.IndentStyle)
}
if len(d.IndentSize) > 0 {
iniSec.Key("indent_size").SetValue(d.IndentSize)
}
if d.TabWidth > 0 && strconv.Itoa(d.TabWidth) != d.IndentSize {
iniSec.Key("tab_width").SetValue(strconv.Itoa(d.TabWidth))
}
if len(d.EndOfLine) > 0 {
iniSec.Key("end_of_line").SetValue(d.EndOfLine)
}
if d.TrimTrailingWhitespace {
iniSec.Key("trim_trailing_whitespace").SetValue(boolToString(d.TrimTrailingWhitespace))
}
if d.InsertFinalNewline {
iniSec.Key("insert_final_newline").SetValue(boolToString(d.InsertFinalNewline))
}
} }
_, err := iniFile.WriteTo(buffer) _, err := iniFile.WriteTo(buffer)
if err != nil { if err != nil {
@ -251,16 +257,21 @@ func (e *Editorconfig) Save(filename string) error {
// folder with `root = true`, and returns the right editorconfig // folder with `root = true`, and returns the right editorconfig
// definition for the given file. // definition for the given file.
func GetDefinitionForFilename(filename string) (*Definition, error) { func GetDefinitionForFilename(filename string) (*Definition, error) {
return GetDefinitionForFilenameWithConfigname(filename, ConfigNameDefault)
}
func GetDefinitionForFilenameWithConfigname(filename string, configname string) (*Definition, error) {
abs, err := filepath.Abs(filename) abs, err := filepath.Abs(filename)
if err != nil { if err != nil {
return nil, err return nil, err
} }
definition := &Definition{} definition := &Definition{}
definition.Raw = make(map[string]string)
dir := abs dir := abs
for dir != filepath.Dir(dir) { for dir != filepath.Dir(dir) {
dir = filepath.Dir(dir) dir = filepath.Dir(dir)
ecFile := filepath.Join(dir, ".editorconfig") ecFile := filepath.Join(dir, configname)
if _, err := os.Stat(ecFile); os.IsNotExist(err) { if _, err := os.Stat(ecFile); os.IsNotExist(err) {
continue continue
} }

2
vendor/modules.txt vendored
View file

@ -414,7 +414,7 @@ gopkg.in/alexcesaro/quotedprintable.v3
gopkg.in/asn1-ber.v1 gopkg.in/asn1-ber.v1
# gopkg.in/bufio.v1 v1.0.0-20140618132640-567b2bfa514e # gopkg.in/bufio.v1 v1.0.0-20140618132640-567b2bfa514e
gopkg.in/bufio.v1 gopkg.in/bufio.v1
# gopkg.in/editorconfig/editorconfig-core-go.v1 v1.2.0 # gopkg.in/editorconfig/editorconfig-core-go.v1 v1.3.0
gopkg.in/editorconfig/editorconfig-core-go.v1 gopkg.in/editorconfig/editorconfig-core-go.v1
# gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df # gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
gopkg.in/gomail.v2 gopkg.in/gomail.v2