Skip to content

Fetch the pinned commit for Composer branch downloads - #430

Open
pinguinfuss wants to merge 4 commits into
git-pkgs:mainfrom
pinguinfuss:fix-composer-dev-dist
Open

pinguinfuss wants to merge 4 commits into
git-pkgs:mainfrom
pinguinfuss:fix-composer-dev-dist

Conversation

@pinguinfuss

Copy link
Copy Markdown
Contributor

Found while working on Composer retention (#306).

For branch versions like dev-master, the download handler fetched whatever commit the metadata lists now and cached it under the file name the client asked for. A composer.lock pinning an older commit got the current head, cached under the old commit's name. GitHub zipballs have no shasum, so Composer doesn't notice.

Now the requested file has to match the metadata. For branches with commit-hash dist URLs (GitHub, Bitbucket), the proxy fetches the requested commit, as Composer would without the proxy. Tagged releases only get the listed commit. Anything else returns a 404 instead of the wrong archive. Bare hashes without .zip, from proxy versions before 0.2.1, still work.

Not fixed here:

  • archives already cached under the wrong commit are still served
  • GitLab caches every commit as archive.zip
  • branch names with a slash (dev-feature/x) don't match the download route

The download handler resolved a version's dist URL from the current metadata and cached the archive under whatever file name the client asked for. A lock file pinning an older commit of a branch like dev-master got the branch head, stored and served as that older commit.

Downloads now fetch the commit the file name stands for when the dist URL ends in a commit hash (GitHub zipballs, Bitbucket archives), and return 404 for other names the metadata no longer lists.
Proxy versions before the .zip suffix handed out GitHub zipball URLs ending in the bare commit hash. Lock files written back then still ask for those names, and the new file name check turned them into 404s.
A tagged release lists one commit and lock files ask for that one. Rebuilding the URL for any requested commit let a client store another commit, even one from a fork, as the release, and the browse view could then show it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant