Skip to content

Commit

Permalink
Merge pull request #295 from vim-volt/devel
Browse files Browse the repository at this point in the history
Release v0.3.7
  • Loading branch information
tyru authored May 26, 2019
2 parents b1c9efd + 01e8510 commit e604467
Show file tree
Hide file tree
Showing 24 changed files with 656 additions and 255 deletions.
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ language: go
matrix:
include:
- os: linux
go: 1.9
go: 1.11.10
env: GO111MODULE="on"
- os: linux
go: tip
go: 1.12.5
env: GO111MODULE="on"
# macOS build *extraordinary* slow, disable them
# - os: osx
# osx_image: xcode8.3
Expand All @@ -14,6 +16,7 @@ matrix:
# osx_image: xcode8.3
# go: tip


script:
- go vet -v ./...
- make test
Expand Down
27 changes: 18 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,16 @@ See [the command reference](https://github.com/vim-volt/volt/blob/master/CMDREF.
* You can switch those combinations with one command
* For example, you can switch various Vim such as Web development mode, Essential plugins + vimrc only, or Vanilla Vim.

## Install
## Quickstart

* **RECOMMENDED**: Download binaries from [GitHub releases](https://github.com/vim-volt/volt/releases)
### Install

* [Download](https://github.com/vim-volt/volt/releases)
* Or `go get github.com/vim-volt/volt`
* You need Go 1.9 or higher
* 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))**
* But it's a hassle, you can just download linux-386/amd64 binaries from [GitHub releases](https://github.com/vim-volt/volt/releases) :)

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

## Self upgrade
### Self upgrade

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

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

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

## Introduction
### vimrc / gvimrc

If you put your vimrc / gvimrc to:

* `$HOME/volt/rc/<profile>/vimrc.vim` (installed to: `$HOME/.vim/vimrc`)
* `$HOME/volt/rc/<profile>/gvimrc.vim` (installed to: `$HOME/.vim/gvimrc`)

The default profile is `default`.

Why volt manages vimrc / gvimrc is to allow easily switching vimrc / gvimrc.
See [the profile feature](https://github.com/vim-volt/volt#switch-set-of-plugins-profile-feature) for details.

### VOLTPATH

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

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

`volt build` synchronizes `~/.vim/pack/volt/...` with `$VOLTPATH/rc` (vimrc/gvimrc), `$VOLTPATH/repos` (repositories), `$VOLTPATH/plugconf` (plugconf):
`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):

1. Install `$VOLTPATH/rc/<profile>/{vimrc.vim,gvimrc.vim}` to `~/.vim/vimrc` and `~/.vim/gvimrc`
1. Copy `$VOLTPATH/repos/<repos>` to `~/.vim/pack/volt/opt/<repos>`
Expand Down
26 changes: 26 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module github.com/vim-volt/volt

require (
github.com/BurntSushi/toml v0.3.0
github.com/fatih/color v1.5.0
github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce
github.com/hashicorp/go-multierror v0.0.0-20171204182908-b7773ae21874
github.com/haya14busa/go-vimlparser v0.0.0-20171121121341-6c96c660fcd0
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99
github.com/mattn/go-colorable v0.0.9
github.com/mattn/go-isatty v0.0.3
github.com/mitchellh/go-homedir v0.0.0-20161203194507-b8bc1bf76747
github.com/pkg/errors v0.8.0
github.com/sergi/go-diff v1.0.0
github.com/src-d/gcfg v1.3.0
github.com/xanzy/ssh-agent v0.2.0
golang.org/x/crypto v0.0.0-20171128194009-94eea52f7b74
golang.org/x/net v0.0.0-20171129192339-a8b929477797
golang.org/x/sys v0.0.0-20171222143536-83801418e1b5
golang.org/x/text v0.0.0-20171204161852-57961680700a
gopkg.in/src-d/go-billy.v3 v3.1.0
gopkg.in/src-d/go-git.v4 v4.0.0-rc15
gopkg.in/warnings.v0 v0.1.2
)

go 1.12.5
61 changes: 61 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
github.com/BurntSushi/toml v0.3.0 h1:e1/Ivsx3Z0FVTV0NSOv/aVgbUWyQuzj7DDnFblkRvsY=
github.com/BurntSushi/toml v0.3.0/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs=
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs=
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/fatih/color v1.5.0 h1:vBh+kQp8lg9XPr56u1CPrWjFXtdphMoGWVHr9/1c+A0=
github.com/fatih/color v1.5.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce h1:prjrVgOk2Yg6w+PflHoszQNLTUh4kaByUcEWM/9uin4=
github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-multierror v0.0.0-20171204182908-b7773ae21874 h1:em+tTnzgU7N22woTBMcSJAOW7tRHAkK597W+MD/CpK8=
github.com/hashicorp/go-multierror v0.0.0-20171204182908-b7773ae21874/go.mod h1:JMRHfdO9jKNzS/+BTlxCjKNQHg/jZAft8U7LloJvN7I=
github.com/haya14busa/go-vimlparser v0.0.0-20171121121341-6c96c660fcd0 h1:sxoYbdIYLfxgz8159xE5mXJUmQeTICnIFeSkkhFVc98=
github.com/haya14busa/go-vimlparser v0.0.0-20171121121341-6c96c660fcd0/go.mod h1:VE0/1pIFG9fOhtMe4dblZq/ObGQn80iOJUQyJ9lmub0=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-isatty v0.0.3 h1:ns/ykhmWi7G9O+8a448SecJU3nSMBXJfqQkl0upE1jI=
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mitchellh/go-homedir v0.0.0-20161203194507-b8bc1bf76747 h1:eQox4Rh4ewJF+mqYPxCkmBAirRnPaHEB26UkNuPyjlk=
github.com/mitchellh/go-homedir v0.0.0-20161203194507-b8bc1bf76747/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
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/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/src-d/gcfg v1.3.0 h1:2BEDr8r0I0b8h/fOqwtxCEiq2HJu8n2JGZJQFGXWLjg=
github.com/src-d/gcfg v1.3.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jWoI=
github.com/src-d/go-git-fixtures v3.5.0+incompatible h1:UajAcIr55moBwZvO0UY6WjV6QTYbNBtMZkz41O55QuY=
github.com/src-d/go-git-fixtures v3.5.0+incompatible/go.mod h1:XcIQp7L+k0pgfTqfbaTKj3kxlBv8kYOKZ/tKNXbZFLg=
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/xanzy/ssh-agent v0.2.0 h1:Adglfbi5p9Z0BmK2oKU9nTG+zKfniSfnaMYB+ULd+Ro=
github.com/xanzy/ssh-agent v0.2.0/go.mod h1:0NyE30eGUDliuLEHJgYte/zncp2zdTStcOnWhgSqHD8=
golang.org/x/crypto v0.0.0-20171128194009-94eea52f7b74 h1:tJPDBgnvRBr/cDv54KIfTbVhREArfmr25jw8GcNSI4A=
golang.org/x/crypto v0.0.0-20171128194009-94eea52f7b74/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/net v0.0.0-20171129192339-a8b929477797 h1:LwuzaILeZdnfjwbkFDc5ex0Us4o0k6PlbZuThgT8a68=
golang.org/x/net v0.0.0-20171129192339-a8b929477797/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/sys v0.0.0-20171222143536-83801418e1b5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180903190138-2b024373dcd9 h1:lkiLiLBHGoH3XnqSLUIaBsilGMUjI+Uy2Xu2JLUtTas=
golang.org/x/sys v0.0.0-20180903190138-2b024373dcd9/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.0.0-20171204161852-57961680700a h1:mPr3OLk7qFT9QAOdjTjhmCduzdp5wGoG0VpMPlr4Eb0=
golang.org/x/text v0.0.0-20171204161852-57961680700a/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
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/src-d/go-billy.v3 v3.1.0 h1:jQUeZbuaZTRIFkumLzrKPbx1HE2oaSr4bwv//3erGN4=
gopkg.in/src-d/go-billy.v3 v3.1.0/go.mod h1:M8qZfUdoeVaxdZyDBaKp3COPKq3Bn3JZH3ycn7wlfBE=
gopkg.in/src-d/go-billy.v4 v4.3.0 h1:KtlZ4c1OWbIs4jCv5ZXrTqG8EQocr0g/d4DjNg70aek=
gopkg.in/src-d/go-billy.v4 v4.3.0/go.mod h1:tm33zBoOwxjYHZIE+OV8bxTWFMJLrconzFMd38aARFk=
gopkg.in/src-d/go-git.v4 v4.0.0-rc15 h1:c8p6Nx7Im3Ns3p2Y3cJ8M9HALggj0FpQuf0HMNfzCz8=
gopkg.in/src-d/go-git.v4 v4.0.0-rc15/go.mod h1:CzbUWqMn4pvmvndg3gnh5iZFmSsbhyhUWdI0IQ60AQo=
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
11 changes: 10 additions & 1 deletion internal/testutil/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package testutil

import (
"fmt"
"github.com/pkg/errors"
"io/ioutil"
"os"
"os/exec"
Expand All @@ -13,6 +12,8 @@ import (
"strings"
"testing"

"github.com/pkg/errors"

"github.com/vim-volt/volt/config"
"github.com/vim-volt/volt/fileutil"
"github.com/vim-volt/volt/lockjson"
Expand Down Expand Up @@ -58,6 +59,13 @@ func SetUpEnv(t *testing.T) {
}
}

func CleanUpEnv(t *testing.T) {
for _, env := range []string{"VOLTPATH", "HOME"} {
parent, _ := filepath.Split(os.Getenv(env))
os.RemoveAll(parent)
}
}

func RunVolt(args ...string) ([]byte, error) {
cmd := exec.Command(voltCommand, args...)
// cmd.Env = append(os.Environ(), "VOLTPATH="+voltpath)
Expand Down Expand Up @@ -141,6 +149,7 @@ func SetUpRepos(t *testing.T, testdataName string, rType lockjson.ReposType, rep
t.Fatalf("failed to set VOLTPATH: %s", err)
}
defer os.Setenv("HOME", home)
defer os.RemoveAll(home)
if err := os.Setenv("VOLTPATH", tmpVoltpath); err != nil {
t.Fatal("failed to set VOLTPATH")
}
Expand Down
47 changes: 35 additions & 12 deletions lockjson/lockjson.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"sort"
"strconv"

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

// sortArrays sorts all arrays in lock.json for generating readable diff output
// when lock.json is under version-controled.
func sortArrays(lockJSON *LockJSON) {
// Sort repos[] by path
sort.SliceStable(lockJSON.Repos, func(i, j int) bool {
return lockJSON.Repos[i].Path.FullPath() < lockJSON.Repos[j].Path.FullPath()
})
// Sort profiles[] by name
sort.SliceStable(lockJSON.Profiles, func(i, j int) bool {
return lockJSON.Profiles[i].Name < lockJSON.Profiles[j].Name
})
// Sort profiles[]/repos_path[] by URLs
for i := range lockJSON.Profiles {
pathList := lockJSON.Profiles[i].ReposPath
sort.SliceStable(pathList, func(i, j int) bool {
return pathList[i] < pathList[j]
})
}
}

func validate(lockJSON *LockJSON) error {
if lockJSON.Version < 1 {
return errors.Errorf("lock.json version is '%d' (must be 1 or greater)", lockJSON.Version)
Expand Down Expand Up @@ -253,6 +274,9 @@ func validateMissing(lockJSON *LockJSON) error {
}

func (lockJSON *LockJSON) Write() error {
// Sort all arrays in lock.json for readable diff
sortArrays(lockJSON)

// Validate lock.json
err := validate(lockJSON)
if err != nil {
Expand Down Expand Up @@ -318,7 +342,7 @@ func (plist ProfileList) RemoveAllReposPath(reposPath pathutil.ReposPath) error
removed := false
for i := range plist {
for j := 0; j < len(plist[i].ReposPath); {
if plist[i].ReposPath[j] == reposPath {
if plist[i].ReposPath[j].Equals(reposPath) {
plist[i].ReposPath = append(
plist[i].ReposPath[:j],
plist[i].ReposPath[j+1:]...,
Expand All @@ -337,26 +361,25 @@ func (plist ProfileList) RemoveAllReposPath(reposPath pathutil.ReposPath) error

// Contains returns true if reposList contains reposPath.
func (reposList ReposList) Contains(reposPath pathutil.ReposPath) bool {
_, err := reposList.FindByPath(reposPath)
return err == nil
return reposList.FindByPath(reposPath) != nil
}

// FindByPath finds reposPath from reposList.
// Non-nil pointer is returned if found.
// nil pointer is returned if not found.
func (reposList ReposList) FindByPath(reposPath pathutil.ReposPath) (*Repos, error) {
func (reposList ReposList) FindByPath(reposPath pathutil.ReposPath) *Repos {
for i := range reposList {
if reposList[i].Path == reposPath {
return &reposList[i], nil
if reposList[i].Path.Equals(reposPath) {
return &reposList[i]
}
}
return nil, errors.New("repos '" + reposPath.String() + "' does not exist")
return nil
}

// RemoveAllReposPath removes all reposPath from all repos path list.
func (reposList *ReposList) RemoveAllReposPath(reposPath pathutil.ReposPath) error {
for i := range *reposList {
if (*reposList)[i].Path == reposPath {
if (*reposList)[i].Path.Equals(reposPath) {
*reposList = append((*reposList)[:i], (*reposList)[i+1:]...)
return nil
}
Expand All @@ -374,7 +397,7 @@ func (reposPathList profReposPath) Contains(reposPath pathutil.ReposPath) bool {
// idx == -1 is returned if not found.
func (reposPathList profReposPath) IndexOf(reposPath pathutil.ReposPath) int {
for i := range reposPathList {
if reposPathList[i] == reposPath {
if reposPathList[i].Equals(reposPath) {
return i
}
}
Expand All @@ -385,9 +408,9 @@ func (reposPathList profReposPath) IndexOf(reposPath pathutil.ReposPath) int {
func (lockJSON *LockJSON) GetReposListByProfile(profile *Profile) (ReposList, error) {
reposList := make(ReposList, 0, len(profile.ReposPath))
for _, reposPath := range profile.ReposPath {
repos, err := lockJSON.Repos.FindByPath(reposPath)
if err != nil {
return nil, err
repos := lockJSON.Repos.FindByPath(reposPath)
if repos == nil {
return nil, errors.New("repos '" + reposPath.String() + "' does not exist")
}
reposList = append(reposList, *repos)
}
Expand Down
Loading

0 comments on commit e604467

Please sign in to comment.