Repository navigation
feat: version control awareness; --commit flag for commands which change files - #2861
simonmichael wants to merge 1 commit into
Conversation
…nge files hledger now notices when the journal is in a jj or git repository (the nearest one at or above the main journal file's directory; jj is preferred when a directory has both). setup shows whether the journal is version controlled, whether all of its files are tracked, and whether they have unrecorded changes. add, import, get, init and hledger-web have a new --commit flag. After changing files, they commit just the files they changed, with a descriptive message, like "hledger import: 12 new transactions from bank.csv.rules", leaving other changes in the repository alone. If a changed file already had unrecorded changes, those are included, and hledger says so. With --dry-run, the message is shown. Without a repository (or its tool), --commit is an error, and nothing is changed. To commit by default, add --commit to a config file. The manual has a new Version control section. The design and implementation notes are in doc/PLAN-vcs.md. AI usage: Claude Fable 5.2/Opus 5.5, ~84k output tokens
|
Everybody's workflow is different; but I thought more about my own usage. I import most days, but that's not when I commit. I almost always do additional followup or unrelated manual edits first. Such as:
So I'm adding entries manually in emacs, and/or doing an import, then I'm doing additional edits in emacs, and once or more per day I'm committing, usually with magit, occasionally with vscode or jj. And for vague reasons of wanting to avoid conflicts/keep history clear and compartmentalised, I usually do multiple separate commits - txns, accounts, rules, scripts, etc. So it feels rather repetitive and tedious, even though commits are quick with magit. (With a notable exception: if I strengthen precommit hooks to catch more breakages, including in the all-years journal, as I did recently, it adds a delay to each commit, which even if small makes committing noticeably slower and more bothersome.) So I could
Or there could be a Or, nothing: don't try to make hledger do this job. At least, not as a builtin. Here are the hledger-git and hledger-jj CLIs, for reference: |
|
What are some workflows where automatic committing might be more useful ?
I think that's all ? |
|
I think these parts of the PR might be worth keeping:
|
|
And this might be worth adding:
|
|
My two cents is that in my experience VCSes typically have lots of commands, switches, features, and if you wrap them expecting a handful of specific workflows, you would inevitable find yourself in a position where you cut users off of specific command, or a feature, or a way to use the VCS, and now you need to think about how to make your wrapper more open and more flexible... Like, if you have "hledger commit", then "hledger vcs status", and "hledger vcs commit --rebase-push" might be a reasonable ask as well. And so the slippery slope begins |
|
hledger-git/jj do indeed provide more commands -
They aimed to make version-controlling your hledger files practical for non-VCS people. But as for this PR, yes I think I'll just close it; we could revive it in future if we find more of a value proposition. |
(This will need some testing and discussion. Is it a good idea ? Or feature creep, better left out so there's a clean separation of concerns ?)
hledger now notices when the journal's files are in a jj or git repository, and can record its changes there.
--commitonadd,import,get,initand hledger-web: after changing files, commit just the files changed, with a descriptive message, eg:--commitis an error and nothing is changed. With--dry-run, the commit message is shown.addcommits once at the end of the session;getcommits per phase (data, prices); hledger-web commits each add, edit or upload, checking for a repository at startup.--committo a config file.The tools are run as external programs (no new dependencies). The manual has a new Version control section; the design and implementation notes are in doc/PLAN-vcs.md.
Tests: new hledger/test/vcs.test (git, and jj when installed), isolated from user git/jj configuration. setup's checks and hledger-web's commits were tested manually.
AI usage: Claude Fable 5.2/Opus 5.5, ~84k output tokens