{"action":"opened","issue":{"url":"https://api.github.com/repos/commercialhaskell/stack/issues/1595","labels_url":"https://api.github.com/repos/commercialhaskell/stack/issues/1595/labels{/name}","comments_url":"https://api.github.com/repos/commercialhaskell/stack/issues/1595/comments","events_url":"https://api.github.com/repos/commercialhaskell/stack/issues/1595/events","html_url":"https://github.com/commercialhaskell/stack/issues/1595","id":124626872,"number":1595,"title":"Clone stack templates repo instead of using github API","user":{"login":"mgsloan","id":22570,"avatar_url":"https://avatars.githubusercontent.com/u/22570?v=3","gravatar_id":"","url":"https://api.github.com/users/mgsloan","html_url":"https://github.com/mgsloan","followers_url":"https://api.github.com/users/mgsloan/followers","following_url":"https://api.github.com/users/mgsloan/following{/other_user}","gists_url":"https://api.github.com/users/mgsloan/gists{/gist_id}","starred_url":"https://api.github.com/users/mgsloan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgsloan/subscriptions","organizations_url":"https://api.github.com/users/mgsloan/orgs","repos_url":"https://api.github.com/users/mgsloan/repos","events_url":"https://api.github.com/users/mgsloan/events{/privacy}","received_events_url":"https://api.github.com/users/mgsloan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-01-03T03:41:59Z","updated_at":"2016-01-03T03:41:59Z","closed_at":null,"body":"In order to resolve #1251, and support #1571, we need to clone the templates repository.  Here's how this would work:\r\n\r\n1) If it doesn't exist yet, clone the templates repo to some location in `~/.stack/`.\r\n\r\n2) If the repo is dirty, complain to the user about it and skip step (3).  This allows you to easily modify existing templates / add new ones.\r\n\r\n3) Fetch and reset to the latest master.  If the user passes `--offline`, then errors while running these git commands will be ignored.  When `--offline` isn't passed and an error occurs, the exception will mention that you can use `--offline`.  See also this issue about `-offline`: #1594\r\n\r\n4) Load the template from the file in the cloned repo.\r\n\r\nAnother detail here is windows newline normalization, as recently mentioned by Lokathor in the #haskell-stack IRC channel.  Since we're using the github API, we currently get `\\n` rather than `\\r\\n`.  This is something that [git can deal with](https://help.github.com/articles/dealing-with-line-endings/#platform-all), at least if we prefer using `\\r\\n` on windows."}}