Reformat reflog output

This commit is contained in:
Chris Penner 2022-09-01 15:49:17 -06:00
parent cfb6fae357
commit 482ba16523
3 changed files with 13 additions and 8 deletions

View File

@ -404,7 +404,7 @@ loop e = do
expandEntries ([], Just expectedHash, moreEntriesToLoad) =
if moreEntriesToLoad
then Nothing
else Just ((Nothing, expectedHash, "The history starts here"), ([], Nothing, moreEntriesToLoad))
else Just ((Nothing, expectedHash, "history starts here"), ([], Nothing, moreEntriesToLoad))
expandEntries ([], Nothing, _moreEntriesToLoad) = Nothing
expandEntries (entries@(Reflog.Entry {time, fromRootCausalHash, toRootCausalHash, reason} : rest), mayExpectedHash, moreEntriesToLoad) =
Just $

View File

@ -1403,7 +1403,7 @@ notifyUser dir o = case o of
pure $
P.lines
[ header,
P.numberedColumnNHeader ["When", "Action", "Root Hash"] $ entries <&> renderEntry3Column now,
P.numberedColumnNHeader ["When", "Root Hash", "Action"] $ entries <&> renderEntry3Column now,
"",
tip $ "Use " <> IP.makeExample IP.diffNamespace ["1", "7"] <> " to compare namespaces between two points in history."
]
@ -1437,7 +1437,11 @@ notifyUser dir o = case o of
_ -> mempty
renderEntry3Column :: UTCTime -> (Maybe UTCTime, SBH.ShortBranchHash, Text) -> [Pretty]
renderEntry3Column now (mayTime, sbh, reason) =
[maybe "" (prettyHumanReadableTime now) mayTime, P.text reason, P.blue (prettySBH sbh)]
[maybe "" (prettyHumanReadableTime now) mayTime, P.blue (prettySBH sbh), P.text $ truncateReason reason]
truncateReason :: Text -> Text
truncateReason txt = case Text.splitAt 60 txt of
(short, "") -> short
(short, _) -> short <> "..."
StartOfCurrentPathHistory ->
pure $
P.wrap "You're already at the very beginning! 🙂"
@ -3153,7 +3157,7 @@ prettyHumanReadableTime now time =
{ justNow = "now",
secondsAgo = \f -> (++ " secs" ++ dir f),
oneMinuteAgo = \f -> "a min" ++ dir f,
minutesAgo = \f -> (++ " minutes" ++ dir f),
minutesAgo = \f -> (++ " mins" ++ dir f),
oneHourAgo = \f -> "an hour" ++ dir f,
aboutHoursAgo = \f x -> "about " ++ x ++ " hours" ++ dir f,
at = \_ t -> t,

View File

@ -66,10 +66,11 @@ y = 2
its history to that of the
specified namespace.
When Action Root Hash
1. now add #5fihla47kl
2. now add #2a4hnm3mcj
3. now builtins.merge #43lqh9lfp3
When Root Hash Action
1. now #5fihla47kl add
2. now #2a4hnm3mcj add
3. now #43lqh9lfp3 builtins.merge
4. #sg60bvjo91 history starts here
Tip: Use `diff.namespace 1 7` to compare namespaces between
two points in history.