@@ -118,41 +118,42 @@ func (cmd *ensureCommand) Run(ctx *dep.Ctx, args []string) error {
118
118
sm .UseDefaultSignalHandling ()
119
119
defer sm .Release ()
120
120
121
+ params := p .MakeParams ()
122
+ if cmd .update && len (args ) == 0 {
123
+ // If -update was specified without args, we want the solver to allow all versions to change
124
+ params .ChangeAll = cmd .update
125
+ }
126
+
121
127
var errs []error
122
128
for _ , arg := range args {
123
- // default persist to manifest
124
129
pc , err := getProjectConstraint (arg , sm )
125
130
if err != nil {
126
131
errs = append (errs , err )
127
132
continue
128
133
}
129
134
130
- if gps .IsAny (pc .Constraint ) && pc .Ident .Source == "" {
131
- // If the input specified neither a network name nor a constraint,
132
- // then the strict thing to do would be to remove the entry
133
- // entirely. But that would probably be quite surprising for users,
134
- // and it's what rm is for, so just ignore the input.
135
- //
136
- // TODO(sdboyer): for this case - or just in general - do we want to
137
- // add project args to the requires list temporarily for this run?
138
- if _ , has := p .Manifest .Dependencies [pc .Ident .ProjectRoot ]; ! has {
139
- logf ("No constraint or alternate source specified for %q, omitting from manifest" , pc .Ident .ProjectRoot )
135
+ // Ignore the lockfile for this dependency and allow its version to change
136
+ params .ToChange = append (params .ToChange , pc .Ident .ProjectRoot )
137
+
138
+ if ! cmd .update {
139
+ if gps .IsAny (pc .Constraint ) && pc .Ident .Source == "" {
140
+ // If the input specified neither a network name nor a constraint,
141
+ // then the strict thing to do would be to remove the entry
142
+ // entirely. But that would probably be quite surprising for users,
143
+ // and it's what rm is for, so just ignore the input.
144
+ //
145
+ // TODO(sdboyer): for this case - or just in general - do we want to
146
+ // add project args to the requires list temporarily for this run?
147
+ if _ , has := p .Manifest .Dependencies [pc .Ident .ProjectRoot ]; ! has {
148
+ logf ("No constraint or alternate source specified for %q, omitting from manifest" , pc .Ident .ProjectRoot )
149
+ }
150
+ // If it's already in the manifest, no need to log
151
+ continue
140
152
}
141
- // If it's already in the manifest, no need to log
142
- continue
143
- }
144
-
145
- p .Manifest .Dependencies [pc .Ident .ProjectRoot ] = gps.ProjectProperties {
146
- Source : pc .Ident .Source ,
147
- Constraint : pc .Constraint ,
148
- }
149
153
150
- if p .Lock != nil {
151
- for i , lp := range p .Lock .P {
152
- if lp .Ident () == pc .Ident {
153
- p .Lock .P = append (p .Lock .P [:i ], p .Lock .P [i + 1 :]... )
154
- break
155
- }
154
+ p .Manifest .Dependencies [pc .Ident .ProjectRoot ] = gps.ProjectProperties {
155
+ Source : pc .Ident .Source ,
156
+ Constraint : pc .Constraint ,
156
157
}
157
158
}
158
159
}
@@ -173,14 +174,8 @@ func (cmd *ensureCommand) Run(ctx *dep.Ctx, args []string) error {
173
174
Constraint : pc .Constraint ,
174
175
}
175
176
176
- if p .Lock != nil {
177
- for i , lp := range p .Lock .P {
178
- if lp .Ident () == pc .Ident {
179
- p .Lock .P = append (p .Lock .P [:i ], p .Lock .P [i + 1 :]... )
180
- break
181
- }
182
- }
183
- }
177
+ // Ignore the lockfile for this dependency and allow its version to change
178
+ params .ToChange = append (params .ToChange , pc .Ident .ProjectRoot )
184
179
}
185
180
186
181
if len (errs ) > 0 {
@@ -192,10 +187,6 @@ func (cmd *ensureCommand) Run(ctx *dep.Ctx, args []string) error {
192
187
return errors .New (buf .String ())
193
188
}
194
189
195
- params := p .MakeParams ()
196
- // If -update was passed, we want the solver to allow all versions to change
197
- params .ChangeAll = cmd .update
198
-
199
190
if * verbose {
200
191
params .Trace = true
201
192
params .TraceLogger = log .New (os .Stderr , "" , 0 )
0 commit comments