Skip to content

Commit

Permalink
Fix git path splitting
Browse files Browse the repository at this point in the history
  • Loading branch information
diskshima committed Sep 8, 2024
1 parent 61958f4 commit 70fb7d5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/GitUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ remoteSection = printf "remote \"%s\""
dropDotGit :: String -> String
dropDotGit = reverse . drop 4 . reverse

segmentsToRepoInfo :: [String] -> RepoInfo
segmentsToRepoInfo segments = RepoInfo org repo
where org = segments !! 1
repo = dropDotGit $ segments !! 2
segmentsToRepoInfo :: [String] -> Maybe RepoInfo
segmentsToRepoInfo segments =
if length segments >= 2
then Just $ RepoInfo (segments !! 0) (dropDotGit $ segments !! 1)
else Nothing

toFullSshUrl :: String -> String
toFullSshUrl str =
Expand All @@ -60,7 +61,7 @@ toFullSshUrl str =
urlToRepoInfo :: String -> Maybe RepoInfo
urlToRepoInfo url = do
uri <- parseURI $ toFullSshUrl url
return $ (segmentsToRepoInfo . pathSegments) uri
segmentsToRepoInfo $ pathSegments uri

listRemoteBranches :: IO [Branch]
listRemoteBranches = do
Expand Down

0 comments on commit 70fb7d5

Please sign in to comment.