MCPcopy Create free account
hub / github.com/Masterminds/glide / Update

Function Update

action/update.go:15–113  ·  view source on GitHub ↗

Update updates repos and the lock file from the main glide yaml.

(installer *repo.Installer, skipRecursive, stripVendor bool)

Source from the content-addressed store, hash-verified

13
14// Update updates repos and the lock file from the main glide yaml.
15func Update(installer *repo.Installer, skipRecursive, stripVendor bool) {
16 cache.SystemLock()
17
18 base := "."
19 EnsureGopath()
20 EnsureVendorDir()
21 conf := EnsureConfig()
22
23 // Try to check out the initial dependencies.
24 if err := installer.Checkout(conf); err != nil {
25 msg.Die("Failed to do initial checkout of config: %s", err)
26 }
27
28 // Set the versions for the initial dependencies so that resolved dependencies
29 // are rooted in the correct version of the base.
30 if err := repo.SetReference(conf, installer.ResolveTest); err != nil {
31 msg.Die("Failed to set initial config references: %s", err)
32 }
33
34 // Prior to resolving dependencies we need to start working with a clone
35 // of the conf because we'll be making real changes to it.
36 confcopy := conf.Clone()
37
38 if !skipRecursive {
39 // Get all repos and update them.
40 err := installer.Update(confcopy)
41 if err != nil {
42 msg.Die("Could not update packages: %s", err)
43 }
44
45 // Set references. There may be no remaining references to set since the
46 // installer set them as it went to make sure it parsed the right imports
47 // from the right version of the package.
48 msg.Info("Setting references for remaining imports")
49 if err := repo.SetReference(confcopy, installer.ResolveTest); err != nil {
50 msg.Err("Failed to set references: %s (Skip to cleanup)", err)
51 }
52 }
53
54 err := installer.Export(confcopy)
55 if err != nil {
56 msg.Die("Unable to export dependencies to vendor directory: %s", err)
57 }
58
59 // Write glide.yaml (Why? Godeps/GPM/GB?)
60 // I think we don't need to write a new Glide file because update should not
61 // change anything important. It will just generate information about
62 // transative dependencies, all of which belongs exclusively in the lock
63 // file, not the glide.yaml file.
64 // TODO(mattfarina): Detect when a new dependency has been added or removed
65 // from the project. A removed dependency should warn and an added dependency
66 // should be added to the glide.yaml file. See issue #193.
67
68 if !skipRecursive {
69 // Write lock
70 hash, err := conf.Hash()
71 if err != nil {
72 msg.Die("Failed to generate config hash. Unable to generate lock file.")

Callers 1

InstallFunction · 0.85

Calls 14

FingerprintMethod · 0.95
WriteFileMethod · 0.95
EnsureGopathFunction · 0.85
EnsureVendorDirFunction · 0.85
EnsureConfigFunction · 0.85
CheckoutMethod · 0.80
DieMethod · 0.80
UpdateMethod · 0.80
InfoMethod · 0.80
ErrMethod · 0.80
ExportMethod · 0.80
HashMethod · 0.80

Tested by

no test coverage detected