]> git.lizzy.rs Git - micro.git/commitdiff
Fix tooling dependencies
authorZachary Yedidia <zyedidia@gmail.com>
Mon, 4 Feb 2019 04:41:39 +0000 (23:41 -0500)
committerZachary Yedidia <zyedidia@gmail.com>
Wed, 25 Dec 2019 22:05:10 +0000 (17:05 -0500)
.gitignore
.gitmodules [new file with mode: 0644]
Makefile
go.mod
go.sum
tools/build-version.go
tools/go-bindata [new submodule]
tools/semver/json.go [deleted file]
tools/semver/semver.go [deleted file]
tools/semver/sort.go [deleted file]
tools/semver/sql.go [deleted file]

index 910f4c58b9762214423b7d92e4152786840a7bec..ded313bd7f96a7c88165f74a6e9ef6c59c15e5b2 100644 (file)
@@ -11,3 +11,6 @@ todo.txt
 test.txt
 log.txt
 *.old
+tools/build-version
+tools/build-date
+tools/info-plist
diff --git a/.gitmodules b/.gitmodules
new file mode 100644 (file)
index 0000000..dbbdf7b
--- /dev/null
@@ -0,0 +1,3 @@
+[submodule "tools/go-bindata"]
+       path = tools/go-bindata
+       url = https://github.com/zyedidia/go-bindata
index e4f274e431bc5c320cee0af429a2a04bb804ae3e..4135756f469ff0d28e632d9eba7e96e9bd7e9ae6 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -12,7 +12,7 @@ GOBIN ?= $(shell go env GOPATH)/bin
 GOVARS := -X main.Version=$(VERSION) -X main.CommitHash=$(HASH) -X 'main.CompileDate=$(DATE)' -X main.Debug=OFF
 
 # Builds micro after checking dependencies but without updating the runtime
-build: update
+build:
        go build -ldflags "-s -w $(GOVARS) $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro
 
 # Builds micro after building the runtime and checking dependencies
@@ -23,7 +23,7 @@ build-quick:
        go build -ldflags "-s -w $(GOVARS) $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro
 
 # Same as 'build' but installs to $GOBIN afterward
-install: update
+install:
        go install -ldflags "-s -w $(GOVARS) $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro
 
 # Same as 'build-all' but installs to $GOBIN afterward
@@ -33,13 +33,11 @@ install-all: runtime install
 install-quick:
        go install -ldflags "-s -w $(GOVARS) $(ADDITIONAL_GO_LINKER_FLAGS)"  ./cmd/micro
 
-update:
-       git pull
-
 # Builds the runtime
 runtime:
-       go get -u github.com/jteeuwen/go-bindata/...
-       $(GOBIN)/go-bindata -pkg config -nomemcopy -nometadata -o runtime.go runtime/...
+       git submodule update --init
+       go build -o tools/ ./tools/go-bindata
+       tools/go-bindata -pkg config -nomemcopy -nometadata -o runtime.go runtime/...
        mv runtime.go internal/config
        gofmt -w internal/config/runtime.go
 
diff --git a/go.mod b/go.mod
index 2ce1f48f40edd852288c0125f693650daa136a45..4749634a949b6b6fde99779284808483b2892795 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -1,10 +1,12 @@
 module github.com/zyedidia/micro
 
 require (
+       github.com/blang/semver v3.5.1+incompatible // indirect
        github.com/dustin/go-humanize v1.0.0
        github.com/flynn/json5 v0.0.0-20160717195620-7620272ed633
        github.com/gdamore/encoding v1.0.0 // indirect
        github.com/go-errors/errors v1.0.1
+       github.com/jteeuwen/go-bindata v3.0.7+incompatible
        github.com/lucasb-eyer/go-colorful v0.0.0-20181028223441-12d3b2882a08 // indirect
        github.com/mattn/go-isatty v0.0.4
        github.com/mattn/go-runewidth v0.0.4
diff --git a/go.sum b/go.sum
index 894c39cf6d25df4db3e9871e6b8a012472b03b7b..7714e214d2dacbbf8737e15ac07ba3539d7f82c6 100644 (file)
--- a/go.sum
+++ b/go.sum
@@ -1,3 +1,5 @@
+github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ=
+github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
 github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
 github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
 github.com/flynn/json5 v0.0.0-20160717195620-7620272ed633 h1:xJMmr4GMYIbALX5edyoDIOQpc2bOQTeJiWMeCl9lX/8=
@@ -6,6 +8,8 @@ github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdk
 github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
 github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w=
 github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
+github.com/jteeuwen/go-bindata v3.0.7+incompatible h1:91Uy4d9SYVr1kyTJ15wJsog+esAZZl7JmEfTkwmhJts=
+github.com/jteeuwen/go-bindata v3.0.7+incompatible/go.mod h1:JVvhzYOiGBnFSYRyV00iY8q7/0PThjIYav1p9h5dmKs=
 github.com/lucasb-eyer/go-colorful v0.0.0-20181028223441-12d3b2882a08 h1:5MnxBC15uMxFv5FY/J/8vzyaBiArCOkMdFT9Jsw78iY=
 github.com/lucasb-eyer/go-colorful v0.0.0-20181028223441-12d3b2882a08/go.mod h1:NXg0ArsFk0Y01623LgUqoqcouGDB+PwCCQlrwrG6xJ4=
 github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs=
index 7a60307c56e3aceb1680449c52d6c28e7a4c5ee4..8e7e9b86879fe8a401d97993ebf26d3aad76d6a0 100644 (file)
@@ -5,7 +5,7 @@ import (
        "os/exec"
        "strings"
 
-       "github.com/zyedidia/micro/tools/semver"
+       "github.com/blang/semver"
 )
 
 func getTag(match ...string) (string, *semver.PRVersion) {
diff --git a/tools/go-bindata b/tools/go-bindata
new file mode 160000 (submodule)
index 0000000..9453701
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit 9453701aa0dbd20f88145dbd77c6f50937f17a19
diff --git a/tools/semver/json.go b/tools/semver/json.go
deleted file mode 100644 (file)
index a74bf7c..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-package semver
-
-import (
-       "encoding/json"
-)
-
-// MarshalJSON implements the encoding/json.Marshaler interface.
-func (v Version) MarshalJSON() ([]byte, error) {
-       return json.Marshal(v.String())
-}
-
-// UnmarshalJSON implements the encoding/json.Unmarshaler interface.
-func (v *Version) UnmarshalJSON(data []byte) (err error) {
-       var versionString string
-
-       if err = json.Unmarshal(data, &versionString); err != nil {
-               return
-       }
-
-       *v, err = Parse(versionString)
-
-       return
-}
diff --git a/tools/semver/semver.go b/tools/semver/semver.go
deleted file mode 100644 (file)
index ec26aa0..0000000
+++ /dev/null
@@ -1,418 +0,0 @@
-package semver
-
-import (
-       "errors"
-       "fmt"
-       "strconv"
-       "strings"
-)
-
-const (
-       numbers  string = "0123456789"
-       alphas          = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-"
-       alphanum        = alphas + numbers
-)
-
-// SpecVersion is the latest fully supported spec version of semver
-var SpecVersion = Version{
-       Major: 2,
-       Minor: 0,
-       Patch: 0,
-}
-
-// Version represents a semver compatible version
-type Version struct {
-       Major uint64
-       Minor uint64
-       Patch uint64
-       Pre   []PRVersion
-       Build []string //No Precedence
-}
-
-// Version to string
-func (v Version) String() string {
-       b := make([]byte, 0, 5)
-       b = strconv.AppendUint(b, v.Major, 10)
-       b = append(b, '.')
-       b = strconv.AppendUint(b, v.Minor, 10)
-       b = append(b, '.')
-       b = strconv.AppendUint(b, v.Patch, 10)
-
-       if len(v.Pre) > 0 {
-               b = append(b, '-')
-               b = append(b, v.Pre[0].String()...)
-
-               for _, pre := range v.Pre[1:] {
-                       b = append(b, '.')
-                       b = append(b, pre.String()...)
-               }
-       }
-
-       if len(v.Build) > 0 {
-               b = append(b, '+')
-               b = append(b, v.Build[0]...)
-
-               for _, build := range v.Build[1:] {
-                       b = append(b, '.')
-                       b = append(b, build...)
-               }
-       }
-
-       return string(b)
-}
-
-// Equals checks if v is equal to o.
-func (v Version) Equals(o Version) bool {
-       return (v.Compare(o) == 0)
-}
-
-// EQ checks if v is equal to o.
-func (v Version) EQ(o Version) bool {
-       return (v.Compare(o) == 0)
-}
-
-// NE checks if v is not equal to o.
-func (v Version) NE(o Version) bool {
-       return (v.Compare(o) != 0)
-}
-
-// GT checks if v is greater than o.
-func (v Version) GT(o Version) bool {
-       return (v.Compare(o) == 1)
-}
-
-// GTE checks if v is greater than or equal to o.
-func (v Version) GTE(o Version) bool {
-       return (v.Compare(o) >= 0)
-}
-
-// GE checks if v is greater than or equal to o.
-func (v Version) GE(o Version) bool {
-       return (v.Compare(o) >= 0)
-}
-
-// LT checks if v is less than o.
-func (v Version) LT(o Version) bool {
-       return (v.Compare(o) == -1)
-}
-
-// LTE checks if v is less than or equal to o.
-func (v Version) LTE(o Version) bool {
-       return (v.Compare(o) <= 0)
-}
-
-// LE checks if v is less than or equal to o.
-func (v Version) LE(o Version) bool {
-       return (v.Compare(o) <= 0)
-}
-
-// Compare compares Versions v to o:
-// -1 == v is less than o
-// 0 == v is equal to o
-// 1 == v is greater than o
-func (v Version) Compare(o Version) int {
-       if v.Major != o.Major {
-               if v.Major > o.Major {
-                       return 1
-               }
-               return -1
-       }
-       if v.Minor != o.Minor {
-               if v.Minor > o.Minor {
-                       return 1
-               }
-               return -1
-       }
-       if v.Patch != o.Patch {
-               if v.Patch > o.Patch {
-                       return 1
-               }
-               return -1
-       }
-
-       // Quick comparison if a version has no prerelease versions
-       if len(v.Pre) == 0 && len(o.Pre) == 0 {
-               return 0
-       } else if len(v.Pre) == 0 && len(o.Pre) > 0 {
-               return 1
-       } else if len(v.Pre) > 0 && len(o.Pre) == 0 {
-               return -1
-       }
-
-       i := 0
-       for ; i < len(v.Pre) && i < len(o.Pre); i++ {
-               if comp := v.Pre[i].Compare(o.Pre[i]); comp == 0 {
-                       continue
-               } else if comp == 1 {
-                       return 1
-               } else {
-                       return -1
-               }
-       }
-
-       // If all pr versions are the equal but one has further prversion, this one greater
-       if i == len(v.Pre) && i == len(o.Pre) {
-               return 0
-       } else if i == len(v.Pre) && i < len(o.Pre) {
-               return -1
-       } else {
-               return 1
-       }
-
-}
-
-// Validate validates v and returns error in case
-func (v Version) Validate() error {
-       // Major, Minor, Patch already validated using uint64
-
-       for _, pre := range v.Pre {
-               if !pre.IsNum { //Numeric prerelease versions already uint64
-                       if len(pre.VersionStr) == 0 {
-                               return fmt.Errorf("Prerelease can not be empty %q", pre.VersionStr)
-                       }
-                       if !containsOnly(pre.VersionStr, alphanum) {
-                               return fmt.Errorf("Invalid character(s) found in prerelease %q", pre.VersionStr)
-                       }
-               }
-       }
-
-       for _, build := range v.Build {
-               if len(build) == 0 {
-                       return fmt.Errorf("Build meta data can not be empty %q", build)
-               }
-               if !containsOnly(build, alphanum) {
-                       return fmt.Errorf("Invalid character(s) found in build meta data %q", build)
-               }
-       }
-
-       return nil
-}
-
-// New is an alias for Parse and returns a pointer, parses version string and returns a validated Version or error
-func New(s string) (vp *Version, err error) {
-       v, err := Parse(s)
-       vp = &v
-       return
-}
-
-// Make is an alias for Parse, parses version string and returns a validated Version or error
-func Make(s string) (Version, error) {
-       return Parse(s)
-}
-
-// ParseTolerant allows for certain version specifications that do not strictly adhere to semver
-// specs to be parsed by this library. It does so by normalizing versions before passing them to
-// Parse(). It currently trims spaces, removes a "v" prefix, and adds a 0 patch number to versions
-// with only major and minor components specified
-func ParseTolerant(s string) (Version, error) {
-       s = strings.TrimSpace(s)
-       s = strings.TrimPrefix(s, "v")
-
-       // Split into major.minor.(patch+pr+meta)
-       parts := strings.SplitN(s, ".", 3)
-       if len(parts) < 3 {
-               if strings.ContainsAny(parts[len(parts)-1], "+-") {
-                       return Version{}, errors.New("Short version cannot contain PreRelease/Build meta data")
-               }
-               for len(parts) < 3 {
-                       parts = append(parts, "0")
-               }
-               s = strings.Join(parts, ".")
-       }
-
-       return Parse(s)
-}
-
-// Parse parses version string and returns a validated Version or error
-func Parse(s string) (Version, error) {
-       if len(s) == 0 {
-               return Version{}, errors.New("Version string empty")
-       }
-
-       // Split into major.minor.(patch+pr+meta)
-       parts := strings.SplitN(s, ".", 3)
-       if len(parts) != 3 {
-               return Version{}, errors.New("No Major.Minor.Patch elements found")
-       }
-
-       // Major
-       if !containsOnly(parts[0], numbers) {
-               return Version{}, fmt.Errorf("Invalid character(s) found in major number %q", parts[0])
-       }
-       if hasLeadingZeroes(parts[0]) {
-               return Version{}, fmt.Errorf("Major number must not contain leading zeroes %q", parts[0])
-       }
-       major, err := strconv.ParseUint(parts[0], 10, 64)
-       if err != nil {
-               return Version{}, err
-       }
-
-       // Minor
-       if !containsOnly(parts[1], numbers) {
-               return Version{}, fmt.Errorf("Invalid character(s) found in minor number %q", parts[1])
-       }
-       if hasLeadingZeroes(parts[1]) {
-               return Version{}, fmt.Errorf("Minor number must not contain leading zeroes %q", parts[1])
-       }
-       minor, err := strconv.ParseUint(parts[1], 10, 64)
-       if err != nil {
-               return Version{}, err
-       }
-
-       v := Version{}
-       v.Major = major
-       v.Minor = minor
-
-       var build, prerelease []string
-       patchStr := parts[2]
-
-       if buildIndex := strings.IndexRune(patchStr, '+'); buildIndex != -1 {
-               build = strings.Split(patchStr[buildIndex+1:], ".")
-               patchStr = patchStr[:buildIndex]
-       }
-
-       if preIndex := strings.IndexRune(patchStr, '-'); preIndex != -1 {
-               prerelease = strings.Split(patchStr[preIndex+1:], ".")
-               patchStr = patchStr[:preIndex]
-       }
-
-       if !containsOnly(patchStr, numbers) {
-               return Version{}, fmt.Errorf("Invalid character(s) found in patch number %q", patchStr)
-       }
-       if hasLeadingZeroes(patchStr) {
-               return Version{}, fmt.Errorf("Patch number must not contain leading zeroes %q", patchStr)
-       }
-       patch, err := strconv.ParseUint(patchStr, 10, 64)
-       if err != nil {
-               return Version{}, err
-       }
-
-       v.Patch = patch
-
-       // Prerelease
-       for _, prstr := range prerelease {
-               parsedPR, err := NewPRVersion(prstr)
-               if err != nil {
-                       return Version{}, err
-               }
-               v.Pre = append(v.Pre, parsedPR)
-       }
-
-       // Build meta data
-       for _, str := range build {
-               if len(str) == 0 {
-                       return Version{}, errors.New("Build meta data is empty")
-               }
-               if !containsOnly(str, alphanum) {
-                       return Version{}, fmt.Errorf("Invalid character(s) found in build meta data %q", str)
-               }
-               v.Build = append(v.Build, str)
-       }
-
-       return v, nil
-}
-
-// MustParse is like Parse but panics if the version cannot be parsed.
-func MustParse(s string) Version {
-       v, err := Parse(s)
-       if err != nil {
-               panic(`semver: Parse(` + s + `): ` + err.Error())
-       }
-       return v
-}
-
-// PRVersion represents a PreRelease Version
-type PRVersion struct {
-       VersionStr string
-       VersionNum uint64
-       IsNum      bool
-}
-
-// NewPRVersion creates a new valid prerelease version
-func NewPRVersion(s string) (PRVersion, error) {
-       if len(s) == 0 {
-               return PRVersion{}, errors.New("Prerelease is empty")
-       }
-       v := PRVersion{}
-       if containsOnly(s, numbers) {
-               if hasLeadingZeroes(s) {
-                       return PRVersion{}, fmt.Errorf("Numeric PreRelease version must not contain leading zeroes %q", s)
-               }
-               num, err := strconv.ParseUint(s, 10, 64)
-
-               // Might never be hit, but just in case
-               if err != nil {
-                       return PRVersion{}, err
-               }
-               v.VersionNum = num
-               v.IsNum = true
-       } else if containsOnly(s, alphanum) {
-               v.VersionStr = s
-               v.IsNum = false
-       } else {
-               return PRVersion{}, fmt.Errorf("Invalid character(s) found in prerelease %q", s)
-       }
-       return v, nil
-}
-
-// IsNumeric checks if prerelease-version is numeric
-func (v PRVersion) IsNumeric() bool {
-       return v.IsNum
-}
-
-// Compare compares two PreRelease Versions v and o:
-// -1 == v is less than o
-// 0 == v is equal to o
-// 1 == v is greater than o
-func (v PRVersion) Compare(o PRVersion) int {
-       if v.IsNum && !o.IsNum {
-               return -1
-       } else if !v.IsNum && o.IsNum {
-               return 1
-       } else if v.IsNum && o.IsNum {
-               if v.VersionNum == o.VersionNum {
-                       return 0
-               } else if v.VersionNum > o.VersionNum {
-                       return 1
-               } else {
-                       return -1
-               }
-       } else { // both are Alphas
-               if v.VersionStr == o.VersionStr {
-                       return 0
-               } else if v.VersionStr > o.VersionStr {
-                       return 1
-               } else {
-                       return -1
-               }
-       }
-}
-
-// PreRelease version to string
-func (v PRVersion) String() string {
-       if v.IsNum {
-               return strconv.FormatUint(v.VersionNum, 10)
-       }
-       return v.VersionStr
-}
-
-func containsOnly(s string, set string) bool {
-       return strings.IndexFunc(s, func(r rune) bool {
-               return !strings.ContainsRune(set, r)
-       }) == -1
-}
-
-func hasLeadingZeroes(s string) bool {
-       return len(s) > 1 && s[0] == '0'
-}
-
-// NewBuildVersion creates a new valid build version
-func NewBuildVersion(s string) (string, error) {
-       if len(s) == 0 {
-               return "", errors.New("Buildversion is empty")
-       }
-       if !containsOnly(s, alphanum) {
-               return "", fmt.Errorf("Invalid character(s) found in build meta data %q", s)
-       }
-       return s, nil
-}
diff --git a/tools/semver/sort.go b/tools/semver/sort.go
deleted file mode 100644 (file)
index e18f880..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-package semver
-
-import (
-       "sort"
-)
-
-// Versions represents multiple versions.
-type Versions []Version
-
-// Len returns length of version collection
-func (s Versions) Len() int {
-       return len(s)
-}
-
-// Swap swaps two versions inside the collection by its indices
-func (s Versions) Swap(i, j int) {
-       s[i], s[j] = s[j], s[i]
-}
-
-// Less checks if version at index i is less than version at index j
-func (s Versions) Less(i, j int) bool {
-       return s[i].LT(s[j])
-}
-
-// Sort sorts a slice of versions
-func Sort(versions []Version) {
-       sort.Sort(Versions(versions))
-}
diff --git a/tools/semver/sql.go b/tools/semver/sql.go
deleted file mode 100644 (file)
index eb4d802..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-package semver
-
-import (
-       "database/sql/driver"
-       "fmt"
-)
-
-// Scan implements the database/sql.Scanner interface.
-func (v *Version) Scan(src interface{}) (err error) {
-       var str string
-       switch src := src.(type) {
-       case string:
-               str = src
-       case []byte:
-               str = string(src)
-       default:
-               return fmt.Errorf("Version.Scan: cannot convert %T to string.", src)
-       }
-
-       if t, err := Parse(str); err == nil {
-               *v = t
-       }
-
-       return
-}
-
-// Value implements the database/sql/driver.Valuer interface.
-func (v Version) Value() (driver.Value, error) {
-       return v.String(), nil
-}