zk
zk copied to clipboard
Refactor tilde expansion
We added tilde expansion for note.template so users can share template files between notebooks in https://github.com/zk-org/zk/pull/431.
We however overlooked that tilde / home dir expansion was already being implemented in isolation for the global notebook directory in container.go.
I've refactored that code into the function @WhyNotHugo created, and also made a few optimisations to it (and renamed it as it now expands more than just tildes).
Otherwise, am I overlooking anything, have I overdone / underdone anything, or is it looking alright?
I'm really stumped by the failing tesh test.. It's not failing on my end. I've double checked that there have been no changes between my local branch and this remote branch...
I've tried make tesh-update, but no change.
...
OK neuron.tesh
PASSED 64 tests
make tesh-update passes CI.
make tesh does not.
Might help you to tag the right Hugo if you want constructive feedback 😄 (Not a complaint/criticism, just you may actually want them to see this.)
woops! thanks 😅 haha
Suspicions were correct. GitHub CI doesn't have $HOME set. So checking directly for os.UserHomeDir() was breaking GitHub CI, while it was passing fine locally.
Solution is then exactly as @WhyNotHugo did it 😅. First check for os.CurrentUser(), which seemingly works for GitHub CI and then access the HomeDir field of the returned struct. It does not error if there is none, so the function continues executing fine and the path string passed to ExpandHomeDir() is returned unchanged.
I guess there was no issue using os.UserHomeDir() here in container.go, because there were no tesh cases for it. That threw me off for a while...
P.S The force push was just hard resetting to the previous commit in a lazy way... I know it's bad...