Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/GitHash.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import System.Exit
import System.FilePath
import System.IO.Error (isDoesNotExistError)
import System.Process
import System.IO (hPutStrLn, stderr)
import Text.Read (readMaybe)

-- | Various pieces of information about a Git repository.
Expand Down Expand Up @@ -221,8 +222,14 @@ getGitFilesForWorktree git = do
-- | Get a list of dependent git related files.
getGitFiles :: FilePath -> IO [FilePath]
getGitFiles git = do
exists <- doesPathExist git
isDir <- doesDirectoryExist git
if isDir then getGitFilesRegular git else getGitFilesForWorktree git
case (exists, isDir) of
(True, True) -> getGitFilesRegular git
(True, False) -> getGitFilesForWorktree git
(False, _) -> do
hPutStrLn stderr $ "Path " <> git <> " does not exists!"
pure []

-- | Get the 'GitInfo' for the given root directory. Root directory
-- should be the directory containing the @.git@ directory.
Expand Down