story: enforce 80 cols, fix formatting, update comments

This commit is contained in:
Yaseen 2022-03-11 12:08:40 -05:00
parent b43b9f195e
commit 341e27b5c3
7 changed files with 112 additions and 67 deletions

View File

@ -1,4 +1,4 @@
:: story: Create a story file for a given desk, optionally overwriting an existing one
:: story: Create a story file for a given desk, optionally overwriting
::
::::
::
@ -14,7 +14,8 @@
helm-pass+[%d %noop ~]
=/ existing-story .^(? %cu /(scot %p our)/[desk]/(scot %da now)/story)
?: ?&(existing-story !overwrite)
~& >> "Error: /{(trip (slav %tas desk))}/story already exists. Set the optional parameter `overwrite` to `%.y` to forcibly overwrite."
~& >> "Error: /{(trip (slav %tas desk))}/story already exists."
~& >> "To forcibly overwrite, use `=overwrite %.y`"
:: XX could use a better way to noop
helm-pass+[%d %noop ~]
=| tale=story

View File

@ -1,4 +1,6 @@
:: story: Remove any commit message(s) for a given desk, optionally targeting a specific case or prose
:: story: Remove any commit message(s) for a given commit
::
:: Optionally targeting a specific desk or prose
::
::::
::

View File

@ -1,4 +1,6 @@
:: story: Attach a commit message to the commit associated with a given case on a given desk
:: story: Attach a commit message (to the last commit by default)
::
:: Optionally takes a case and desk
::
::::
::

View File

@ -1,4 +1,4 @@
:: story: (Internal) List all commit messages for the given desk including orphans
:: story: List unordered commit messages for the given desk, including orphans
::
::::
::
@ -13,10 +13,13 @@
=/ pax /(scot %p our)/[desk]/(scot cas)/story
?: !(~(has in .^((set ^desk) %cd /(scot %p our)/$/(scot %da now))) desk)
tang+[leaf+"Error: desk {<desk>} does not exist." ~]
?: !.^(? %cu pax) tang+['Error: No story file found. Please use |story-init to create one.' ~]
=/ tale=story .^(story %cx pax)
=/ story-to-mime .^($-(story mime) %cf /(scot %p our)/[desk]/(scot cas)/story/mime)
=/ tale-mime (story-to-mime tale)
=/ tale-text `@t`q.q.tale-mime
?: !.^(? %cu pax)
tang+['Error: No story file found. Please use |story-init to create one.' ~]
=/ story-to-mime
.^($-(story mime) %cf /(scot %p our)/[desk]/(scot cas)/story/mime)
::
=/ tale=story .^(story %cx pax)
=/ tale-mime (story-to-mime tale)
=/ tale-text `@t`q.q.tale-mime
:- %tang
[tale-text ~]

View File

@ -11,55 +11,62 @@
|^
=/ our p.bec
=? desk =(*^desk desk) q.bec :: use current desk if user didn't provide
=/ cas=case r.bec :: use case from beak
=/ cas r.bec :: use case from beak
=/ pax /(scot %p our)/[desk]/(scot cas)/story
?: !(~(has in .^((set ^desk) %cd /(scot %p our)/$/(scot %da now))) desk)
tang+[leaf+"Error: desk {<desk>} does not exist." ~]
=/ pax /(scot %p our)/[desk]/(scot cas)/story
?: !.^(? %cu pax) tang+['Error: No story file found. Please use |story-init to create one.' ~]
=/ tale .^(story %cx pax)
=/ current-tako .^(tako:clay %cs /(scot %p our)/[desk]/(scot cas)/tako/~)
=/ current-yaki .^(yaki:clay %cs /(scot %p our)/[desk]/(scot cas)/yaki/(scot %uv current-tako))
?: !.^(? %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)
:- %tang
(story-read [our desk cas] current-yaki tale)
(story-read [our desk cas] yak tale)
::::
:: Remarks:
::
:: There are two recursions in the logging process:
:: 1. the outer loop, `commit-loop` which threads downwards into each commit by ancestor
:: 2. the inner loop, `ancestor-loop`, which threads left-to-right on reverse-ancestors
:: 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
::
:: +story-read outputs a tang with the least-recent commits at the head of the list,
:: even though we want most-recent commits to end up printing first.
:: But because dojo prints tangs in reverse, we don't flop the results
:: +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.
::::
++ story-read
|= [[our=ship syd=^desk cas=case] current-commit=yaki:clay tale=story]
|= [[our=ship syd=^desk cas=case] this-commit=yaki:clay tale=story]
^- tang
:: TODO factor out /(scot %p our)/[syd]/(scot cas)
%- head :: result from state
=| state=[result=tang mergebase=(unit tako:clay)]
|-
^- _state
=* commit-loop $
=/ reverse-ancestors (flop p.current-commit)
=/ reverse-ancestors (flop p.this-commit)
|-
=* ancestor-loop $
?- reverse-ancestors
~
:: stop here and return the current message
=/ msg=(list cord) (msg-from-commit current-commit tale)
=/ msg=(list cord) (msg-from-commit this-commit tale)
[(weld msg result.state) mergebase=~]
::
[tako:clay ~]
=/ parent=tako:clay i.reverse-ancestors
=/ parent-commit .^(yaki:clay %cs /(scot %p our)/[syd]/(scot cas)/yaki/(scot %uv parent))
=/ msg (msg-from-commit current-commit tale)
=/ 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)
::
:: If there is a mergebase and we are visting it right now:
:: stop here and clear the mergebase.
:: skip adding the mergebase's msg itself because it will be added through the other branch
:: Otherwise, record the current message if exists
?: ?&(?=(^ mergebase.state) =(u.mergebase.state r.current-commit))
:: 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))
[result=result.state mergebase=~]
commit-loop(current-commit parent-commit, result.state (weld msg result.state))
commit-loop(this-commit parent-commit, result.state (weld msg result.state))
::
[tako:clay tako:clay ~]
::
@ -67,43 +74,68 @@
:: nowline: relative mainline
:: sideline: side-chain, featurebranch
::
:: From the context of e, commit c is on its relative mainline, or nowline, while commit d is on its sideline
:: From the context of e, commit c is on its relative mainline, or nowline,
:: while commit d is on its sideline.
::
:: %base a--b-------------X :: mainline
:: %new \--c------e--/ :: nowline
:: %new2 \--d--/ :: sideline
::
::
=/ sideline=tako:clay i.reverse-ancestors
=/ mainline=tako:clay i.t.reverse-ancestors
=/ mergebases .^((list tako:clay) %cs /(scot %p our)/[syd]/(scot cas)/base-tako/(scot %uv mainline)/(scot %uv sideline)) :: XX base-tako ignores beak
=/ next-mergebase=(unit tako:clay) ?~(mergebases ~ (some i.mergebases)) :: take the first valid mergebase (by convention) if exists, else none
:: ~& "Debug: Mergebase is null? {<=(~ next-mergebase)>}"
=/ sideline-commit=yaki:clay .^(yaki:clay %cs /(scot %p our)/[syd]/(scot cas)/yaki/(scot %uv sideline))
=/ mainline-commit=yaki:clay .^(yaki:clay %cs /(scot %p our)/[syd]/(scot cas)/yaki/(scot %uv mainline))
=/ msg=(list cord) (msg-from-commit current-commit tale)
=/ 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)
::
:: 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
:: (by definition) towards the less recent side of the resulting flopped list
:: (by definition) towards the less recent side of the flopped list
::
=. state [result=(weld msg result.state) mergebase=next-mergebase] :: 1
=. state commit-loop(current-commit sideline-commit) :: 2
=. state commit-loop(current-commit mainline-commit) :: 3
=. state commit-loop(this-commit sideline-commit) :: 2
=. state commit-loop(this-commit mainline-commit) :: 3
state
::
[tako:clay tako:clay tako:clay *]
~& "in 3+ ancestor commit"
=/ sideline=tako:clay i.reverse-ancestors
=/ nowline=tako:clay i.t.reverse-ancestors
=/ mergebases .^((list tako:clay) %cs /(scot %p our)/[syd]/(scot cas)/base-tako/(scot %uv nowline)/(scot %uv sideline))
=/ next-mergebase=(unit tako:clay) ?~(mergebases ~ (some i.mergebases)) :: take the first valid mergebase (by convention) if exists, else none
=/ sideline-commit=yaki:clay .^(yaki:clay %cs /(scot %p our)/[syd]/(scot cas)/yaki/(scot %uv sideline))
:: ~& "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))
=. mergebase.state next-mergebase
=. state commit-loop(current-commit sideline-commit) :: traverse downwards
=. state ancestor-loop(reverse-ancestors t.reverse-ancestors) :: traverse rightwards
=. state commit-loop(this-commit sideline-commit) :: downward
=. state ancestor-loop(reverse-ancestors t.reverse-ancestors) :: rightward
state
==
::
@ -112,7 +144,7 @@
^- (list cord)
=/ proses (~(get by tale) r.commit)
?~ proses ~
%- flop :: fix formatting reversal in dojo
%- flop :: fixes formatting reversal in dojo
%- to-wain:format
%- crip
;: welp

View File

@ -99,11 +99,14 @@
(cook crip ;~(sfix (star prn) (just '\0a')))
==
::
++ parse-prose-single ;~(plug parse-title parse-body) ::`$-(nail (like prose))`
++ parse-rest-proses (star ;~(pfix (jest '|||\0a') parse-prose-single)) ::`$-(nail (like (list prose)))`
++ parse-proses (cook silt ;~(plug parse-prose-single parse-rest-proses)) :: `$-(nail (like proses))`
++ parse-chapter ;~(plug parse-commit-hash parse-proses) :: `$-(nail (like chapter))`
++ parse-story (cook ~(gas by *story) (star ;~(sfix parse-chapter (jest '---\0a'))))
:: N.B. if instead of writing conflicting messages all under one conflict and you split them up (which is not supported notation),
:: we will overwrite previous entries with later ones (due to the nature of gas:by)
++ parse-prose ;~(plug parse-title parse-body)
++ parse-rest-proses (star ;~(pfix (jest '|||\0a') parse-prose))
++ parse-proses (cook silt ;~(plug parse-prose parse-rest-proses))
++ parse-chapter ;~(plug parse-commit-hash parse-proses)
++ parse-story
(cook ~(gas by *story) (star ;~(sfix parse-chapter (jest '---\0a'))))
::
:: N.B: If conflicting messages are written individually,
:: instead of under the same commit, we will overwrite previous entries
:: with later ones due to the nature of gas:by.
--

View File

@ -1,6 +1,5 @@
/- *story
/+ *story
!:
|_ tale=story
++ grad
|%
@ -14,7 +13,8 @@
[(dif-ju tory tale) (dif-ju tale tory)]
++ pact
|= dif=story-diff
:: compute the new story after applying dif to tale
:: Compute the new story after applying dif to tale.
::
^- story
=. tale (uni-ju tale additions.dif)
=. tale (dif-ju tale deletions.dif)
@ -25,8 +25,10 @@
=/ joined-additions (uni-ju additions.ali additions.bob)
=/ joined-deletions (uni-ju deletions.ali deletions.bob)
::
:: in a true join, we'd do an intersection and see if the vals are not exactly the same
:: which means we have a conflict, then we'd produce null, kick the flow to mash
:: In a true join, we'd do a set intersection on the keys.
:: If they're not equal, we have a conflict.
:: In this case, we'd produce null and kick the flow to +mash
::
%- some
[joined-additions joined-deletions]
++ mash
@ -58,9 +60,9 @@
==
--
++ grab
|% :: convert from
++ noun story :: clam from %noun
++ mime :: retrieve form %mime
|% :: convert from
++ noun story :: clam from %noun
++ mime :: retrieve from %mime
|= [p=mite q=octs]
=/ story-text `@t`q.q
`story`(rash story-text parse-story)