Skip to content

Commit b453c3e

Browse files
committed
Catchup to vsolver; fix compile errs
1 parent 5833d89 commit b453c3e

File tree

5 files changed

+28
-19
lines changed

5 files changed

+28
-19
lines changed

action/install.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package action
22

33
import (
4-
"encoding/hex"
4+
"bytes"
55
"fmt"
66
"io/ioutil"
77
"os"
@@ -31,7 +31,7 @@ func Install(installer *repo.Installer, strip, stripVendor bool) {
3131
}
3232

3333
opts := vsolver.SolveOpts{
34-
Name: vsolver.ProjectName(filepath.Dir(installer.Vendor)),
34+
N: vsolver.ProjectName(filepath.Dir(installer.Vendor)),
3535
Root: filepath.Dir(installer.Vendor),
3636
M: conf,
3737
}
@@ -42,25 +42,25 @@ func Install(installer *repo.Installer, strip, stripVendor bool) {
4242
msg.Die("Could not load lockfile.")
4343
}
4444
// Check if digests match, and warn if they don't
45-
if opts.L.InputHash() != hex.EncodeToString(opts.HashInputs()) {
45+
if bytes.Equal(opts.L.InputHash(), opts.HashInputs()) {
4646
msg.Warn("glide.yaml is out of sync with glide.lock!")
4747
}
48-
err = writeVendor(installer.Vendor, l, sm)
48+
err = writeVendor(installer.Vendor, opts.L, sm)
4949
if err != nil {
50-
msg.Die(err)
50+
msg.Die(err.Error())
5151
}
5252
} else {
5353
// There is no lock, so we solve first
5454
s := vsolver.NewSolver(sm, logrus.New())
5555
r, err := s.Solve(opts)
5656
if err != nil {
5757
// TODO better error handling
58-
msg.Die(err)
58+
msg.Die(err.Error())
5959
}
6060

6161
err = writeVendor(installer.Vendor, r, sm)
6262
if err != nil {
63-
msg.Die(err)
63+
msg.Die(err.Error())
6464
}
6565
}
6666
}
@@ -78,7 +78,7 @@ func writeVendor(vendor string, l vsolver.Lock, sm vsolver.SourceManager) error
7878
return fmt.Errorf("Error while generating vendor tree: %s", err)
7979
}
8080

81-
err = os.Rename(td, installer.Vendor)
81+
err = os.Rename(td, vendor)
8282
if err != nil {
8383
return fmt.Errorf("Error while moving generated vendor directory into place: %s", err)
8484
}

action/update.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func Update(installer *repo.Installer, skipRecursive, strip, stripVendor bool) {
3232
}
3333

3434
opts := vsolver.SolveOpts{
35-
Name: vsolver.ProjectName(filepath.Dir(installer.Vendor)),
35+
N: vsolver.ProjectName(filepath.Dir(installer.Vendor)),
3636
Root: filepath.Dir(installer.Vendor),
3737
M: conf,
3838
}
@@ -48,12 +48,12 @@ func Update(installer *repo.Installer, skipRecursive, strip, stripVendor bool) {
4848
r, err := s.Solve(opts)
4949
if err != nil {
5050
// TODO better error handling
51-
msg.Die(err)
51+
msg.Die(err.Error())
5252
}
5353

5454
err = writeVendor(installer.Vendor, r, sm)
5555
if err != nil {
56-
msg.Die(err)
56+
msg.Die(err.Error())
5757
}
5858

5959
// TODO compare old and new lock, and only change if contents differ
@@ -65,7 +65,7 @@ func Update(installer *repo.Installer, skipRecursive, strip, stripVendor bool) {
6565
}
6666

6767
for _, p := range r.Projects() {
68-
l := &Lock{
68+
l := &cfg.Lock{
6969
Name: string(p.Name()),
7070
Repository: p.URI(), // TODO this is wrong
7171
VcsType: "", // TODO allow this to be extracted from sm
@@ -79,13 +79,13 @@ func Update(installer *repo.Installer, skipRecursive, strip, stripVendor bool) {
7979
}
8080
}
8181

82-
err = l.WriteFile(filepath.Join(base, gpath.LockFile))
82+
err = lf.WriteFile(filepath.Join(base, gpath.LockFile))
8383
if err != nil {
8484
msg.Die("Error on writing new lock file: %s", err)
8585
}
8686

8787
err = writeVendor(installer.Vendor, r, sm)
8888
if err != nil {
89-
msg.Die(err)
89+
msg.Die(err.Error())
9090
}
9191
}

cfg/lock.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cfg
22

33
import (
4+
"encoding/hex"
45
"io/ioutil"
56
"sort"
67
"strings"
@@ -50,8 +51,12 @@ func (lf *Lockfile) WriteFile(lockpath string) error {
5051

5152
// InputHash returns the hash of the input arguments that resulted in this lock
5253
// file.
53-
func (lf *Lockfile) InputHash() string {
54-
return lf.Hash
54+
func (lf *Lockfile) InputHash() []byte {
55+
b, err := hex.DecodeString(lf.Hash)
56+
if err != nil {
57+
return nil
58+
}
59+
return b
5560
}
5661

5762
// Projects returns the list of projects enumerated in the lock file.

glide.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/sdboyer/vsolver/types.go

Lines changed: 6 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)