Skip to content

Commit

Permalink
Merge pull request #176 from vim-volt/devel
Browse files Browse the repository at this point in the history
Release v0.3.1
  • Loading branch information
tyru authored Jan 24, 2018
2 parents fe28800 + 2fa464d commit c2c2788
Show file tree
Hide file tree
Showing 7 changed files with 516 additions and 97 deletions.
27 changes: 27 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,30 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

---

The original source of the part (lazy loading of Ex commands) of generated code in plugconf.makeBundledPlugconf()
URL: https://github.com/Shougo/dein.vim

License: MIT license
AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
70 changes: 33 additions & 37 deletions cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func (cmd *getCmd) doGet(reposPathList []pathutil.ReposPath, lockJSON *lockjson.
} else {
added := cmd.updateReposVersion(lockJSON, r.reposPath, r.reposType, r.hash, profile)
if added && strings.Contains(status, "already exists") {
status = fmt.Sprintf(fmtAddedRepos, statusPrefixInstalled, r.reposPath)
status = fmt.Sprintf(fmtAddedRepos, r.reposPath)
}
updatedLockJSON = true
}
Expand Down Expand Up @@ -291,21 +291,19 @@ type getParallelResult struct {
}

const (
statusPrefixFailed = "!"
statusPrefixNoChange = "#"
statusPrefixInstalled = "+"
statusPrefixUpgraded = "*"
)

const (
fmtInstallFailed = "%s %s > install failed > %s"
fmtUpgradeFailed = "%s %s > upgrade failed > %s"
fmtNoChange = "%s %s > no change"
fmtAlreadyExists = "%s %s > already exists"
fmtAddedRepos = "%s %s > added repository to current profile"
fmtInstalled = "%s %s > installed"
fmtRevUpdate = "%s %s > updated lock.json revision (%s..%s)"
fmtUpgraded = "%s %s > upgraded (%s..%s)"
statusPrefixFailed = "!"
// Failed
fmtInstallFailed = "! %s > install failed > %s"
fmtUpgradeFailed = "! %s > upgrade failed > %s"
// No change
fmtNoChange = "# %s > no change"
fmtAlreadyExists = "# %s > already exists"
// Installed
fmtAddedRepos = "+ %s > added repository to current profile"
fmtInstalled = "+ %s > installed"
// Upgraded
fmtRevUpdate = "* %s > updated lock.json revision (%s..%s)"
fmtUpgraded = "* %s > upgraded (%s..%s)"
)

// This function is executed in goroutine of each plugin.
Expand All @@ -328,6 +326,7 @@ func (cmd *getCmd) installPlugin(reposPath pathutil.ReposPath, repos *lockjson.R
// true:upgrade, false:install
fullReposPath := pathutil.FullReposPath(reposPath)
doUpgrade := cmd.upgrade && pathutil.Exists(fullReposPath)
doInstall := !pathutil.Exists(fullReposPath)

var fromHash string
var err error
Expand All @@ -343,7 +342,7 @@ func (cmd *getCmd) installPlugin(reposPath pathutil.ReposPath, repos *lockjson.R
}
done <- getParallelResult{
reposPath: reposPath,
status: fmt.Sprintf(fmtInstallFailed, statusPrefixFailed, reposPath, result.Error()),
status: fmt.Sprintf(fmtInstallFailed, reposPath, result.Error()),
err: result,
}
return
Expand All @@ -352,14 +351,15 @@ func (cmd *getCmd) installPlugin(reposPath pathutil.ReposPath, repos *lockjson.R

var status string
var upgraded bool
var checkRevision bool

if doUpgrade {
// when cmd.upgrade is true, repos must not be nil.
if repos == nil {
msg := "-u was specified but repos == nil"
done <- getParallelResult{
reposPath: reposPath,
status: fmt.Sprintf(fmtUpgradeFailed, statusPrefixFailed, reposPath, msg),
status: fmt.Sprintf(fmtUpgradeFailed, reposPath, msg),
err: errors.New("failed to upgrade plugin: " + msg),
}
return
Expand All @@ -376,22 +376,21 @@ func (cmd *getCmd) installPlugin(reposPath pathutil.ReposPath, repos *lockjson.R
}
done <- getParallelResult{
reposPath: reposPath,
status: fmt.Sprintf(fmtUpgradeFailed, statusPrefixFailed, reposPath, err.Error()),
status: fmt.Sprintf(fmtUpgradeFailed, reposPath, err.Error()),
err: result,
}
return
}
if err == git.NoErrAlreadyUpToDate {
status = fmt.Sprintf(fmtNoChange, statusPrefixNoChange, reposPath)
status = fmt.Sprintf(fmtNoChange, reposPath)
} else {
upgraded = true
}
} else if !pathutil.Exists(fullReposPath) {
} else if doInstall {
// Install plugin
logger.Debug("Installing " + reposPath + " ...")
err := cmd.fetchPlugin(reposPath)
// if err == errRepoExists, silently skip
if err != nil && err != errRepoExists {
if err != nil {
result := errors.New("failed to install plugin: " + err.Error())
logger.Debug("Rollbacking " + fullReposPath + " ...")
err = cmd.rollbackRepos(fullReposPath)
Expand All @@ -400,16 +399,15 @@ func (cmd *getCmd) installPlugin(reposPath pathutil.ReposPath, repos *lockjson.R
}
done <- getParallelResult{
reposPath: reposPath,
status: fmt.Sprintf(fmtInstallFailed, statusPrefixFailed, reposPath, result.Error()),
status: fmt.Sprintf(fmtInstallFailed, reposPath, result.Error()),
err: result,
}
return
}
if err == errRepoExists {
status = fmt.Sprintf(fmtAlreadyExists, statusPrefixNoChange, reposPath)
} else {
status = fmt.Sprintf(fmtInstalled, statusPrefixInstalled, reposPath)
}
status = fmt.Sprintf(fmtInstalled, reposPath)
} else {
status = fmt.Sprintf(fmtAlreadyExists, reposPath)
checkRevision = true
}

var toHash string
Expand All @@ -426,7 +424,7 @@ func (cmd *getCmd) installPlugin(reposPath pathutil.ReposPath, repos *lockjson.R
}
done <- getParallelResult{
reposPath: reposPath,
status: fmt.Sprintf(fmtInstallFailed, statusPrefixFailed, reposPath, result.Error()),
status: fmt.Sprintf(fmtInstallFailed, reposPath, result.Error()),
err: result,
}
return
Expand All @@ -435,13 +433,11 @@ func (cmd *getCmd) installPlugin(reposPath pathutil.ReposPath, repos *lockjson.R

// Show old and new revisions: "upgraded ({from}..{to})".
if upgraded {
status = fmt.Sprintf(fmtUpgraded, statusPrefixUpgraded, reposPath, fromHash, toHash)
status = fmt.Sprintf(fmtUpgraded, reposPath, fromHash, toHash)
}

if repos != nil && repos.Version != toHash {
status = fmt.Sprintf(fmtRevUpdate, statusPrefixUpgraded, reposPath, repos.Version, toHash)
} else {
status = fmt.Sprintf(fmtNoChange, statusPrefixNoChange, reposPath)
if checkRevision && repos != nil && repos.Version != toHash {
status = fmt.Sprintf(fmtRevUpdate, reposPath, repos.Version, toHash)
}

done <- getParallelResult{
Expand All @@ -466,7 +462,7 @@ func (cmd *getCmd) installPlugconf(reposPath pathutil.ReposPath, pluginResult *g
}
done <- getParallelResult{
reposPath: reposPath,
status: fmt.Sprintf(fmtInstallFailed, statusPrefixFailed, reposPath, result.Error()),
status: fmt.Sprintf(fmtInstallFailed, reposPath, result.Error()),
err: result,
}
return
Expand Down Expand Up @@ -566,7 +562,7 @@ func (cmd *getCmd) fetchPlugconf(reposPath pathutil.ReposPath) error {
}
content, err := plugconf.GenPlugconfByTemplate(tmpl, filename)
if err != nil {
return err
return fmt.Errorf("parse error in fetched plugconf %s: %s", reposPath, err.Error())
}
os.MkdirAll(filepath.Dir(filename), 0755)
err = ioutil.WriteFile(filename, content, 0644)
Expand Down
Loading

0 comments on commit c2c2788

Please sign in to comment.