aboutsummaryrefslogtreecommitdiff
path: root/Assistant/Ssh.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-10-31 15:17:00 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-10-31 15:26:19 -0400
commita43b7bf71a2369167045ce9ecbddd08276f0e990 (patch)
tree5fe8545a368d7f30837e28dddab083a35310dc29 /Assistant/Ssh.hs
parent8f4726ff9e194d8b5e27b03e45d49de5325b8d1a (diff)
webapp: Generate better git remote names.
Wrote a better git remote name sanitizer. Git blows up on lots of weird stuff, especially if it starts the remote name, but I managed to get some common punctuation working.
Diffstat (limited to 'Assistant/Ssh.hs')
-rw-r--r--Assistant/Ssh.hs10
1 files changed, 4 insertions, 6 deletions
diff --git a/Assistant/Ssh.hs b/Assistant/Ssh.hs
index 69e633ac8..0b957cce9 100644
--- a/Assistant/Ssh.hs
+++ b/Assistant/Ssh.hs
@@ -10,6 +10,7 @@ module Assistant.Ssh where
import Common.Annex
import Utility.TempFile
import Utility.UserInfo
+import Git.Remote
import Data.Text (Text)
import qualified Data.Text as T
@@ -51,14 +52,11 @@ sshDir = do
genSshHost :: Text -> Maybe Text -> String
genSshHost host user = maybe "" (\v -> T.unpack v ++ "@") user ++ T.unpack host
-{- host_dir, with all / in dir replaced by _, and bad characters removed -}
+{- Generates a git remote name, like host_dir or host -}
genSshRepoName :: String -> FilePath -> String
genSshRepoName host dir
- | null dir = filter legal host
- | otherwise = filter legal $ host ++ "_" ++ replace "/" "_" dir
- where
- legal '_' = True
- legal c = isAlphaNum c
+ | null dir = makeLegalName host
+ | otherwise = makeLegalName $ host ++ "_" ++ dir
{- The output of ssh, including both stdout and stderr. -}
sshTranscript :: [String] -> String -> IO (String, Bool)