Equals compares two Packages. This may be an expensive operation since it may have to normalize a Package's attribute path, which may require a network call.
(other *Package)
| 475 | // may have to normalize a Package's attribute path, which may require a network |
| 476 | // call. |
| 477 | func (p *Package) Equals(other *Package) bool { |
| 478 | if p.Raw == other.Raw || p.installable == other.installable { |
| 479 | return true |
| 480 | } |
| 481 | |
| 482 | // check inputs without fragments as optimization. Next step is expensive |
| 483 | if p.URLForFlakeInput() != other.URLForFlakeInput() { |
| 484 | return false |
| 485 | } |
| 486 | |
| 487 | name, err := p.NormalizedPackageAttributePath() |
| 488 | if err != nil { |
| 489 | return false |
| 490 | } |
| 491 | otherName, err := other.NormalizedPackageAttributePath() |
| 492 | if err != nil { |
| 493 | return false |
| 494 | } |
| 495 | return name == otherName |
| 496 | } |
| 497 | |
| 498 | // CanonicalName returns the name of the package without the version |
| 499 | // it only applies to devbox packages |
no test coverage detected