2022-02-19 01:40:55 +03:00
|
|
|
:: story: log commits in order
|
2022-01-21 19:50:42 +03:00
|
|
|
::
|
|
|
|
::::
|
|
|
|
::
|
|
|
|
/- *story
|
2022-01-27 02:07:29 +03:00
|
|
|
/+ lib=story
|
2022-01-21 19:50:42 +03:00
|
|
|
:- %say
|
|
|
|
|= $: [now=@da eny=@uvJ bec=beak]
|
2022-02-06 04:44:26 +03:00
|
|
|
[[~] =desk ~]
|
2022-01-21 19:50:42 +03:00
|
|
|
==
|
|
|
|
|^
|
2022-02-06 04:44:26 +03:00
|
|
|
=/ our p.bec
|
|
|
|
=? desk =(*^desk desk) q.bec :: use current desk if user didn't provide
|
2022-03-11 20:08:40 +03:00
|
|
|
=/ cas r.bec :: use case from beak
|
|
|
|
=/ pax /(scot %p our)/[desk]/(scot cas)/story
|
2022-02-22 06:13:15 +03:00
|
|
|
?: !(~(has in .^((set ^desk) %cd /(scot %p our)/$/(scot %da now))) desk)
|
|
|
|
tang+[leaf+"Error: desk {<desk>} does not exist." ~]
|
2022-03-11 20:08:40 +03:00
|
|
|
?: !.^(? %cu pax)
|
|
|
|
tang+['Error: No story file found. Please use |story-init to create one.' ~]
|
|
|
|
=/ tak .^(tako:clay %cs /(scot %p our)/[desk]/(scot cas)/tako/~)
|
|
|
|
=/ yak .^(yaki:clay %cs /(scot %p our)/[desk]/(scot cas)/yaki/(scot %uv tak))
|
|
|
|
=/ tale .^(story %cx pax)
|
2022-01-21 19:50:42 +03:00
|
|
|
:- %tang
|
2022-03-11 20:08:40 +03:00
|
|
|
(story-read [our desk cas] yak tale)
|
2022-01-21 19:50:42 +03:00
|
|
|
::::
|
|
|
|
:: Remarks:
|
|
|
|
::
|
2022-02-26 02:27:54 +03:00
|
|
|
:: There are two recursions in the logging process:
|
2022-03-11 20:08:40 +03:00
|
|
|
:: 1. the outer loop `commit-loop` threads down into each commit by ancestor
|
|
|
|
:: 2. the inner loop `ancestor-loop` threads left-to-right on reverse-ancestors
|
2022-02-26 00:28:05 +03:00
|
|
|
::
|
2022-03-11 20:08:40 +03:00
|
|
|
:: +story-read outputs a tang with the least-recent commits at the head
|
|
|
|
:: of the list, even though we want most-recent commits to print first.
|
|
|
|
:: But because dojo prints tangs in reverse, we don't flop the results.
|
2022-01-21 19:50:42 +03:00
|
|
|
::::
|
2022-02-26 02:27:54 +03:00
|
|
|
++ story-read
|
2022-03-11 20:08:40 +03:00
|
|
|
|= [[our=ship syd=^desk cas=case] this-commit=yaki:clay tale=story]
|
2022-01-21 19:50:42 +03:00
|
|
|
^- tang
|
2022-03-11 20:08:40 +03:00
|
|
|
:: TODO factor out /(scot %p our)/[syd]/(scot cas)
|
2022-02-06 04:44:26 +03:00
|
|
|
%- head :: result from state
|
2022-01-21 19:50:42 +03:00
|
|
|
=| state=[result=tang mergebase=(unit tako:clay)]
|
|
|
|
|-
|
|
|
|
^- _state
|
|
|
|
=* commit-loop $
|
2022-03-11 20:08:40 +03:00
|
|
|
=/ reverse-ancestors (flop p.this-commit)
|
2022-01-21 19:50:42 +03:00
|
|
|
|-
|
|
|
|
=* ancestor-loop $
|
|
|
|
?- reverse-ancestors
|
|
|
|
~
|
2022-02-06 04:44:26 +03:00
|
|
|
:: stop here and return the current message
|
2022-03-11 20:08:40 +03:00
|
|
|
=/ msg=(list cord) (msg-from-commit this-commit tale)
|
2022-02-26 00:28:05 +03:00
|
|
|
[(weld msg result.state) mergebase=~]
|
2022-01-21 19:50:42 +03:00
|
|
|
::
|
|
|
|
[tako:clay ~]
|
2022-03-11 20:08:40 +03:00
|
|
|
=/ parent i.reverse-ancestors
|
|
|
|
=/ parent-commit
|
|
|
|
.^(yaki:clay %cs /(scot %p our)/[syd]/(scot cas)/yaki/(scot %uv parent))
|
|
|
|
::
|
|
|
|
=/ msg
|
|
|
|
(msg-from-commit this-commit tale)
|
|
|
|
::
|
2022-02-06 04:44:26 +03:00
|
|
|
:: If there is a mergebase and we are visting it right now:
|
|
|
|
:: stop here and clear the mergebase.
|
2022-03-11 20:08:40 +03:00
|
|
|
:: skip adding the mergebase's msg itself,
|
|
|
|
:: because it will be added through the other branch.
|
|
|
|
:: Otherwise, record the current message if exists and recur.
|
|
|
|
?: ?&(?=(^ mergebase.state) =(u.mergebase.state r.this-commit))
|
2022-01-21 19:50:42 +03:00
|
|
|
[result=result.state mergebase=~]
|
2022-03-11 20:08:40 +03:00
|
|
|
commit-loop(this-commit parent-commit, result.state (weld msg result.state))
|
2022-01-21 19:50:42 +03:00
|
|
|
::
|
|
|
|
[tako:clay tako:clay ~]
|
|
|
|
::
|
|
|
|
:: mainline: ultimate base chain
|
2022-02-06 04:44:26 +03:00
|
|
|
:: nowline: relative mainline
|
2022-01-21 19:50:42 +03:00
|
|
|
:: sideline: side-chain, featurebranch
|
|
|
|
::
|
2022-03-11 20:08:40 +03:00
|
|
|
:: From the context of e, commit c is on its relative mainline, or nowline,
|
|
|
|
:: while commit d is on its sideline.
|
|
|
|
::
|
2022-01-21 19:50:42 +03:00
|
|
|
:: %base a--b-------------X :: mainline
|
|
|
|
:: %new \--c------e--/ :: nowline
|
|
|
|
:: %new2 \--d--/ :: sideline
|
|
|
|
::
|
|
|
|
::
|
2022-03-11 20:08:40 +03:00
|
|
|
=/ sideline i.reverse-ancestors
|
|
|
|
=/ mainline i.t.reverse-ancestors
|
|
|
|
:: XX base-tako ignores beak
|
|
|
|
::
|
|
|
|
=/ mergebases
|
|
|
|
.^ (list tako:clay) %cs
|
|
|
|
(scot %p our) syd (scot cas)
|
|
|
|
/base-tako/(scot %uv mainline)/(scot %uv sideline)
|
|
|
|
==
|
|
|
|
::
|
|
|
|
:: Take the first valid mergebase (by convention) if exists, else none
|
|
|
|
::
|
|
|
|
=/ next-mergebase
|
|
|
|
?~(mergebases ~ (some i.mergebases))
|
|
|
|
::
|
|
|
|
=/ sideline-commit
|
|
|
|
.^(yaki:clay %cs /(scot %p our)/[syd]/(scot cas)/yaki/(scot %uv sideline))
|
|
|
|
::
|
|
|
|
=/ mainline-commit
|
|
|
|
.^(yaki:clay %cs /(scot %p our)/[syd]/(scot cas)/yaki/(scot %uv mainline))
|
|
|
|
::
|
|
|
|
=/ msg=(list cord)
|
|
|
|
(msg-from-commit this-commit tale)
|
2022-01-21 19:50:42 +03:00
|
|
|
::
|
|
|
|
:: 1 - process current commit
|
|
|
|
:: 2 - recur and queue processing on all commits on the sideline
|
|
|
|
:: 3 - recur and queue processing on all commits on the mainline
|
|
|
|
::
|
|
|
|
:: Because mainline messages are cons'd to result last, they are
|
2022-03-11 20:08:40 +03:00
|
|
|
:: (by definition) towards the less recent side of the flopped list
|
2022-01-21 19:50:42 +03:00
|
|
|
::
|
2022-02-26 00:28:05 +03:00
|
|
|
=. state [result=(weld msg result.state) mergebase=next-mergebase] :: 1
|
2022-03-11 20:08:40 +03:00
|
|
|
=. state commit-loop(this-commit sideline-commit) :: 2
|
|
|
|
=. state commit-loop(this-commit mainline-commit) :: 3
|
2022-01-21 19:50:42 +03:00
|
|
|
state
|
|
|
|
::
|
|
|
|
[tako:clay tako:clay tako:clay *]
|
2022-03-11 20:08:40 +03:00
|
|
|
:: ~& "in 3+ ancestor commit"
|
|
|
|
=/ sideline i.reverse-ancestors
|
|
|
|
=/ nowline i.t.reverse-ancestors
|
|
|
|
=/ mergebases
|
|
|
|
.^ (list tako:clay) %cs
|
|
|
|
(scot %p our) syd (scot cas)
|
|
|
|
/base-tako/(scot %uv nowline)/(scot %uv sideline)
|
|
|
|
==
|
|
|
|
::
|
|
|
|
:: Take the first valid mergebase (by convention) if exists, else none
|
|
|
|
::
|
|
|
|
=/ next-mergebase ?~(mergebases ~ (some i.mergebases))
|
|
|
|
=/ sideline-commit
|
|
|
|
.^(yaki:clay %cs /(scot %p our)/[syd]/(scot cas)/yaki/(scot %uv sideline))
|
2022-01-21 19:50:42 +03:00
|
|
|
=. mergebase.state next-mergebase
|
2022-03-11 20:08:40 +03:00
|
|
|
=. state commit-loop(this-commit sideline-commit) :: downward
|
|
|
|
=. state ancestor-loop(reverse-ancestors t.reverse-ancestors) :: rightward
|
2022-01-21 19:50:42 +03:00
|
|
|
state
|
|
|
|
==
|
2022-02-19 02:20:17 +03:00
|
|
|
::
|
2022-02-06 04:44:26 +03:00
|
|
|
++ msg-from-commit
|
|
|
|
|= [commit=yaki:clay tale=story]
|
2022-02-26 00:28:05 +03:00
|
|
|
^- (list cord)
|
2022-02-06 04:44:26 +03:00
|
|
|
=/ proses (~(get by tale) r.commit)
|
|
|
|
?~ proses ~
|
2022-03-11 20:08:40 +03:00
|
|
|
%- flop :: fixes formatting reversal in dojo
|
2022-02-26 00:28:05 +03:00
|
|
|
%- to-wain:format
|
2022-02-06 04:44:26 +03:00
|
|
|
%- crip
|
|
|
|
;: welp
|
|
|
|
(tako-to-text:lib r.commit)
|
|
|
|
(proses-to-text:lib u.proses)
|
|
|
|
==
|
2022-01-21 19:50:42 +03:00
|
|
|
--
|