-
Notifications
You must be signed in to change notification settings - Fork 841
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
Support main
as the default branch for templates
#5422
Comments
@majjoha I don't see |
@qrilka: Oh. It was public when I ran into the issue but I removed the repository afterwards. I've put it on GitHub again so you can reproduce the issue. Sorry for the inconvenience! |
Good then. I think PR fixing this will be appreciated. |
Having only read Learn You a Haskell for Great Good! and currently working my way through Haskell Programming from First Principles, I believe I am still too much of a novice to implement this (at least, without a bit of guidance). Also, what would be the ideal behavior from your perspective? Off the top of my head, I see three possible implementations:
What are your thoughts? |
I think 2 makes sense probably with 3 as an enhancement. |
Thank you so much for your willingness to help. I greatly appreciate it. I've decided to give it a try, although I might admit that I am struggling quite a bit. What I am currently trying to achieve is to keep the existing behavior of how templates are downloaded but add support for a branch field in In https://github.com/majjoha/stack/commit/8d3180a83ac6381e7345eefb017bd44f1dc6360f, you can see the progress I've made so far. Does it seem like I am on the right track, and if so, where would you suggest that I go next? At the moment, one of the tests in the test suite is failing with the following error:
Do you have any pointers on how I can fix the failing test, and also, how do I run the version of Stack that I am currently working on? Thank you once again! |
Your appreach could help with the point 3 but it doesn't seem to address 2. |
Actually, GitHub does provide an API to get the information of the repository, including the direct download link (with the default branch). For example, {
"name": "simple.hsfiles",
"path": "simple.hsfiles",
"sha": "ee253ece365710a3f334ebd4d63eb82dd2fd948c",
"size": 3098,
"url": "https://api.github.com/repos/majjoha/stack-templates/contents/simple.hsfiles?ref=main",
"html_url": "https://github.com/majjoha/stack-templates/blob/main/simple.hsfiles",
"git_url": "https://api.github.com/repos/majjoha/stack-templates/git/blobs/ee253ece365710a3f334ebd4d63eb82dd2fd948c",
"download_url": "https://raw.githubusercontent.com/majjoha/stack-templates/main/simple.hsfiles",
"type": "file",
"content": "ey0jIFNUQVJUX0ZJTEUgLmdpdGh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1QsIE9SIENPTlNFUVVFTlRJQUwg\nREFNQUdFUyBPUiBBTlkgREFNQUdFUyBXSEFUU09FVkVSIFJFU1VMVElORyBG\nUk9NCkxPU1MgT0YgVVNFLCBEQVRBIE9SIFBST0ZJVFMsIFdIRVRIRVIgSU4g\nQU4gQUNUSU9OIE9GIENPTlRSQUNULCBORUdMSUdFTkNFIE9SCk9USEVSIFRP\nUlRJT1VTIEFDVElPTiwgQVJJU0lORyBPVVQgT0YgT1IgSU4gQ09OTkVDVElP\nTiBXSVRIIFRIRSBVU0UgT1IKUEVSRk9STUFOQ0UgT0YgVEhJUyBTT0ZUV0FS\nRS4KCnstIyBTVEFSVF9GSUxFIFNldHVwLmhzICMtfQppbXBvcnQgRGlzdHJp\nYnV0aW9uLlNpbXBsZQptYWluID0gZGVmYXVsdE1haW4KCnstIyBTVEFSVF9G\nSUxFIHNyYy9NYWluLmhzICMtfQptb2R1bGUgTWFpbiB3aGVyZQoKbWFpbiA6\nOiBJTyAoKQptYWluID0gZG8KICBwdXRTdHJMbiAiaGVsbG8gd29ybGQiCgp7\nLSMgU1RBUlRfRklMRSBzcmMvU2ltcGxlLmhzICMtfQptb2R1bGUgU2ltcGxl\nIHdoZXJlCgp7LSMgU1RBUlRfRklMRSB0ZXN0L1NpbXBsZVNwZWMuaHMgIy19\nCm1vZHVsZSBTaW1wbGVTcGVjIChzcGVjKSB3aGVyZQoKaW1wb3J0IFNpbXBs\nZQppbXBvcnQgVGVzdC5Ic3BlYwoKc3BlYyA6OiBTcGVjCnNwZWMgPSB1bmRl\nZmluZWQKCnstIyBTVEFSVF9GSUxFIHRlc3QvU3BlYy5ocyAjLX0Key0jIE9Q\nVElPTlNfR0hDIC1GIC1wZ21GIGhzcGVjLWRpc2NvdmVyICMtfQo=\n",
"encoding": "base64",
"_links": {
"self": "https://api.github.com/repos/majjoha/stack-templates/contents/simple.hsfiles?ref=main",
"git": "https://api.github.com/repos/majjoha/stack-templates/git/blobs/ee253ece365710a3f334ebd4d63eb82dd2fd948c",
"html": "https://github.com/majjoha/stack-templates/blob/main/simple.hsfiles"
}
} and the |
This looks to be an interesting way to resolve the situation. BTW |
Thank you for your helpful feedback, @qrilka. I like the simplicity of your suggestion a lot, @jeffhappily, and it seems that running Since I am still fairly inexperienced, I think this might be too big a mouthful for me, though, but I'd love to either join somebody for a pairing session to see how they'd go about implementing it or look at a diff at some point. |
@majjoha I don't think it is very complicated - at the moment it looks to me that the main step would be to change
to
and then add an extra step which for Github will extract the field "content" and decode it and for Gitlab/Bitbucket will leave the contents as is. |
@qrilka: My apologies for the late reply. Work has taken up a lot of my time lately, so I have not been able to spend too much time on GitHub. Thank you for looking into a solution to the issue. It is incredibly helpful and a good learning experience to have the code available to learn from. |
Sure @majjoha - no problem. |
I've been looking into setting up a template for my Stack projects that I want to share on GitHub, and I am currently running version 2.5.1.
When referencing a template with either a URL or a file on my computer, I am able to scaffold projects successfully with the following two commands:
However, if I try to scaffold a project by referencing a template from my GitHub repository, I get the following error:
Expand/collapse log output
From what I can gather, the issue is that
stack new <project-name> <github-username>/<template-name>
assumes that the template exists on themaster
branch (see src/Stack/New.hs#L176:L182).Is it possible to reference
main
as the default branch at the moment, and if it isn't, would you consider supporting it?Thank you for your great work!
The text was updated successfully, but these errors were encountered: