Skip to content

Commit c2c2788

Browse files
authored
Merge pull request #176 from vim-volt/devel
Release v0.3.1
2 parents fe28800 + 2fa464d commit c2c2788

File tree

7 files changed

+516
-97
lines changed

7 files changed

+516
-97
lines changed

LICENSE

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,30 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4646
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4747
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
4848
SOFTWARE.
49+
50+
---
51+
52+
The original source of the part (lazy loading of Ex commands) of generated code in plugconf.makeBundledPlugconf()
53+
URL: https://github.com/Shougo/dein.vim
54+
55+
License: MIT license
56+
AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com>
57+
58+
Permission is hereby granted, free of charge, to any person obtaining
59+
a copy of this software and associated documentation files (the
60+
"Software"), to deal in the Software without restriction, including
61+
without limitation the rights to use, copy, modify, merge, publish,
62+
distribute, sublicense, and/or sell copies of the Software, and to
63+
permit persons to whom the Software is furnished to do so, subject to
64+
the following conditions:
65+
66+
The above copyright notice and this permission notice shall be included
67+
in all copies or substantial portions of the Software.
68+
69+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
70+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
71+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
72+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
73+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
74+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
75+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

cmd/get.go

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ func (cmd *getCmd) doGet(reposPathList []pathutil.ReposPath, lockJSON *lockjson.
229229
} else {
230230
added := cmd.updateReposVersion(lockJSON, r.reposPath, r.reposType, r.hash, profile)
231231
if added && strings.Contains(status, "already exists") {
232-
status = fmt.Sprintf(fmtAddedRepos, statusPrefixInstalled, r.reposPath)
232+
status = fmt.Sprintf(fmtAddedRepos, r.reposPath)
233233
}
234234
updatedLockJSON = true
235235
}
@@ -291,21 +291,19 @@ type getParallelResult struct {
291291
}
292292

293293
const (
294-
statusPrefixFailed = "!"
295-
statusPrefixNoChange = "#"
296-
statusPrefixInstalled = "+"
297-
statusPrefixUpgraded = "*"
298-
)
299-
300-
const (
301-
fmtInstallFailed = "%s %s > install failed > %s"
302-
fmtUpgradeFailed = "%s %s > upgrade failed > %s"
303-
fmtNoChange = "%s %s > no change"
304-
fmtAlreadyExists = "%s %s > already exists"
305-
fmtAddedRepos = "%s %s > added repository to current profile"
306-
fmtInstalled = "%s %s > installed"
307-
fmtRevUpdate = "%s %s > updated lock.json revision (%s..%s)"
308-
fmtUpgraded = "%s %s > upgraded (%s..%s)"
294+
statusPrefixFailed = "!"
295+
// Failed
296+
fmtInstallFailed = "! %s > install failed > %s"
297+
fmtUpgradeFailed = "! %s > upgrade failed > %s"
298+
// No change
299+
fmtNoChange = "# %s > no change"
300+
fmtAlreadyExists = "# %s > already exists"
301+
// Installed
302+
fmtAddedRepos = "+ %s > added repository to current profile"
303+
fmtInstalled = "+ %s > installed"
304+
// Upgraded
305+
fmtRevUpdate = "* %s > updated lock.json revision (%s..%s)"
306+
fmtUpgraded = "* %s > upgraded (%s..%s)"
309307
)
310308

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

332331
var fromHash string
333332
var err error
@@ -343,7 +342,7 @@ func (cmd *getCmd) installPlugin(reposPath pathutil.ReposPath, repos *lockjson.R
343342
}
344343
done <- getParallelResult{
345344
reposPath: reposPath,
346-
status: fmt.Sprintf(fmtInstallFailed, statusPrefixFailed, reposPath, result.Error()),
345+
status: fmt.Sprintf(fmtInstallFailed, reposPath, result.Error()),
347346
err: result,
348347
}
349348
return
@@ -352,14 +351,15 @@ func (cmd *getCmd) installPlugin(reposPath pathutil.ReposPath, repos *lockjson.R
352351

353352
var status string
354353
var upgraded bool
354+
var checkRevision bool
355355

356356
if doUpgrade {
357357
// when cmd.upgrade is true, repos must not be nil.
358358
if repos == nil {
359359
msg := "-u was specified but repos == nil"
360360
done <- getParallelResult{
361361
reposPath: reposPath,
362-
status: fmt.Sprintf(fmtUpgradeFailed, statusPrefixFailed, reposPath, msg),
362+
status: fmt.Sprintf(fmtUpgradeFailed, reposPath, msg),
363363
err: errors.New("failed to upgrade plugin: " + msg),
364364
}
365365
return
@@ -376,22 +376,21 @@ func (cmd *getCmd) installPlugin(reposPath pathutil.ReposPath, repos *lockjson.R
376376
}
377377
done <- getParallelResult{
378378
reposPath: reposPath,
379-
status: fmt.Sprintf(fmtUpgradeFailed, statusPrefixFailed, reposPath, err.Error()),
379+
status: fmt.Sprintf(fmtUpgradeFailed, reposPath, err.Error()),
380380
err: result,
381381
}
382382
return
383383
}
384384
if err == git.NoErrAlreadyUpToDate {
385-
status = fmt.Sprintf(fmtNoChange, statusPrefixNoChange, reposPath)
385+
status = fmt.Sprintf(fmtNoChange, reposPath)
386386
} else {
387387
upgraded = true
388388
}
389-
} else if !pathutil.Exists(fullReposPath) {
389+
} else if doInstall {
390390
// Install plugin
391391
logger.Debug("Installing " + reposPath + " ...")
392392
err := cmd.fetchPlugin(reposPath)
393-
// if err == errRepoExists, silently skip
394-
if err != nil && err != errRepoExists {
393+
if err != nil {
395394
result := errors.New("failed to install plugin: " + err.Error())
396395
logger.Debug("Rollbacking " + fullReposPath + " ...")
397396
err = cmd.rollbackRepos(fullReposPath)
@@ -400,16 +399,15 @@ func (cmd *getCmd) installPlugin(reposPath pathutil.ReposPath, repos *lockjson.R
400399
}
401400
done <- getParallelResult{
402401
reposPath: reposPath,
403-
status: fmt.Sprintf(fmtInstallFailed, statusPrefixFailed, reposPath, result.Error()),
402+
status: fmt.Sprintf(fmtInstallFailed, reposPath, result.Error()),
404403
err: result,
405404
}
406405
return
407406
}
408-
if err == errRepoExists {
409-
status = fmt.Sprintf(fmtAlreadyExists, statusPrefixNoChange, reposPath)
410-
} else {
411-
status = fmt.Sprintf(fmtInstalled, statusPrefixInstalled, reposPath)
412-
}
407+
status = fmt.Sprintf(fmtInstalled, reposPath)
408+
} else {
409+
status = fmt.Sprintf(fmtAlreadyExists, reposPath)
410+
checkRevision = true
413411
}
414412

415413
var toHash string
@@ -426,7 +424,7 @@ func (cmd *getCmd) installPlugin(reposPath pathutil.ReposPath, repos *lockjson.R
426424
}
427425
done <- getParallelResult{
428426
reposPath: reposPath,
429-
status: fmt.Sprintf(fmtInstallFailed, statusPrefixFailed, reposPath, result.Error()),
427+
status: fmt.Sprintf(fmtInstallFailed, reposPath, result.Error()),
430428
err: result,
431429
}
432430
return
@@ -435,13 +433,11 @@ func (cmd *getCmd) installPlugin(reposPath pathutil.ReposPath, repos *lockjson.R
435433

436434
// Show old and new revisions: "upgraded ({from}..{to})".
437435
if upgraded {
438-
status = fmt.Sprintf(fmtUpgraded, statusPrefixUpgraded, reposPath, fromHash, toHash)
436+
status = fmt.Sprintf(fmtUpgraded, reposPath, fromHash, toHash)
439437
}
440438

441-
if repos != nil && repos.Version != toHash {
442-
status = fmt.Sprintf(fmtRevUpdate, statusPrefixUpgraded, reposPath, repos.Version, toHash)
443-
} else {
444-
status = fmt.Sprintf(fmtNoChange, statusPrefixNoChange, reposPath)
439+
if checkRevision && repos != nil && repos.Version != toHash {
440+
status = fmt.Sprintf(fmtRevUpdate, reposPath, repos.Version, toHash)
445441
}
446442

447443
done <- getParallelResult{
@@ -466,7 +462,7 @@ func (cmd *getCmd) installPlugconf(reposPath pathutil.ReposPath, pluginResult *g
466462
}
467463
done <- getParallelResult{
468464
reposPath: reposPath,
469-
status: fmt.Sprintf(fmtInstallFailed, statusPrefixFailed, reposPath, result.Error()),
465+
status: fmt.Sprintf(fmtInstallFailed, reposPath, result.Error()),
470466
err: result,
471467
}
472468
return
@@ -566,7 +562,7 @@ func (cmd *getCmd) fetchPlugconf(reposPath pathutil.ReposPath) error {
566562
}
567563
content, err := plugconf.GenPlugconfByTemplate(tmpl, filename)
568564
if err != nil {
569-
return err
565+
return fmt.Errorf("parse error in fetched plugconf %s: %s", reposPath, err.Error())
570566
}
571567
os.MkdirAll(filepath.Dir(filename), 0755)
572568
err = ioutil.WriteFile(filename, content, 0644)

0 commit comments

Comments
 (0)