Commit 56367b5
committed
fix(syncmodutil): parse single-line replaces and tokenize strip logic
Two follow-ups to #983 review feedback:
- getReplacedVersionsFromString now also picks up single-line
`replace foo [v] => bar [v]` directives in the source go.mod, not just
block form. Without this, a source that uses single-line replaces loses
them in the emitted output, violating the documented guarantee that
source-declared replaces are mirrored verbatim. Block boundaries are
tracked so lines inside `replace (...)` are only processed once (by the
existing block parser).
- stripConflictingReplaces tokenizes with strings.Fields instead of a
fixed "replace " prefix. go.mod permits arbitrary whitespace after the
keyword (e.g. `replace<tab>foo => bar`), and such lines were previously
not stripped, which would cause `go mod tidy` to fail with "multiple
replacements for <module>" once the new pin block was appended.
Signed-off-by: Yi Nuo <218099172+yi-nuo426@users.noreply.github.com>1 parent 24f97a9 commit 56367b5
1 file changed
Lines changed: 41 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
173 | | - | |
174 | | - | |
175 | 173 | | |
176 | | - | |
177 | | - | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
178 | 184 | | |
179 | 185 | | |
180 | 186 | | |
| |||
252 | 258 | | |
253 | 259 | | |
254 | 260 | | |
| 261 | + | |
255 | 262 | | |
256 | 263 | | |
257 | 264 | | |
| |||
268 | 275 | | |
269 | 276 | | |
270 | 277 | | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
271 | 308 | | |
272 | 309 | | |
273 | 310 | | |
| |||
0 commit comments