gitHUD 1.3.6 → 1.3.7
raw patch · 7 files changed
+47/−4 lines, 7 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ GitHUD.Git.Command: gitCmdCommitTag :: MVar String -> IO ()
+ GitHUD.Git.Types: [gitCommitTag] :: GitRepoState -> String
- GitHUD.Git.Types: GitRepoState :: GitLocalRepoChanges -> String -> String -> String -> String -> Int -> Int -> Int -> Int -> Int -> GitRepoState
+ GitHUD.Git.Types: GitRepoState :: GitLocalRepoChanges -> String -> String -> String -> String -> String -> Int -> Int -> Int -> Int -> Int -> GitRepoState
Files
- gitHUD.cabal +1/−1
- src/GitHUD/Git/Command.hs +7/−0
- src/GitHUD/Git/Parse/Base.hs +4/−0
- src/GitHUD/Git/Types.hs +2/−0
- src/GitHUD/Terminal/Prompt.hs +8/−2
- test/Test/GitHUD/Git/Types.hs +1/−1
- test/Test/GitHUD/Terminal/Prompt.hs +24/−0
gitHUD.cabal view
@@ -1,5 +1,5 @@ name: gitHUD-version: 1.3.6+version: 1.3.7 synopsis: More efficient replacement to the great git-radar description: Please see README.md homepage: http://github.com/gbataille/gitHUD#readme
src/GitHUD/Git/Command.hs view
@@ -8,6 +8,7 @@ , gitCmdRevToPull , gitCmdStashCount , gitCmdCommitShortSHA+ , gitCmdCommitTag , checkInGitDirectory ) where @@ -89,3 +90,9 @@ gitCmdCommitShortSHA out = do shortSHA <- readProcessWithIgnoreExitCode "git" ["rev-parse", "--short", "HEAD"] "" putMVar out shortSHA++gitCmdCommitTag :: MVar String+ -> IO ()+gitCmdCommitTag out = do+ tag <- readProcessWithIgnoreExitCode "git" ["describe", "--exact-match", "--tags"] ""+ putMVar out tag
src/GitHUD/Git/Parse/Base.hs view
@@ -23,11 +23,13 @@ mvRemoteName <- newEmptyMVar mvStashCount <- newEmptyMVar mvCommitShortSHA <- newEmptyMVar+ mvCommitTag <- newEmptyMVar forkIO $ gitCmdLocalBranchName mvLocalBranch forkIO $ gitCmdPorcelainStatus mvGitStatus forkIO $ gitCmdStashCount mvStashCount forkIO $ gitCmdCommitShortSHA mvCommitShortSHA+ forkIO $ gitCmdCommitTag mvCommitTag localBranchName <- removeEndingNewline <$> (takeMVar mvLocalBranch) forkIO $ gitCmdRemoteName localBranchName mvRemoteName@@ -36,12 +38,14 @@ repoState <- gitParseStatus <$> takeMVar mvGitStatus stashCountStr <- takeMVar mvStashCount commitShortSHA <- removeEndingNewline <$> takeMVar mvCommitShortSHA+ commitTag <- removeEndingNewline <$> takeMVar mvCommitTag fillGitRemoteRepoState zeroGitRepoState { gitLocalRepoChanges = repoState , gitRemote = remoteName , gitLocalBranch = localBranchName , gitCommitShortSHA = commitShortSHA+ , gitCommitTag = commitTag , gitStashCount = (getCount stashCountStr) }
src/GitHUD/Git/Types.hs view
@@ -45,6 +45,7 @@ gitLocalRepoChanges :: GitLocalRepoChanges , gitLocalBranch :: String , gitCommitShortSHA :: String+ , gitCommitTag :: String , gitRemote :: String , gitRemoteTrackingBranch :: String , gitStashCount :: Int@@ -61,6 +62,7 @@ gitLocalRepoChanges = zeroLocalRepoChanges , gitLocalBranch = "" , gitCommitShortSHA = ""+ , gitCommitTag = "" , gitRemote = "" , gitRemoteTrackingBranch = "" , gitStashCount = 0
src/GitHUD/Terminal/Prompt.hs view
@@ -113,6 +113,7 @@ repoState <- askRepoState config <- askConfig let localBranchName = gitLocalBranch repoState+ let commitTag = gitCommitTag repoState tell (confLocalBranchNamePrefix config) if (localBranchName /= "")@@ -120,8 +121,13 @@ tellStringInColor (confLocalBranchColor config) (confLocalBranchIntensity config) $ localBranchName else do- tellStringInColor (confLocalDetachedColor config) (confLocalDetachedIntensity config) $- (confLocalDetachedPrefix config) ++ (gitCommitShortSHA repoState)+ if (commitTag /= "")+ then do+ tellStringInColor (confLocalDetachedColor config) (confLocalDetachedIntensity config) $+ (confLocalDetachedPrefix config) ++ commitTag+ else do+ tellStringInColor (confLocalDetachedColor config) (confLocalDetachedIntensity config) $+ (confLocalDetachedPrefix config) ++ (gitCommitShortSHA repoState) tell (confLocalBranchNameSuffix config) tell " "
test/Test/GitHUD/Git/Types.hs view
@@ -18,7 +18,7 @@ mergeGitLocalRepoChanges glrc1 glrc2 @?= glrcMerged glrc1 :: GitLocalRepoChanges-glrc1 = GitLocalRepoChanges { +glrc1 = GitLocalRepoChanges { localMod = 3 , localAdd = 2 , localDel = 4
test/Test/GitHUD/Terminal/Prompt.hs view
@@ -210,6 +210,18 @@ addLocalBranchName @?= "[\x1b[39mfoo\x1b[39m] " + , testCase "ZSH: should display the current commit tag if we are not on one" $+ testWriterWithConfig+ (buildOutputConfig ZSH (zeroGitRepoState { gitCommitTag = "v1.1.1" }) defaultConfig)+ addLocalBranchName+ @?= "[%{\x1b[1;33m%}detached@v1.1.1%{\x1b[39m%}] "++ , testCase "Other: should display the current commit tog if we are on one" $+ testWriterWithConfig+ (buildOutputConfig Other (zeroGitRepoState { gitCommitTag = "v1.1.1" }) defaultConfig)+ addLocalBranchName+ @?= "[\x1b[1;33mdetached@v1.1.1\x1b[39m] "+ , testCase "ZSH: should display the current commit SHA if we are not on a branch's HEAD" $ testWriterWithConfig (buildOutputConfig ZSH (zeroGitRepoState { gitCommitShortSHA = "3d25ef" }) defaultConfig)@@ -234,6 +246,18 @@ (buildOutputConfig Other (zeroGitRepoState { gitLocalBranch = "foo" }) customConfigLocalBranchName) addLocalBranchName @?= "{\x1b[36mfoo\x1b[39m} "++ , testCase "ZSH: should display the current commit tag if we are not on one" $+ testWriterWithConfig+ (buildOutputConfig ZSH (zeroGitRepoState { gitCommitTag = "v1.1.1" }) customConfigLocalBranchName)+ addLocalBranchName+ @?= "{%{\x1b[35m%}det#!v1.1.1%{\x1b[39m%}} "++ , testCase "Other: should display the current commit tog if we are on one" $+ testWriterWithConfig+ (buildOutputConfig Other (zeroGitRepoState { gitCommitTag = "v1.1.1" }) customConfigLocalBranchName)+ addLocalBranchName+ @?= "{\x1b[35mdet#!v1.1.1\x1b[39m} " , testCase "ZSH: should display the current commit SHA if we are not on a branch's HEAD" $ testWriterWithConfig