git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #1782 from passy/psc-publish-https

Allow https://github.com URLs for psc-publish

commitbc5f300eed5fa3dfa786ff911262731ec22dd78b authorPhil Freeman <paf31@cantab.net> dateSat 2 Jan 2016, 13:17 (11 years ago) parentbef7b11a98f28a
2 files changed+11−7
CONTRIBUTORS.md+1 src/Language/PureScript/Publish.hs+10−7
CONTRIBUTORS.md+1
@@ -61,6 +61,7 @@ This file lists the contributors to the PureScript compiler project, and the ter
6161- [@soupi](https://github.com/soupi) (Gil Mizrahi) My existing contributions and all future contributions until further notice are Copyright Gil Mizrahi, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license](http://opensource.org/licenses/MIT).
6262- [@tfausak](https://github.com/tfausak) (Taylor Fausak) My existing contributions and all future contributions until further notice are Copyright Taylor Fausak, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license](http://opensource.org/licenses/MIT).
6363- [@codedmart](https://github.com/codedmart) (Brandon Martin) My existing contributions and all future contributions until further notice are Copyright Brandon Martin, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license](http://opensource.org/licenses/MIT).
64+- [@passy](https://github.com/passy) (Pascal Hartig) My existing contributions and all future contributions until further notice are Copyright Pascal Hartig, and are licensed to the owners and users of the PureScript compiler project under the terms of the [MIT license](http://opensource.org/licenses/MIT).
6465
6566### Companies
6667
src/Language/PureScript/Publish.hs+10−7
@@ -41,7 +41,6 @@ import qualified Data.Text.Lazy.Encoding as TL
4141
4242import Control.Category ((>>>))
4343import Control.Arrow ((***))
44−import Control.Applicative ((<|>))
4544import Control.Exception (catch, try)
4645import Control.Monad.Trans.Maybe (MaybeT(..), runMaybeT)
4746import Control.Monad.Trans.Except
@@ -197,8 +196,7 @@ getBowerInfo = either (userError . BadRepositoryField) return . tryExtract
197196 maybe (Left NotOnGithub) Right (extractGithub repositoryUrl)
198197
199198extractGithub :: String -> Maybe (D.GithubUser, D.GithubRepo)
200−extractGithub =
201− matchUrl
199+extractGithub = stripGitHubPrefixes
202200 >>> fmap (splitOn "/")
203201 >=> takeTwo
204202 >>> fmap (D.GithubUser *** (D.GithubRepo . dropDotGit))
@@ -208,15 +206,20 @@ extractGithub =
208206 takeTwo [x, y] = Just (x, y)
209207 takeTwo _ = Nothing
210208
209+ stripGitHubPrefixes :: String -> Maybe String
210+ stripGitHubPrefixes = stripPrefixes [ "git://github.com/"
211+ , "https://github.com/"
212+ , "git@github.com:"
213+ ]
214+
215+ stripPrefixes :: [String] -> String -> Maybe String
216+ stripPrefixes prefixes str = msum $ (`stripPrefix` str) <$> prefixes
217+
211218 dropDotGit :: String -> String
212219 dropDotGit str
213220 | ".git" `isSuffixOf` str = take (length str - 4) str
214221 | otherwise = str
215222
216− matchUrl :: String -> Maybe String
217− matchUrl str =
218− stripPrefix "git@github.com:" str <|> stripPrefix "git://github.com/" str
219−
220223readProcess' :: String -> [String] -> String -> PrepareM String
221224readProcess' prog args stdin = do
222225 out <- liftIO (catch (Right <$> readProcess prog args stdin)