vndr
vndr copied to clipboard
fix vendoring if vanity URL is broken
relates to https://github.com/moby/moby/pull/42798
The vendor.conf allows passing a custom URL to download the dependency, however, the import-path may still be used to detect the repository "root" (for versioned imports).
In situations where a vanity URL is used, and the vanity URL is broken, this can cause downloading the dependency to fail:
This patch checks if a custom VCS URL is provided, and in that case skips the detection of the repository root (as the VCS URL will provide this information, and won't contain a versioned import path.
Before this change:
vndr code.cloudfoundry.org/clock v1.0.0 https://github.com/cloudfoundry/clock.git
Collecting initial packages
Download dependencies
unrecognized import path "code.cloudfoundry.org/clock" (https fetch: Get "https://code.cloudfoundry.org/clock?go-get=1": x509: certificate signed by unknown authority)
After this change:
vndr code.cloudfoundry.org/clock v1.0.0 https://github.com/cloudfoundry/clock.git
Collecting initial packages
Download dependencies
Clone https://github.com/cloudfoundry/clock.git to code.cloudfoundry.org/clock, revision v1.0.0, attempt 1/20
Finished clone code.cloudfoundry.org/clock
Dependencies downloaded. Download time: 2.796983086s
Collecting all dependencies
Clean vendor dir from unused packages
...
moving to draft. this doesn't work as expected
[2021-08-30T13:57:04.290Z] 2021/08/30 13:57:04 WARNING: package github.com/hashicorp/go-immutable-radix is unused, consider removing it from vendor.conf
[2021-08-30T13:57:04.290Z] 2021/08/30 13:57:04 WARNING: package code.cloudfoundry.org/clock is unused, consider removing it from vendor.conf
[2021-08-30T13:57:04.290Z] 2021/08/30 13:57:04 Success
[2021-08-30T13:57:04.290Z] 2021/08/30 13:57:04 Running time: 6m1.020840444s
[2021-08-30T13:57:04.553Z] The result of vndr differs
[2021-08-30T13:57:04.553Z]
[2021-08-30T13:57:04.553Z] D vendor/code.cloudfoundry.org/clock/LICENSE
[2021-08-30T13:57:04.553Z] D vendor/code.cloudfoundry.org/clock/NOTICE
[2021-08-30T13:57:04.553Z] D vendor/code.cloudfoundry.org/clock/README.md
[2021-08-30T13:57:04.553Z] D vendor/code.cloudfoundry.org/clock/clock.go
[2021-08-30T13:57:04.553Z] D vendor/code.cloudfoundry.org/clock/package.go
[2021-08-30T13:57:04.553Z] D vendor/code.cloudfoundry.org/clock/ticker.go
[2021-08-30T13:57:04.553Z] D vendor/code.cloudfoundry.org/clock/timer.go
[2021-08-30T13:57:04.553Z] D vendor/github.com/hashicorp/go-immutable-radix/LICENSE
[2021-08-30T13:57:04.553Z] D vendor/github.com/hashicorp/go-immutable-radix/README.md
[2021-08-30T13:57:04.553Z] D vendor/github.com/hashicorp/go-immutable-radix/edges.go
[2021-08-30T13:57:04.553Z] D vendor/github.com/hashicorp/go-immutable-radix/iradix.go
[2021-08-30T13:57:04.553Z] D vendor/github.com/hashicorp/go-immutable-radix/iter.go
[2021-08-30T13:57:04.553Z] D vendor/github.com/hashicorp/go-immutable-radix/node.go
[2021-08-30T13:57:04.553Z] D vendor/github.com/hashicorp/go-immutable-radix/raw_iter.go
[2021-08-30T13:57:04.553Z]
[2021-08-30T13:57:04.553Z] Please vendor your package with hack/vendor.sh.
@LK4D4 PTAL. Looks like one of the vanity URLs is failing again (and I managed to get this PR working) 🤗
I completely missed that you sent me an invite for this repo (❤️) but when I found it, it had expired 😅 😓
Thanks!