@@ -82,7 +82,7 @@ func (a *rootAnalyzer) importManifestAndLock(dir string, pr gps.ProjectRoot, sup
82
82
if err != nil {
83
83
return nil , nil , err
84
84
}
85
- a .removeTransitiveDependencies (m )
85
+ a .RemoveTransitiveDependencies (m )
86
86
return m , l , err
87
87
}
88
88
}
@@ -91,7 +91,7 @@ func (a *rootAnalyzer) importManifestAndLock(dir string, pr gps.ProjectRoot, sup
91
91
return emptyManifest , nil , nil
92
92
}
93
93
94
- func (a * rootAnalyzer ) removeTransitiveDependencies (m * dep.Manifest ) {
94
+ func (a * rootAnalyzer ) RemoveTransitiveDependencies (m * dep.Manifest ) {
95
95
for pr := range m .Constraints {
96
96
if _ , isDirect := a .directDeps [string (pr )]; ! isDirect {
97
97
delete (m .Constraints , pr )
@@ -126,39 +126,38 @@ func (a *rootAnalyzer) DeriveManifestAndLock(dir string, pr gps.ProjectRoot) (gp
126
126
return gps.SimpleManifest {}, nil , nil
127
127
}
128
128
129
- func (a * rootAnalyzer ) FinalizeRootManifestAndLock (m * dep.Manifest , l * dep.Lock ) {
130
- // Remove dependencies from the manifest that aren't used
131
- for pr := range m .Constraints {
132
- var used bool
133
- for _ , y := range l .Projects () {
134
- if pr == y .Ident ().ProjectRoot {
135
- used = true
136
- break
137
- }
138
- }
139
- if ! used {
140
- delete (m .Constraints , pr )
141
- }
142
- }
143
- // Pick the direct dependencies from the solution lock and add to manifest.
144
- // This is done to fill up the manifest constraints with the dependencies
145
- // solved over the network.
129
+ func (a * rootAnalyzer ) FinalizeRootManifestAndLock (m * dep.Manifest , l * dep.Lock , ol dep.Lock ) {
130
+ // Iterate through the new projects in solved lock and add them to manifest
131
+ // if they are direct deps and log feedback for all the new projects.
146
132
for _ , y := range l .Projects () {
147
133
var f * fb.ConstraintFeedback
148
134
pr := y .Ident ().ProjectRoot
135
+ // New constraints: in new lock and dir dep but not in manifest
149
136
if _ , ok := a .directDeps [string (pr )]; ok {
150
- pp := getProjectPropertiesFromVersion (y .Version ())
151
- if pp .Constraint != nil {
152
- m .Constraints [pr ] = pp
153
- pc := gps.ProjectConstraint {Ident : y .Ident (), Constraint : pp .Constraint }
154
- f = fb .NewConstraintFeedback (pc , fb .DepTypeDirect )
155
- } else {
156
- f = fb .NewLockedProjectFeedback (y , fb .DepTypeDirect )
137
+ if _ , ok := m .Constraints [pr ]; ! ok {
138
+ pp := getProjectPropertiesFromVersion (y .Version ())
139
+ if pp .Constraint != nil {
140
+ m .Constraints [pr ] = pp
141
+ pc := gps.ProjectConstraint {Ident : y .Ident (), Constraint : pp .Constraint }
142
+ f = fb .NewConstraintFeedback (pc , fb .DepTypeDirect )
143
+ } else {
144
+ f = fb .NewLockedProjectFeedback (y , fb .DepTypeDirect )
145
+ }
146
+ f .LogFeedback (a .ctx .Err )
157
147
}
158
148
} else {
159
- f = fb .NewLockedProjectFeedback (y , fb .DepTypeTransitive )
149
+ // New locked projects: in new lock but not in old lock
150
+ newProject := true
151
+ for _ , opl := range ol .Projects () {
152
+ if pr == opl .Ident ().ProjectRoot {
153
+ newProject = false
154
+ }
155
+ }
156
+ if newProject {
157
+ f = fb .NewLockedProjectFeedback (y , fb .DepTypeTransitive )
158
+ f .LogFeedback (a .ctx .Err )
159
+ }
160
160
}
161
- f .LogFeedback (a .ctx .Err )
162
161
}
163
162
}
164
163
0 commit comments