@@ -134,9 +134,10 @@ func unify(originals []string, inputs []resolved) (map[string][]string, map[stri
134134 // special characters that delimit the package name from the cosntraint
135135 // so lop off the package name and stick the rest of the constraint into
136136 // the versions map.
137- if idx := strings .IndexAny (orig , "=<>~" ); idx >= 0 {
137+ if idx := strings .IndexAny (orig , "@ =<>~" ); idx >= 0 {
138138 name = orig [:idx ]
139139 }
140+
140141 originalPackages .packages .Insert (name )
141142 originalPackages .versions [name ] = strings .TrimPrefix (orig , name )
142143 }
@@ -235,7 +236,12 @@ func unify(originals []string, inputs []resolved) (map[string][]string, map[stri
235236 // Append all of the resolved and unified packages with an exact match
236237 // based on the resolved version we found.
237238 for _ , pkg := range sets .List (acc .packages ) {
238- pl = append (pl , fmt .Sprintf ("%s=%s" , pkg , acc .versions [pkg ]))
239+ pkgName := fmt .Sprintf ("%s=%s" , pkg , acc .versions [pkg ])
240+ // Add back the version if that is stripped before
241+ if originalPackages .versions [pkg ] != "" {
242+ pkgName = pkgName + originalPackages .versions [pkg ]
243+ }
244+ pl = append (pl , pkgName )
239245 }
240246 // Sort the package list explicitly with the `=` included.
241247 // This is because (foo, foo-bar) sorts differently than (foo=1, foo-bar=1)
@@ -249,7 +255,12 @@ func unify(originals []string, inputs []resolved) (map[string][]string, map[stri
249255 for _ , input := range inputs {
250256 pl := make ([]string , 0 , len (input .packages ))
251257 for _ , pkg := range sets .List (input .packages ) {
252- pl = append (pl , fmt .Sprintf ("%s=%s" , pkg , input .versions [pkg ]))
258+ pkgName := fmt .Sprintf ("%s=%s" , pkg , input .versions [pkg ])
259+ // Add back the version if that is stripped before
260+ if originalPackages .versions [pkg ] != "" {
261+ pkgName = pkgName + originalPackages .versions [pkg ]
262+ }
263+ pl = append (pl , pkgName )
253264 }
254265 // Sort the package list explicitly with the `=` included.
255266 // This is because (foo, foo-bar) sorts differently than (foo=1, foo-bar=1)
0 commit comments