mirror of
https://github.com/unisonweb/unison.git
synced 2024-09-11 02:25:39 +03:00
Omit times from project reflogs
This commit is contained in:
parent
c156ba75c8
commit
6fe6d673d2
@ -6,6 +6,7 @@ module Unison.Codebase.Editor.HandleInput.Reflogs
|
||||
)
|
||||
where
|
||||
|
||||
import Control.Monad.Reader
|
||||
import Data.Time (getCurrentTime)
|
||||
import U.Codebase.HashTags (CausalHash)
|
||||
import U.Codebase.Sqlite.Project (Project)
|
||||
@ -52,5 +53,8 @@ reflogHelper getEntries = do
|
||||
if length entries == numEntriesToShow
|
||||
then Output.MoreEntriesThanShown
|
||||
else Output.AllEntriesShown
|
||||
now <- liftIO getCurrentTime
|
||||
Cli.respondNumbered $ Output.ShowProjectBranchReflog now moreEntriesToLoad entries
|
||||
mayNow <-
|
||||
asks Cli.isTranscriptTest >>= \case
|
||||
True -> pure Nothing
|
||||
False -> Just <$> liftIO getCurrentTime
|
||||
Cli.respondNumbered $ Output.ShowProjectBranchReflog mayNow moreEntriesToLoad entries
|
||||
|
@ -154,7 +154,10 @@ data NumberedOutput
|
||||
PPE.PrettyPrintEnv -- PPE containing names for everything from the root namespace.
|
||||
ProjectPath -- The namespace we're checking dependencies for.
|
||||
(Map LabeledDependency (Set Name)) -- Mapping of external dependencies to their local dependents.
|
||||
| ShowProjectBranchReflog UTCTime {- current time -} MoreEntriesThanShown [ProjectReflog.Entry Project ProjectBranch (CausalHash, SCH.ShortCausalHash)]
|
||||
| ShowProjectBranchReflog
|
||||
(Maybe UTCTime {- current time, omitted in transcript tests to be more deterministic -})
|
||||
MoreEntriesThanShown
|
||||
[ProjectReflog.Entry Project ProjectBranch (CausalHash, SCH.ShortCausalHash)]
|
||||
|
||||
data TodoOutput = TodoOutput
|
||||
{ dependentsOfTodo :: !(Set TermReferenceId),
|
||||
|
@ -3389,19 +3389,19 @@ listDependentsOrDependencies ppe labelStart label lds types terms =
|
||||
c = P.syntaxToColor
|
||||
|
||||
displayProjectBranchReflogEntries ::
|
||||
UTCTime ->
|
||||
Maybe UTCTime ->
|
||||
E.MoreEntriesThanShown ->
|
||||
[ProjectReflog.Entry Project ProjectBranch (CausalHash, ShortCausalHash)] ->
|
||||
(Pretty, NumberedArgs)
|
||||
displayProjectBranchReflogEntries _ _ [] =
|
||||
(P.warnCallout "The reflog is empty", mempty)
|
||||
displayProjectBranchReflogEntries now _ entries =
|
||||
displayProjectBranchReflogEntries mayNow _ entries =
|
||||
let (entryRows, numberedArgs) = foldMap renderEntry entries
|
||||
rendered =
|
||||
P.lines
|
||||
[ header,
|
||||
"",
|
||||
P.numberedColumnNHeader ["Branch", "When", "Hash", "Description"] entryRows
|
||||
P.numberedColumnNHeader (["Branch"] <> Monoid.whenM (isJust mayNow) ["When"] <> ["Hash", "Description"]) entryRows
|
||||
]
|
||||
in (rendered, numberedArgs)
|
||||
where
|
||||
@ -3416,7 +3416,14 @@ displayProjectBranchReflogEntries now _ entries =
|
||||
]
|
||||
renderEntry :: ProjectReflog.Entry Project ProjectBranch (CausalHash, SCH.ShortCausalHash) -> ([[Pretty]], NumberedArgs)
|
||||
renderEntry ProjectReflog.Entry {time, project, branch, toRootCausalHash = (toCH, toSCH), reason} =
|
||||
([[prettyProjectAndBranchName $ ProjectAndBranch project.name branch.name, prettyHumanReadableTime now time, P.blue (prettySCH toSCH), P.text $ truncateReason reason]], [SA.Namespace toCH])
|
||||
( [ [prettyProjectAndBranchName $ ProjectAndBranch project.name branch.name]
|
||||
<> ( mayNow
|
||||
& foldMap (\now -> [prettyHumanReadableTime now time])
|
||||
)
|
||||
<> [P.blue (prettySCH toSCH), P.text $ truncateReason reason]
|
||||
],
|
||||
[SA.Namespace toCH]
|
||||
)
|
||||
truncateReason :: Text -> Text
|
||||
truncateReason txt = case Text.splitAt 60 txt of
|
||||
(short, "") -> short
|
||||
|
@ -81,11 +81,11 @@ scratch/main> reflog
|
||||
Tip: Use `diff.namespace 1 7` to compare between points in
|
||||
history.
|
||||
|
||||
Branch When Hash Description
|
||||
1. scratch/main now #6mdl5gruh5 add
|
||||
2. scratch/main now #3rqf1hbev7 add
|
||||
3. scratch/main now #ms9lggs2rg builtins.merge scratch/main:.lib.builtins
|
||||
4. scratch/main now #sg60bvjo91 Project Created
|
||||
Branch Hash Description
|
||||
1. scratch/main #6mdl5gruh5 add
|
||||
2. scratch/main #3rqf1hbev7 add
|
||||
3. scratch/main #ms9lggs2rg builtins.merge scratch/main:.lib.builtins
|
||||
4. scratch/main #sg60bvjo91 Project Created
|
||||
|
||||
```
|
||||
Should see reflog entries from the current project
|
||||
@ -100,13 +100,13 @@ scratch/main> project.reflog
|
||||
Tip: Use `diff.namespace 1 7` to compare between points in
|
||||
history.
|
||||
|
||||
Branch When Hash Description
|
||||
1. scratch/other now #148flqs4b1 alias.term scratch/other:..y scratch/other:.z
|
||||
2. scratch/other now #6mdl5gruh5 Branch created from scratch/main
|
||||
3. scratch/main now #6mdl5gruh5 add
|
||||
4. scratch/main now #3rqf1hbev7 add
|
||||
5. scratch/main now #ms9lggs2rg builtins.merge scratch/main:.lib.builtins
|
||||
6. scratch/main now #sg60bvjo91 Project Created
|
||||
Branch Hash Description
|
||||
1. scratch/other #148flqs4b1 alias.term scratch/other:..y scratch/other:.z
|
||||
2. scratch/other #6mdl5gruh5 Branch created from scratch/main
|
||||
3. scratch/main #6mdl5gruh5 add
|
||||
4. scratch/main #3rqf1hbev7 add
|
||||
5. scratch/main #ms9lggs2rg builtins.merge scratch/main:.lib.builtins
|
||||
6. scratch/main #sg60bvjo91 Project Created
|
||||
|
||||
```
|
||||
Should see reflog entries from all projects
|
||||
@ -121,15 +121,15 @@ scratch/main> reflog.global
|
||||
Tip: Use `diff.namespace 1 7` to compare between points in
|
||||
history.
|
||||
|
||||
Branch When Hash Description
|
||||
1. newproject/main now #2rjhs2vq43 alias.term newproject/main:.lib.builtins.Nat newproject/main...
|
||||
2. newproject/main now #ms9lggs2rg builtins.merge newproject/main:.lib.builtins
|
||||
3. newproject/main now #sg60bvjo91 Branch Created
|
||||
4. scratch/other now #148flqs4b1 alias.term scratch/other:..y scratch/other:.z
|
||||
5. scratch/other now #6mdl5gruh5 Branch created from scratch/main
|
||||
6. scratch/main now #6mdl5gruh5 add
|
||||
7. scratch/main now #3rqf1hbev7 add
|
||||
8. scratch/main now #ms9lggs2rg builtins.merge scratch/main:.lib.builtins
|
||||
9. scratch/main now #sg60bvjo91 Project Created
|
||||
Branch Hash Description
|
||||
1. newproject/main #2rjhs2vq43 alias.term newproject/main:.lib.builtins.Nat newproject/main...
|
||||
2. newproject/main #ms9lggs2rg builtins.merge newproject/main:.lib.builtins
|
||||
3. newproject/main #sg60bvjo91 Branch Created
|
||||
4. scratch/other #148flqs4b1 alias.term scratch/other:..y scratch/other:.z
|
||||
5. scratch/other #6mdl5gruh5 Branch created from scratch/main
|
||||
6. scratch/main #6mdl5gruh5 add
|
||||
7. scratch/main #3rqf1hbev7 add
|
||||
8. scratch/main #ms9lggs2rg builtins.merge scratch/main:.lib.builtins
|
||||
9. scratch/main #sg60bvjo91 Project Created
|
||||
|
||||
```
|
||||
|
@ -83,12 +83,12 @@ scratch/main> reflog
|
||||
Tip: Use `diff.namespace 1 7` to compare between points in
|
||||
history.
|
||||
|
||||
Branch When Hash Description
|
||||
1. scratch/main now #ujvq6e87kp reset ujvq6e87kp4288eq3al9v5luctic0ocd7ug1fu0go5bicrr2vfnrb0...
|
||||
2. scratch/main now #5vq851j3hg update
|
||||
3. scratch/main now #ujvq6e87kp update
|
||||
4. scratch/main now #4bigcpnl7t builtins.merge
|
||||
5. scratch/main now #sg60bvjo91 Project Created
|
||||
Branch Hash Description
|
||||
1. scratch/main #ujvq6e87kp reset ujvq6e87kp4288eq3al9v5luctic0ocd7ug1fu0go5bicrr2vfnrb0...
|
||||
2. scratch/main #5vq851j3hg update
|
||||
3. scratch/main #ujvq6e87kp update
|
||||
4. scratch/main #4bigcpnl7t builtins.merge
|
||||
5. scratch/main #sg60bvjo91 Project Created
|
||||
|
||||
-- Reset the current branch to the first history element
|
||||
scratch/main> reset 2
|
||||
|
Loading…
Reference in New Issue
Block a user