git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #1782 from passy/psc-publish-https
bc5f300Phil Freeman
CONTRIBUTORS.md+1
@@ -61,6 +61,7 @@ This file lists the contributors to the PureScript compiler project, and the ter
61- [@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).
61- [@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).
62- [@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).
62- [@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).
63- [@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).
63- [@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).
64
65
65### Companies
66### Companies
66
67
src/Language/PureScript/Publish.hs+10−7
@@ -41,7 +41,6 @@ import qualified Data.Text.Lazy.Encoding as TL
41
41
42import Control.Category ((>>>))
42import Control.Category ((>>>))
43import Control.Arrow ((***))
43import Control.Arrow ((***))
44−import Control.Applicative ((<|>))
45import Control.Exception (catch, try)
44import Control.Exception (catch, try)
46import Control.Monad.Trans.Maybe (MaybeT(..), runMaybeT)
45import Control.Monad.Trans.Maybe (MaybeT(..), runMaybeT)
47import Control.Monad.Trans.Except
46import Control.Monad.Trans.Except
@@ -197,8 +196,7 @@ getBowerInfo = either (userError . BadRepositoryField) return . tryExtract
197 maybe (Left NotOnGithub) Right (extractGithub repositoryUrl)
196 maybe (Left NotOnGithub) Right (extractGithub repositoryUrl)
198
197
199extractGithub :: String -> Maybe (D.GithubUser, D.GithubRepo)
198extractGithub :: String -> Maybe (D.GithubUser, D.GithubRepo)
200−extractGithub =
199+extractGithub = stripGitHubPrefixes
201− matchUrl
202 >>> fmap (splitOn "/")
200 >>> fmap (splitOn "/")
203 >=> takeTwo
201 >=> takeTwo
204 >>> fmap (D.GithubUser *** (D.GithubRepo . dropDotGit))
202 >>> fmap (D.GithubUser *** (D.GithubRepo . dropDotGit))
@@ -208,15 +206,20 @@ extractGithub =
208 takeTwo [x, y] = Just (x, y)
206 takeTwo [x, y] = Just (x, y)
209 takeTwo _ = Nothing
207 takeTwo _ = Nothing
210
208
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+
211 dropDotGit :: String -> String
218 dropDotGit :: String -> String
212 dropDotGit str
219 dropDotGit str
213 | ".git" `isSuffixOf` str = take (length str - 4) str
220 | ".git" `isSuffixOf` str = take (length str - 4) str
214 | otherwise = str
221 | otherwise = str
215
222
216− matchUrl :: String -> Maybe String
217− matchUrl str =
218− stripPrefix "git@github.com:" str <|> stripPrefix "git://github.com/" str
219−
220readProcess' :: String -> [String] -> String -> PrepareM String
223readProcess' :: String -> [String] -> String -> PrepareM String
221readProcess' prog args stdin = do
224readProcess' prog args stdin = do
222 out <- liftIO (catch (Right <$> readProcess prog args stdin)
225 out <- liftIO (catch (Right <$> readProcess prog args stdin)