gitHUD 1.3.1 → 1.3.2
raw patch · 6 files changed
+68/−8 lines, 6 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ GitHUD.Config.Parse: stringConfigToStringList :: String -> [String]
+ GitHUD.Config.Types: [confMergeBranchIgnoreBranches] :: Config -> [String]
- GitHUD.Config.Types: Config :: Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> String -> String -> Color -> ColorIntensity -> String -> Color -> ColorIntensity -> 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 -> 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 -> Config
Files
- gitHUD.cabal +3/−3
- src/GitHUD/Config/Parse.hs +27/−2
- src/GitHUD/Config/Types.hs +2/−0
- src/GitHUD/Terminal/Prompt.hs +9/−2
- test/Test/GitHUD/Config/Parse.hs +20/−0
- test/Test/GitHUD/Terminal/Prompt.hs +7/−1
gitHUD.cabal view
@@ -1,13 +1,13 @@ name: gitHUD-version: 1.3.1+version: 1.3.2 synopsis: More efficient replacement to the great git-radar description: Please see README.md homepage: http://github.com/gbataille/gitHUD#readme license: BSD3 license-file: LICENSE author: Grégory Bataille-maintainer: gbataille.dev@gmail.com-copyright: Grégory Bataille 2015+maintainer: gregory.bataille@gmail.com+copyright: Grégory Bataille 2015-2016 category: Development build-type: Simple -- extra-source-files:
src/GitHUD/Config/Parse.hs view
@@ -7,12 +7,13 @@ , ConfigItem(..) , colorConfigToColor , intensityConfigToIntensity+ , stringConfigToStringList ) where import Control.Monad (void, when) import Text.Parsec (parse)-import Text.Parsec.Char (anyChar, char, newline, letter, string)-import Text.Parsec.Combinator (choice, eof, manyTill)+import Text.Parsec.Char (anyChar, char, newline, noneOf, letter, spaces, string)+import Text.Parsec.Combinator (choice, eof, many1, manyTill, optional, sepBy) import Text.Parsec.Prim (many, try, unexpected, (<|>), (<?>)) import Text.Parsec.String (parseFromFile, Parser) @@ -110,6 +111,8 @@ conf { confMergeBranchCommitsOnlyPush = value } configItemsFolder conf (Item "merge_branch_commits_push_pull_infix" value) = conf { confMergeBranchCommitsBothPullPush = value }+configItemsFolder conf (Item "merge_branch_ignore_branches" value) =+ conf { confMergeBranchIgnoreBranches = stringConfigToStringList value } configItemsFolder conf (Item "local_branch_prefix" value) = conf { confLocalBranchNamePrefix = value }@@ -242,6 +245,28 @@ (const True) id (parse boolParser "" str)++stringConfigToStringList :: String -> [String]+stringConfigToStringList str =+ either+ (const [])+ id+ (parse stringListParser "" str)++stringListParser :: Parser [String]+stringListParser = do+ branchNameList <- sepBy stripedBranchName (char ',')+ return $ filter noEmptyStringFilter branchNameList++noEmptyStringFilter :: String -> Bool+noEmptyStringFilter str = not (str == "")++stripedBranchName :: Parser String+stripedBranchName = do+ spaces+ branchName <- many (noneOf [',', ' '])+ spaces+ return branchName boolParser :: Parser Bool boolParser = choice [
src/GitHUD/Config/Types.hs view
@@ -26,6 +26,7 @@ , confMergeBranchCommitsOnlyPush :: String , confMergeBranchCommitsOnlyPull :: String , confMergeBranchCommitsBothPullPush :: String+ , confMergeBranchIgnoreBranches :: [String] , confLocalBranchNamePrefix :: String , confLocalBranchNameSuffix :: String@@ -97,6 +98,7 @@ , confMergeBranchCommitsOnlyPush = "\8592" , confMergeBranchCommitsOnlyPull = "\8594" , confMergeBranchCommitsBothPullPush = "\8644"+ , confMergeBranchIgnoreBranches = ["gh-pages"] , confLocalBranchNamePrefix = "[" , confLocalBranchNameSuffix = "]"
src/GitHUD/Terminal/Prompt.hs view
@@ -31,15 +31,22 @@ buildPrompt :: ShellOutput buildPrompt = do config <- askConfig+ repoState <- askRepoState+ let branch = gitLocalBranch repoState resetPromptAtBeginning when (confShowPartRepoIndicator config) $ addGitRepoIndicator- when (confShowPartMergeBranchCommitsDiff config) $ addNoTrackedUpstreamIndicator- when (confShowPartMergeBranchCommitsDiff config) $ addMergeBranchCommits+ when (showMergeBranchIndicator branch config) $ addNoTrackedUpstreamIndicator+ when (showMergeBranchIndicator branch config) $ addMergeBranchCommits when (confShowPartLocalBranch config) $ addLocalBranchName when (confShowPartCommitsToOrigin config) $ addLocalCommits when (confShowPartLocalChangesState config) $ addRepoState when (confShowPartStashes config) $ addStashes return ()++showMergeBranchIndicator :: String -> Config -> Bool+showMergeBranchIndicator branch config =+ (confShowPartMergeBranchCommitsDiff config) &&+ (not (branch `elem` (confMergeBranchIgnoreBranches config))) resetPromptAtBeginning :: ShellOutput resetPromptAtBeginning =
test/Test/GitHUD/Config/Parse.hs view
@@ -19,6 +19,7 @@ , testConfigItemFolder , testColorConfigToColor , testIntensityConfigToIntensity+ , testStringConfigToStringList ] testItemParser :: TestTree@@ -179,6 +180,12 @@ forConfigItemKey "merge_branch_commits_push_pull_infix" $ withValue "FOO" + , testCase "Key: merge_branch_ignore_branches" $+ expectValue ["gh-pages", "FOO"] $+ toBeInField confMergeBranchIgnoreBranches $+ forConfigItemKey "merge_branch_ignore_branches" $+ withValue "gh-pages, FOO"+ , testCase "Key: local_branch_prefix" $ expectValue "FOO" $ toBeInField confLocalBranchNamePrefix $@@ -475,3 +482,16 @@ , testCase "invalid color - default to Blue" $ colorConfigToColor "Foo" @?= NoColor ]++testStringConfigToStringList :: TestTree+testStringConfigToStringList = testGroup "#stringConfigToStringList"+ [ testCase "valid string list, comma separated, no spaces" $+ stringConfigToStringList "foo,bar" @?= ["foo", "bar"]++ , testCase "valid string list, comma separated, spaces" $+ stringConfigToStringList "foo, bar , baz " @?= ["foo", "bar", "baz"]++ , testCase "valid string list, comma separated, finish with comma" $+ stringConfigToStringList "foo,bar, " @?= ["foo", "bar"]+ ]+
test/Test/GitHUD/Terminal/Prompt.hs view
@@ -519,7 +519,7 @@ {- For reference here, the full prompt would be - "\5812 \120366 2%{\ESC[1;32m%}\8644%{\ESC[0m%}1 [%{\ESC[0m%}branch%{\ESC[0m%}] 5%{\ESC[1;32m%}⥯%{\ESC[0m%}6 5%{\ESC[1;32m%}A%{\ESC[0m%}6%{\ESC[1;32m%}D%{\ESC[0m%}4%{\ESC[1;32m%}M%{\ESC[0m%}7%{\ESC[1;32m%}R%{\ESC[0m%} 3%{\ESC[1;31m%}D%{\ESC[0m%}1%{\ESC[1;31m%}M%{\ESC[0m%} 2%{\ESC[1;37m%}A%{\ESC[0m%} 8%{\ESC[1;32m%}C%{\ESC[0m%} 3%{\ESC[1;32m%}\8801%{\ESC[0m%} "+ "%{\ESC[0m%}\5812 \120366 2%{\ESC[1;32m%}\8644%{\ESC[0m%}1 [%{\ESC[0m%}branch%{\ESC[0m%}] 5%{\ESC[1;32m%}⥯%{\ESC[0m%}6 5%{\ESC[1;32m%}A%{\ESC[0m%}6%{\ESC[1;32m%}D%{\ESC[0m%}4%{\ESC[1;32m%}M%{\ESC[0m%}7%{\ESC[1;32m%}R%{\ESC[0m%} 3%{\ESC[1;31m%}D%{\ESC[0m%}1%{\ESC[1;31m%}M%{\ESC[0m%} 2%{\ESC[1;37m%}A%{\ESC[0m%} 8%{\ESC[1;32m%}C%{\ESC[0m%} 3%{\ESC[1;32m%}\8801%{\ESC[0m%} " -} testPartialPrompt :: TestTree@@ -541,6 +541,12 @@ (buildOutputConfig ZSH repoStateForPartialPrompt defaultConfig { confShowPartLocalBranch = False }) buildPrompt @?= "%{\ESC[0m%}\5812 \120366 2%{\ESC[1;32m%}\8644%{\ESC[0m%}1 5%{\ESC[1;32m%}⥯%{\ESC[0m%}6 5%{\ESC[1;32m%}A%{\ESC[0m%}6%{\ESC[1;32m%}D%{\ESC[0m%}4%{\ESC[1;32m%}M%{\ESC[0m%}7%{\ESC[1;32m%}R%{\ESC[0m%} 3%{\ESC[1;31m%}D%{\ESC[0m%}1%{\ESC[1;31m%}M%{\ESC[0m%} 2%{\ESC[1;37m%}A%{\ESC[0m%} 8%{\ESC[1;32m%}C%{\ESC[0m%} 3%{\ESC[1;32m%}\8801%{\ESC[0m%} "++ , testCase "with a branch set to ignore its merge branch" $+ testWriterWithConfig+ (buildOutputConfig ZSH repoStateForPartialPrompt defaultConfig { confMergeBranchIgnoreBranches = ["branch"] })+ buildPrompt+ @?= "%{\ESC[0m%}\5812 [%{\ESC[0m%}branch%{\ESC[0m%}] 5%{\ESC[1;32m%}⥯%{\ESC[0m%}6 5%{\ESC[1;32m%}A%{\ESC[0m%}6%{\ESC[1;32m%}D%{\ESC[0m%}4%{\ESC[1;32m%}M%{\ESC[0m%}7%{\ESC[1;32m%}R%{\ESC[0m%} 3%{\ESC[1;31m%}D%{\ESC[0m%}1%{\ESC[1;31m%}M%{\ESC[0m%} 2%{\ESC[1;37m%}A%{\ESC[0m%} 8%{\ESC[1;32m%}C%{\ESC[0m%} 3%{\ESC[1;32m%}\8801%{\ESC[0m%} " , testCase "w/out commits push/pull info" $ testWriterWithConfig