Don't change recipe checkout on abra app deploy if there are unnamed changes
#751
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
As there were reports about seemingly lost changes during recipe dev, I suggest that
abrashould only change the checkout of a recipe if it is currently on a named tag or branch.If I am mindful (and knowledgable) enough I know that I should not do dev in a detached HEAD, though it happens so fast...
Repro:
--chaos--chaos(cancel deployment)Expected outcome:
Actual outcome:
git reflogif you realize what happenedI also stumbled on this lately. I wrote some notes on it. Would it make sense to add those to the docs?
Thank you, that would be a great addition to the docs!
I think I also stumbled into this haha https://matrix.to/#/!DfXPgKLoYCvjHithgS:autonomic.zone/$ElSMkpD1hzrRKRBwetZWAaDdGHvetXOtu5pikfne7vs?via=autonomic.zone&via=matrix.org&via=pub.solar
as an alternative/additional solution, I could imagine having env config for abra in addition to cli?
ABRA_ENSURE_CHAOS (lol at this name)
and when true, then abra just never does the checkout thing
then when you are doing recipe dev work you can set this environment variable and you are safe from confusion
How about this: when warning the user about the modifications and hinting --chaos, could Abra just ask if the user wants to switch to hack mode? And in hack mode, the recipes head will be attached to a selectable branch or create a new one based on main.
And to make sure people are aware when using Abra, they need to pass --hack to every Abra command to wor k in hack mode.
Another idea, following the initial report in #751 (comment):
Why doesn't
abrastore where the checkout is before it does something and always return to it at the end of the operation? This would mean that if you're onmainand then do anabra app deploy, it will always return tomainonce it is finished.If there are unstaged changes it should always bail unless the command does not touch the git repository.
I like "always return to where you were before end of operation" idea, but fwiw having an environmental variable that ensures chaos mode maybe also provides one additional safeguard in addition to "sending you back where you were":
it also prevents you from accidentally running
abra cmdorabra secretusing different code than you intended (which could happen in the "always return" model)I like it to, the ideal outcome would be to never have the repo in detached HEAD unless doing that manually. The main problem is that we are not used to this state and wouldn't choose it consciously. So we should make sure it just doesn't happen.
Related: #742