lastConfigMatches returns true if the provided source file and/or adapter matches the recorded last-config. Matching rules (in priority order): 1. If srcAdapter is provided and differs from the recorded adapter, no match. 2. If srcFile exactly equals the recorded file, match. 3. If both sides can be
(srcFile, srcAdapter string)
| 1292 | // 3. If both sides can be made absolute and equal, match. |
| 1293 | // 4. If basenames are equal, match. |
| 1294 | func lastConfigMatches(srcFile, srcAdapter string) bool { |
| 1295 | lf, la, _ := getLastConfig() |
| 1296 | |
| 1297 | // If adapter is provided, it must match. |
| 1298 | if srcAdapter != "" && srcAdapter != la { |
| 1299 | return false |
| 1300 | } |
| 1301 | |
| 1302 | // Quick equality check. |
| 1303 | if srcFile == lf { |
| 1304 | return true |
| 1305 | } |
| 1306 | |
| 1307 | // Try absolute path comparison. |
| 1308 | sAbs, sErr := filepath.Abs(srcFile) |
| 1309 | lAbs, lErr := filepath.Abs(lf) |
| 1310 | if sErr == nil && lErr == nil && sAbs == lAbs { |
| 1311 | return true |
| 1312 | } |
| 1313 | |
| 1314 | // Final fallback: basename equality. |
| 1315 | if filepath.Base(srcFile) == filepath.Base(lf) { |
| 1316 | return true |
| 1317 | } |
| 1318 | |
| 1319 | return false |
| 1320 | } |
| 1321 | |
| 1322 | // errSameConfig is returned if the new config is the same |
| 1323 | // as the old one. This isn't usually an actual, actionable |
no test coverage detected