githud 3.2.1 → 3.2.2
raw patch · 5 files changed
+54/−33 lines, 5 filesdep +filelockPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: filelock
API changes (from Hackage documentation)
+ GitHUD.Config.Types: [confGithuddLockFilePath] :: Config -> FilePath
- GitHUD.Config.Types: Config :: Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> String -> String -> Color -> ColorIntensity -> String -> Color -> ColorIntensity -> String -> String -> String -> String -> [String] -> String -> String -> String -> Color -> ColorIntensity -> Color -> ColorIntensity -> String -> Color -> ColorIntensity -> String -> Color -> ColorIntensity -> String -> Color -> ColorIntensity -> String -> Color -> ColorIntensity -> String -> Color -> ColorIntensity -> String -> Color -> ColorIntensity -> String -> Color -> ColorIntensity -> String -> Color -> ColorIntensity -> String -> Color -> ColorIntensity -> String -> Color -> ColorIntensity -> String -> Color -> ColorIntensity -> String -> Color -> ColorIntensity -> Bool -> Int -> FilePath -> FilePath -> Redirection -> Config
+ GitHUD.Config.Types: Config :: Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> String -> String -> Color -> ColorIntensity -> String -> Color -> ColorIntensity -> String -> String -> String -> String -> [String] -> String -> String -> String -> Color -> ColorIntensity -> Color -> ColorIntensity -> String -> Color -> ColorIntensity -> String -> Color -> ColorIntensity -> String -> Color -> ColorIntensity -> String -> Color -> ColorIntensity -> String -> Color -> ColorIntensity -> String -> Color -> ColorIntensity -> String -> Color -> ColorIntensity -> String -> Color -> ColorIntensity -> String -> Color -> ColorIntensity -> String -> Color -> ColorIntensity -> String -> Color -> ColorIntensity -> String -> Color -> ColorIntensity -> Bool -> Int -> FilePath -> FilePath -> FilePath -> Redirection -> Config
Files
- githud.cabal +3/−2
- src/GitHUD.hs +41/−31
- src/GitHUD/Config/Parse.hs +2/−0
- src/GitHUD/Config/Types.hs +2/−0
- test/Test/GitHUD/Config/Parse.hs +6/−0
githud.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: githud-version: 3.2.1+version: 3.2.2 synopsis: Heads up, and you see your GIT context description: GIT Heads Up Display for your terminal prompt. More efficient replacement to the great git-radar. Please see README.md for more info homepage: http://github.com/gbataille/gitHUD#readme@@ -8,7 +8,7 @@ license-file: LICENSE author: Grégory Bataille maintainer: gregory.bataille@gmail.com-copyright: Grégory Bataille 2015-2019+copyright: Grégory Bataille 2015-2020 category: Development build-type: Simple -- extra-source-files:@@ -38,6 +38,7 @@ , daemons >= 0.3 && < 0.4 , data-default >= 0.7 && < 0.8 , directory >= 1.3 && < 1.4+ , filelock >= 0.1.1.4 && < 0.1.2.0 , mtl >= 2.2.2 && < 3 , network >= 2.8 && < 3.0 , parsec >= 3.1.13 && < 4
src/GitHUD.hs view
@@ -1,28 +1,29 @@ {-# LANGUAGE OverloadedStrings #-} -module GitHUD (- githud,- githudd- ) where+module GitHUD+ ( githud,+ githudd,+ )+where import Control.Monad (unless, void, when) import Control.Monad.Reader (runReader) import Data.Text-import System.Directory (getCurrentDirectory)-import System.Environment (getArgs)-import System.Exit (ExitCode(ExitSuccess))-import System.Posix.Files (fileExist)-import System.Posix.User (getRealUserID, getUserEntryForID, UserEntry(..))-import System.Process (readProcessWithExitCode)- import GitHUD.Config.Parse import GitHUD.Config.Types import GitHUD.Daemon.Runner+import GitHUD.Git.Command+import GitHUD.Git.Parse.Base import GitHUD.Terminal.Prompt import GitHUD.Terminal.Types-import GitHUD.Git.Parse.Base-import GitHUD.Git.Command import GitHUD.Types+import System.Directory (getCurrentDirectory)+import System.Environment (getArgs)+import System.Exit (ExitCode (ExitSuccess))+import System.FileLock (SharedExclusive (Exclusive), withTryFileLock)+import System.Posix.Files (fileExist)+import System.Posix.User (UserEntry (..), getRealUserID, getUserEntryForID)+import System.Process (readProcessWithExitCode) githud :: IO () githud = do@@ -32,28 +33,36 @@ shell <- processArguments getArgs config <- getAppConfig curDir <- getCurrentDirectory- runFetcherDaemon curDir+ tryRunFetcherDaemon curDir (confGithuddLockFilePath config) repoState <- getGitRepoState let prompt = runReader buildPromptWithConfig $ buildOutputConfig shell repoState config- -- Necessary to use putStrLn to properly terminate the output (needs the CR) putStrLn $ unpack (strip (pack prompt)) - where- runFetcherDaemon dir = do- (code, out, err) <- readProcessWithExitCode "githudd" [dir] ""- unless (Prelude.null err) (putStrLn $ "Issue with githudd: " ++ err)+tryRunFetcherDaemon ::+ String ->+ FilePath ->+ IO ()+tryRunFetcherDaemon dir lockPath = do+ withTryFileLock lockPath Exclusive (\f -> runFetcherDaemon dir)+ return ()+ where+ runFetcherDaemon dir = do+ (code, out, err) <- readProcessWithExitCode "githudd" [dir] ""+ unless (Prelude.null err) (putStrLn $ "Issue with githudd: " ++ err) -processArguments :: IO [String]- -> IO Shell+processArguments ::+ IO [String] ->+ IO Shell processArguments args = getShell <$> args -getShell :: [String]- -> Shell-getShell ("zsh":_) = ZSH-getShell ("bash":_) = BASH-getShell ("tmux":_) = TMUX-getShell ("none":_) = NONE+getShell ::+ [String] ->+ Shell+getShell ("zsh" : _) = ZSH+getShell ("bash" : _) = BASH+getShell ("tmux" : _) = TMUX+getShell ("none" : _) = NONE getShell _ = Other getAppConfig :: IO Config@@ -65,13 +74,14 @@ then parseConfigFile configFilePath else return defaultConfig -githudd :: IO()+githudd :: IO () githudd = do mArg <- processDaemonArguments <$> getArgs config <- getAppConfig runDaemon config mArg -processDaemonArguments :: [String]- -> Maybe String+processDaemonArguments ::+ [String] ->+ Maybe String processDaemonArguments [] = Nothing-processDaemonArguments (fst:_) = Just fst+processDaemonArguments (fst : _) = Just fst
src/GitHUD/Config/Parse.hs view
@@ -215,6 +215,8 @@ conf { confGithuddSleepSeconds = intConfigToInt value } configItemsFolder conf (Item "githudd_pid_file_path" value) = conf { confGithuddPidFilePath = value }+configItemsFolder conf (Item "githudd_lock_file_path" value) =+ conf { confGithuddLockFilePath = value } configItemsFolder conf (Item "githudd_socket_file_path" value) = conf { confGithuddSocketFilePath = value } configItemsFolder conf (Item "githudd_log_file_path" value) =
src/GitHUD/Config/Types.hs view
@@ -88,6 +88,7 @@ , confRunFetcherDaemon :: Bool , confGithuddSleepSeconds :: Int , confGithuddPidFilePath :: FilePath+ , confGithuddLockFilePath :: FilePath , confGithuddSocketFilePath :: FilePath , confGithuddLogFilePath :: Redirection@@ -170,6 +171,7 @@ , confRunFetcherDaemon = True , confGithuddSleepSeconds = 30 , confGithuddPidFilePath = tempDir ++ "/githudd.pid"+ , confGithuddLockFilePath = tempDir ++ "/githudd.lock" , confGithuddSocketFilePath = tempDir ++ "/githudd.socket" , confGithuddLogFilePath = DevNull
test/Test/GitHUD/Config/Parse.hs view
@@ -466,6 +466,12 @@ forConfigItemKey "githudd_pid_file_path" $ withValue "/tmp" + , testCase "Key: githudd_lock_file_path" $+ expectValue "/tmp" $+ toBeInField confGithuddLockFilePath $+ forConfigItemKey "githudd_lock_file_path" $+ withValue "/tmp"+ , testCase "Key: githudd_socket_file_path" $ expectValue "/tmp" $ toBeInField confGithuddSocketFilePath $