From 247e55ba18f304921a64f736628f90ee5ef2d89c Mon Sep 17 00:00:00 2001 From: Filip Gralinski Date: Sat, 7 Dec 2019 21:26:50 +0100 Subject: [PATCH] Add a helper function --- Handler/Shared.hs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Handler/Shared.hs b/Handler/Shared.hs index d68c11a..03a9268 100644 --- a/Handler/Shared.hs +++ b/Handler/Shared.hs @@ -251,6 +251,14 @@ cloneRepo' userId repoCloningSpec chan = do err chan "git failed" return Nothing +-- An auxilliary function for fixing git URLs. +-- By default, this does nothing, but can be changed +-- in Gonito forks. +-- Should be used just before a raw git command is executed +-- (i.e. its changes will not be reflected in the database). +fixGitRepoUrl :: Text -> Text +fixGitRepoUrl = id + rawClone :: FilePath -> RepoCloningSpec -> Channel -> Handler ExitCode rawClone tmpRepoDir repoCloningSpec chan = runWithChannel chan $ do let url = repoSpecUrl $ cloningSpecRepo repoCloningSpec @@ -262,7 +270,7 @@ rawClone tmpRepoDir repoCloningSpec chan = runWithChannel chan $ do "--single-branch", "--branch", T.unpack referenceBranch, - T.unpack referenceUrl, + T.unpack (fixGitRepoUrl referenceUrl), tmpRepoDir] if url /= referenceUrl || branch /= referenceBranch then @@ -270,7 +278,7 @@ rawClone tmpRepoDir repoCloningSpec chan = runWithChannel chan $ do runProg (Just tmpRepoDir) gitPath ["remote", "set-url", "origin", - T.unpack url] + T.unpack (fixGitRepoUrl url)] runProg (Just tmpRepoDir) gitPath ["fetch", "origin", T.unpack branch]