Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use submodule commit whose commitid resolves to HEAD on a Github Pull Request on Flatpak 0.10 & Git <2.14 #1133

Closed
directhex opened this issue Oct 26, 2017 · 2 comments

Comments

@directhex
Copy link

directhex commented Oct 26, 2017

I'm not positive about which commit in git resolves the issue (that's a huge pain in the ass to bisect), but there's a combination of factors which leads to pain. For an easy example, try building https://github.com/directhex/pony-flatpak. The "good" behaviour is the build fails. The "bad" behaviour is the checkout fails.

On Flatpak 0.10, one new feature is to speed up builds, shallow clones are used. Part of this is submodule commitids are resolved to branches. For whatever reason, if a submodule points to a commit which is available as the tip of a pull request branch, then the fetch resolves to the pull request branch instead of the master branch (or any other branch containing that commit):

directhex@bubblegum:~/Projects/pony-flatpak$ flatpak-builder --force-clean pony com.pretty.ponies.json 
Emptying app dir 'pony'
Downloading sources
Fetching git repo git://github.com/directhex/pony-repo.git, ref refs/heads/master
remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
Fetching git repo git@github.com:directhex/wrench-aggregator.git, ref refs/pull/3/head
remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0

On git 2.14.1, this works fine:

Cloning into '/home/directhex/Projects/pony-flatpak/.flatpak-builder/build/pony-repo-4/arbitrary-submodule-with-PR-merge-as-latest'...
Submodule path 'arbitrary-submodule-with-PR-merge-as-latest': checked out '9633efeffd1d1453951af0464fdf1a7e2e5628a2'

On git 2.7.4, it fails the build:

fatal: reference is not a tree: 9633efeffd1d1453951af0464fdf1a7e2e5628a2
Unable to checkout '9633efeffd1d1453951af0464fdf1a7e2e5628a2' in submodule path 'arbitrary-submodule-with-PR-merge-as-latest'

Since PR refs are special-cased in the Github back-end, maybe Flatpak should be taught to avoid them? Or include a git version check on shallow cloning?

@directhex
Copy link
Author

alexlarsson added a commit to flatpak/flatpak-builder that referenced this issue Oct 27, 2017
It turns out older versions of git cannot properly check out a commit
if the ref that points to it was not a normal one (branch or tag).
So, we work around this case by detecting it add adding a fake
tag. Also, we change the fake ref we use for commit-only references
to be a regular branch and not a special one for the same reason.

This fixes flatpak/flatpak#1133
@alexlarsson
Copy link
Member

For the record, we pull the tip of a pull request branch because there is no other way to pull a specific commit. If you pull a commit id directly you get a denied error from the server. If we can't find it at the tip of some ref, then we fall back to a deep clone.

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 a pull request may close this issue.

2 participants