-
Notifications
You must be signed in to change notification settings - Fork 22
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
"Could not parse object" when referencing the commit of a github pull request #73
Comments
Oh, turns out using |
@ChickenProp, I understand (from https://docs.haskellstack.org/en/stable/pantry/#package-location) that the difference is:
I also understand that 'forking' and 'pull requests' are a feature of GitHub and not a feature of Git itself. So, it seems to me that the |
So I'm no expert, but I don't think my proposed
Where github comes into it, is that apparently the commits downloaded in a clone don't include commits found in unmerged PRs made from forks. But those commits are still part of the repo, which is why It's possible that github is doing something weird when it doesn't send every commit in the original I'm not going to do this right now, but I think I could test that, and also test a gitlab instance and see if it has the same behavior with PRs. (I don't think I have access to a gitlab instance where I could test the force pushing thing.) |
OK, I understand from this that, in the case, of GitHub:
I don't know what it means for a commit in a pull request to be 'available' in a remote repository, but not available to be included in a clone with |
So, to recap, with a GitHub repository and: - git: <repo>
commit: <commit> Stack, effectively, does:
and that does not work if <commit> relates to an unmerged pull request from a different repository <fork>. The alternatives appear to be:
If I were to make the call, I would say that Alternative 1 (plus clear online documentation) is the better one. However, others may have different view. |
That sounds about right. Some clarifications:
To confirm, I just tested with gitlab and it behaves the same in this case. And on github (and I assume gitlab but didn't test this one) the reset-without-fetch also doesn't work if a commit is on a deleted branch, but fetch-then-reset does work in that case. I don't know if it will continue to work indefinitely; I think GH won't garbage collect it if that commit can still be found in the GH user interface (e.g. if it was a PR that got rejected and the branch deleted), but might eventually do so if not (e.g. someone just pushed a branch and then deleted it, but then how did you find it?). If it will get GCed, then it might actually be better for pantry to fail before then, so users can still look up the commit manually (by copying its shasum into the URL bar) if necessary. But this feels like something that won't come up very often.
Two more options:
Yeah. It's awkward for me for two reasons. One is that I have to edit both the I don't think documentation would help much with this, because for the most part I just don't look at these docs. Neither of these is a big deal. It would be a small QOL improvement for me, but if you think it's not worth it, I'm not going to argue. |
@ChickenProp, the conditional fetch seemed like a good idea. I've raised a pull request to implement it. |
@mpilgrem Awesome, thank you! |
Fix #73 Fetch commit and re-try, if reset --hard fails
I had this error from
stack build
, but I gather the problem is in pantry.If I reference a repository on github, and set the commit hash to reference a commit found in a pull request made from a fork, I get the error
fatal: Could not parse object '<hash>'.
If I reference the repository that the PR was made from, it works fine.For example (though this example won't work if the PR in question gets merged), if I have an extra-deps entry
referencing haskell-streaming/streaming-postgresql-simple#3, I get the error:
If I change the repository to
https://github.com/ivan-m/streaming-postgresql-simple
, I don't.I can reproduce the error with
git
itself. After a clone, if I manually run the raw command:An easy solution here is to fetch the commit explicitly:
So I expect that adding this extra fetch to
Pantry.Repo.withRepo
would fix the issue. It does have a downside that the extra fetch takes a bit of extra time, even if the commit is already available. There's probably more complicated things that work to avoid that.The text was updated successfully, but these errors were encountered: