Skip to content

Commit e604467

Browse files
authored
Merge pull request #295 from vim-volt/devel
Release v0.3.7
2 parents b1c9efd + 01e8510 commit e604467

24 files changed

+656
-255
lines changed

.travis.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ language: go
33
matrix:
44
include:
55
- os: linux
6-
go: 1.9
6+
go: 1.11.10
7+
env: GO111MODULE="on"
78
- os: linux
8-
go: tip
9+
go: 1.12.5
10+
env: GO111MODULE="on"
911
# macOS build *extraordinary* slow, disable them
1012
# - os: osx
1113
# osx_image: xcode8.3
@@ -14,6 +16,7 @@ matrix:
1416
# osx_image: xcode8.3
1517
# go: tip
1618

19+
1720
script:
1821
- go vet -v ./...
1922
- make test

README.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,16 @@ See [the command reference](https://github.com/vim-volt/volt/blob/master/CMDREF.
5656
* You can switch those combinations with one command
5757
* For example, you can switch various Vim such as Web development mode, Essential plugins + vimrc only, or Vanilla Vim.
5858

59-
## Install
59+
## Quickstart
6060

61-
* **RECOMMENDED**: Download binaries from [GitHub releases](https://github.com/vim-volt/volt/releases)
61+
### Install
62+
63+
* [Download](https://github.com/vim-volt/volt/releases)
6264
* Or `go get github.com/vim-volt/volt`
63-
* You need Go 1.9 or higher
64-
* And if you are using Windows Subsystem Linux, you need to apply **[the patch for os.RemoveAll()](https://go-review.googlesource.com/c/go/+/62970) ! ([#1](https://github.com/vim-volt/go-volt/issues/1))**
65-
* But it's a hassle, you can just download linux-386/amd64 binaries from [GitHub releases](https://github.com/vim-volt/volt/releases) :)
6665

67-
And there is bash completion script in [\_contrib](https://github.com/vim-volt/volt/blob/master/_contrib/completion/bash) directory (thanks @AvianY).
66+
Optional: Bash/Zsh completion scripts in [\_contrib/completion/](https://github.com/vim-volt/volt/blob/master/_contrib/completion) directory (by @AvianY, @mrymtsk).
6867

69-
## Self upgrade
68+
### Self upgrade
7069

7170
If you already have older version's `volt` command, you can use `volt self-upgrade` command.
7271

@@ -78,7 +77,17 @@ will upgrade current running volt binary to the latest version if the [newer rel
7877

7978
Or also you can just checks if the newer releases published by running `volt self-upgrade -check`.
8079

81-
## Introduction
80+
### vimrc / gvimrc
81+
82+
If you put your vimrc / gvimrc to:
83+
84+
* `$HOME/volt/rc/<profile>/vimrc.vim` (installed to: `$HOME/.vim/vimrc`)
85+
* `$HOME/volt/rc/<profile>/gvimrc.vim` (installed to: `$HOME/.vim/gvimrc`)
86+
87+
The default profile is `default`.
88+
89+
Why volt manages vimrc / gvimrc is to allow easily switching vimrc / gvimrc.
90+
See [the profile feature](https://github.com/vim-volt/volt#switch-set-of-plugins-profile-feature) for details.
8291

8392
### VOLTPATH
8493

@@ -144,7 +153,7 @@ $ volt rm tyru/caw.vim # (sob)
144153

145154
![volt build](https://raw.githubusercontent.com/vim-volt/volt/master/img/volt-build.png)
146155

147-
`volt build` synchronizes `~/.vim/pack/volt/...` with `$VOLTPATH/rc` (vimrc/gvimrc), `$VOLTPATH/repos` (repositories), `$VOLTPATH/plugconf` (plugconf):
156+
`volt build` synchronizes `~/.vim/pack/volt/...` with `$VOLTPATH/rc/<profile>/vimrc.vim` and `$VOLTPATH/rc/<profile>/gvimrc.vim` (if exists), `$VOLTPATH/repos` (repositories), `$VOLTPATH/plugconf` (plugconf):
148157

149158
1. Install `$VOLTPATH/rc/<profile>/{vimrc.vim,gvimrc.vim}` to `~/.vim/vimrc` and `~/.vim/gvimrc`
150159
1. Copy `$VOLTPATH/repos/<repos>` to `~/.vim/pack/volt/opt/<repos>`

go.mod

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module github.com/vim-volt/volt
2+
3+
require (
4+
github.com/BurntSushi/toml v0.3.0
5+
github.com/fatih/color v1.5.0
6+
github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce
7+
github.com/hashicorp/go-multierror v0.0.0-20171204182908-b7773ae21874
8+
github.com/haya14busa/go-vimlparser v0.0.0-20171121121341-6c96c660fcd0
9+
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99
10+
github.com/mattn/go-colorable v0.0.9
11+
github.com/mattn/go-isatty v0.0.3
12+
github.com/mitchellh/go-homedir v0.0.0-20161203194507-b8bc1bf76747
13+
github.com/pkg/errors v0.8.0
14+
github.com/sergi/go-diff v1.0.0
15+
github.com/src-d/gcfg v1.3.0
16+
github.com/xanzy/ssh-agent v0.2.0
17+
golang.org/x/crypto v0.0.0-20171128194009-94eea52f7b74
18+
golang.org/x/net v0.0.0-20171129192339-a8b929477797
19+
golang.org/x/sys v0.0.0-20171222143536-83801418e1b5
20+
golang.org/x/text v0.0.0-20171204161852-57961680700a
21+
gopkg.in/src-d/go-billy.v3 v3.1.0
22+
gopkg.in/src-d/go-git.v4 v4.0.0-rc15
23+
gopkg.in/warnings.v0 v0.1.2
24+
)
25+
26+
go 1.12.5

go.sum

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
github.com/BurntSushi/toml v0.3.0 h1:e1/Ivsx3Z0FVTV0NSOv/aVgbUWyQuzj7DDnFblkRvsY=
2+
github.com/BurntSushi/toml v0.3.0/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
3+
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs=
4+
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs=
5+
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
6+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
7+
github.com/fatih/color v1.5.0 h1:vBh+kQp8lg9XPr56u1CPrWjFXtdphMoGWVHr9/1c+A0=
8+
github.com/fatih/color v1.5.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
9+
github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce h1:prjrVgOk2Yg6w+PflHoszQNLTUh4kaByUcEWM/9uin4=
10+
github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
11+
github.com/hashicorp/go-multierror v0.0.0-20171204182908-b7773ae21874 h1:em+tTnzgU7N22woTBMcSJAOW7tRHAkK597W+MD/CpK8=
12+
github.com/hashicorp/go-multierror v0.0.0-20171204182908-b7773ae21874/go.mod h1:JMRHfdO9jKNzS/+BTlxCjKNQHg/jZAft8U7LloJvN7I=
13+
github.com/haya14busa/go-vimlparser v0.0.0-20171121121341-6c96c660fcd0 h1:sxoYbdIYLfxgz8159xE5mXJUmQeTICnIFeSkkhFVc98=
14+
github.com/haya14busa/go-vimlparser v0.0.0-20171121121341-6c96c660fcd0/go.mod h1:VE0/1pIFG9fOhtMe4dblZq/ObGQn80iOJUQyJ9lmub0=
15+
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
16+
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
17+
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
18+
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
19+
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
20+
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
21+
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
22+
github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
23+
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
24+
github.com/mattn/go-isatty v0.0.3 h1:ns/ykhmWi7G9O+8a448SecJU3nSMBXJfqQkl0upE1jI=
25+
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
26+
github.com/mitchellh/go-homedir v0.0.0-20161203194507-b8bc1bf76747 h1:eQox4Rh4ewJF+mqYPxCkmBAirRnPaHEB26UkNuPyjlk=
27+
github.com/mitchellh/go-homedir v0.0.0-20161203194507-b8bc1bf76747/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
28+
github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
29+
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
30+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
31+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
32+
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
33+
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
34+
github.com/src-d/gcfg v1.3.0 h1:2BEDr8r0I0b8h/fOqwtxCEiq2HJu8n2JGZJQFGXWLjg=
35+
github.com/src-d/gcfg v1.3.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jWoI=
36+
github.com/src-d/go-git-fixtures v3.5.0+incompatible h1:UajAcIr55moBwZvO0UY6WjV6QTYbNBtMZkz41O55QuY=
37+
github.com/src-d/go-git-fixtures v3.5.0+incompatible/go.mod h1:XcIQp7L+k0pgfTqfbaTKj3kxlBv8kYOKZ/tKNXbZFLg=
38+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
39+
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
40+
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
41+
github.com/xanzy/ssh-agent v0.2.0 h1:Adglfbi5p9Z0BmK2oKU9nTG+zKfniSfnaMYB+ULd+Ro=
42+
github.com/xanzy/ssh-agent v0.2.0/go.mod h1:0NyE30eGUDliuLEHJgYte/zncp2zdTStcOnWhgSqHD8=
43+
golang.org/x/crypto v0.0.0-20171128194009-94eea52f7b74 h1:tJPDBgnvRBr/cDv54KIfTbVhREArfmr25jw8GcNSI4A=
44+
golang.org/x/crypto v0.0.0-20171128194009-94eea52f7b74/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
45+
golang.org/x/net v0.0.0-20171129192339-a8b929477797 h1:LwuzaILeZdnfjwbkFDc5ex0Us4o0k6PlbZuThgT8a68=
46+
golang.org/x/net v0.0.0-20171129192339-a8b929477797/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
47+
golang.org/x/sys v0.0.0-20171222143536-83801418e1b5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
48+
golang.org/x/sys v0.0.0-20180903190138-2b024373dcd9 h1:lkiLiLBHGoH3XnqSLUIaBsilGMUjI+Uy2Xu2JLUtTas=
49+
golang.org/x/sys v0.0.0-20180903190138-2b024373dcd9/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
50+
golang.org/x/text v0.0.0-20171204161852-57961680700a h1:mPr3OLk7qFT9QAOdjTjhmCduzdp5wGoG0VpMPlr4Eb0=
51+
golang.org/x/text v0.0.0-20171204161852-57961680700a/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
52+
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
53+
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
54+
gopkg.in/src-d/go-billy.v3 v3.1.0 h1:jQUeZbuaZTRIFkumLzrKPbx1HE2oaSr4bwv//3erGN4=
55+
gopkg.in/src-d/go-billy.v3 v3.1.0/go.mod h1:M8qZfUdoeVaxdZyDBaKp3COPKq3Bn3JZH3ycn7wlfBE=
56+
gopkg.in/src-d/go-billy.v4 v4.3.0 h1:KtlZ4c1OWbIs4jCv5ZXrTqG8EQocr0g/d4DjNg70aek=
57+
gopkg.in/src-d/go-billy.v4 v4.3.0/go.mod h1:tm33zBoOwxjYHZIE+OV8bxTWFMJLrconzFMd38aARFk=
58+
gopkg.in/src-d/go-git.v4 v4.0.0-rc15 h1:c8p6Nx7Im3Ns3p2Y3cJ8M9HALggj0FpQuf0HMNfzCz8=
59+
gopkg.in/src-d/go-git.v4 v4.0.0-rc15/go.mod h1:CzbUWqMn4pvmvndg3gnh5iZFmSsbhyhUWdI0IQ60AQo=
60+
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
61+
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=

internal/testutil/testutil.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package testutil
22

33
import (
44
"fmt"
5-
"github.com/pkg/errors"
65
"io/ioutil"
76
"os"
87
"os/exec"
@@ -13,6 +12,8 @@ import (
1312
"strings"
1413
"testing"
1514

15+
"github.com/pkg/errors"
16+
1617
"github.com/vim-volt/volt/config"
1718
"github.com/vim-volt/volt/fileutil"
1819
"github.com/vim-volt/volt/lockjson"
@@ -58,6 +59,13 @@ func SetUpEnv(t *testing.T) {
5859
}
5960
}
6061

62+
func CleanUpEnv(t *testing.T) {
63+
for _, env := range []string{"VOLTPATH", "HOME"} {
64+
parent, _ := filepath.Split(os.Getenv(env))
65+
os.RemoveAll(parent)
66+
}
67+
}
68+
6169
func RunVolt(args ...string) ([]byte, error) {
6270
cmd := exec.Command(voltCommand, args...)
6371
// cmd.Env = append(os.Environ(), "VOLTPATH="+voltpath)
@@ -141,6 +149,7 @@ func SetUpRepos(t *testing.T, testdataName string, rType lockjson.ReposType, rep
141149
t.Fatalf("failed to set VOLTPATH: %s", err)
142150
}
143151
defer os.Setenv("HOME", home)
152+
defer os.RemoveAll(home)
144153
if err := os.Setenv("VOLTPATH", tmpVoltpath); err != nil {
145154
t.Fatal("failed to set VOLTPATH")
146155
}

lockjson/lockjson.go

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"io/ioutil"
66
"os"
77
"path/filepath"
8+
"sort"
89
"strconv"
910

1011
"github.com/pkg/errors"
@@ -118,6 +119,26 @@ func read(doLog bool) (*LockJSON, error) {
118119
return &lockJSON, nil
119120
}
120121

122+
// sortArrays sorts all arrays in lock.json for generating readable diff output
123+
// when lock.json is under version-controled.
124+
func sortArrays(lockJSON *LockJSON) {
125+
// Sort repos[] by path
126+
sort.SliceStable(lockJSON.Repos, func(i, j int) bool {
127+
return lockJSON.Repos[i].Path.FullPath() < lockJSON.Repos[j].Path.FullPath()
128+
})
129+
// Sort profiles[] by name
130+
sort.SliceStable(lockJSON.Profiles, func(i, j int) bool {
131+
return lockJSON.Profiles[i].Name < lockJSON.Profiles[j].Name
132+
})
133+
// Sort profiles[]/repos_path[] by URLs
134+
for i := range lockJSON.Profiles {
135+
pathList := lockJSON.Profiles[i].ReposPath
136+
sort.SliceStable(pathList, func(i, j int) bool {
137+
return pathList[i] < pathList[j]
138+
})
139+
}
140+
}
141+
121142
func validate(lockJSON *LockJSON) error {
122143
if lockJSON.Version < 1 {
123144
return errors.Errorf("lock.json version is '%d' (must be 1 or greater)", lockJSON.Version)
@@ -253,6 +274,9 @@ func validateMissing(lockJSON *LockJSON) error {
253274
}
254275

255276
func (lockJSON *LockJSON) Write() error {
277+
// Sort all arrays in lock.json for readable diff
278+
sortArrays(lockJSON)
279+
256280
// Validate lock.json
257281
err := validate(lockJSON)
258282
if err != nil {
@@ -318,7 +342,7 @@ func (plist ProfileList) RemoveAllReposPath(reposPath pathutil.ReposPath) error
318342
removed := false
319343
for i := range plist {
320344
for j := 0; j < len(plist[i].ReposPath); {
321-
if plist[i].ReposPath[j] == reposPath {
345+
if plist[i].ReposPath[j].Equals(reposPath) {
322346
plist[i].ReposPath = append(
323347
plist[i].ReposPath[:j],
324348
plist[i].ReposPath[j+1:]...,
@@ -337,26 +361,25 @@ func (plist ProfileList) RemoveAllReposPath(reposPath pathutil.ReposPath) error
337361

338362
// Contains returns true if reposList contains reposPath.
339363
func (reposList ReposList) Contains(reposPath pathutil.ReposPath) bool {
340-
_, err := reposList.FindByPath(reposPath)
341-
return err == nil
364+
return reposList.FindByPath(reposPath) != nil
342365
}
343366

344367
// FindByPath finds reposPath from reposList.
345368
// Non-nil pointer is returned if found.
346369
// nil pointer is returned if not found.
347-
func (reposList ReposList) FindByPath(reposPath pathutil.ReposPath) (*Repos, error) {
370+
func (reposList ReposList) FindByPath(reposPath pathutil.ReposPath) *Repos {
348371
for i := range reposList {
349-
if reposList[i].Path == reposPath {
350-
return &reposList[i], nil
372+
if reposList[i].Path.Equals(reposPath) {
373+
return &reposList[i]
351374
}
352375
}
353-
return nil, errors.New("repos '" + reposPath.String() + "' does not exist")
376+
return nil
354377
}
355378

356379
// RemoveAllReposPath removes all reposPath from all repos path list.
357380
func (reposList *ReposList) RemoveAllReposPath(reposPath pathutil.ReposPath) error {
358381
for i := range *reposList {
359-
if (*reposList)[i].Path == reposPath {
382+
if (*reposList)[i].Path.Equals(reposPath) {
360383
*reposList = append((*reposList)[:i], (*reposList)[i+1:]...)
361384
return nil
362385
}
@@ -374,7 +397,7 @@ func (reposPathList profReposPath) Contains(reposPath pathutil.ReposPath) bool {
374397
// idx == -1 is returned if not found.
375398
func (reposPathList profReposPath) IndexOf(reposPath pathutil.ReposPath) int {
376399
for i := range reposPathList {
377-
if reposPathList[i] == reposPath {
400+
if reposPathList[i].Equals(reposPath) {
378401
return i
379402
}
380403
}
@@ -385,9 +408,9 @@ func (reposPathList profReposPath) IndexOf(reposPath pathutil.ReposPath) int {
385408
func (lockJSON *LockJSON) GetReposListByProfile(profile *Profile) (ReposList, error) {
386409
reposList := make(ReposList, 0, len(profile.ReposPath))
387410
for _, reposPath := range profile.ReposPath {
388-
repos, err := lockJSON.Repos.FindByPath(reposPath)
389-
if err != nil {
390-
return nil, err
411+
repos := lockJSON.Repos.FindByPath(reposPath)
412+
if repos == nil {
413+
return nil, errors.New("repos '" + reposPath.String() + "' does not exist")
391414
}
392415
reposList = append(reposList, *repos)
393416
}

0 commit comments

Comments
 (0)