edhil commit
edhil commit
edhil commit [ISSUE] [--no-edit] [--no-agent] [--agent NAME] [--no-input]
Commits the staged changes, or all changes, with a message that follows the same format as the messages of runs. The agent drafts the message, you edit it, edhil checks it and makes the commit. Use it for the work you do yourself: fixing the result of a pause, a review finding, a change that was never a work item.
commit is not a run. It takes the repository lock, so it cannot run at the same time as implement, but it writes nothing to the journal. It works from any directory of the repository, also with a detached HEAD.
What is committed
If something is staged, exactly that is committed and nothing else is touched. If nothing is staged, all changed and new files are staged first (never .edhil/). If there is nothing at all, the command fails with Nothing to commit and the agent is not asked.
The files are listed before anything else:
Committing 2 files:
M src/lib.rs
A src/limit.rs
The draft
edhil gives the agent the output of git diff --cached --stat and asks for a title and a short description. The agent runs with the same git program in front of its PATH as in a run, and it may not change anything. edhil compares the repository before and after:
- The comparison looks at the content of every changed file (the object id that git gives it) and at its mode, so a change of one byte or of the executable bit is seen too.
- If the repository has unresolved conflicts (after a merge, say), the command cannot compare anything. It stops before it asks the agent, names some of the conflicting files and tells you to resolve them first.
- If the agent made a commit, it is undone and the draft is used.
- If anything else is different (a file, the staged changes, the branch), the command stops with exit code 1 and lists what differs. Nothing is committed and nothing is restored: look at
git statusfirst. - If the agent fails, takes too long or gives an answer that cannot be used, the editor opens on an empty message with a note that says why. The command is never worse than
git commit.
The editor
The editor is the one git would use: GIT_EDITOR, core.editor, VISUAL, EDITOR, then vi. It opens on a file with the draft and, below it, lines that start with #: the notes, the rules, the shape of the message and the files that will be committed. The # lines are removed afterwards.
Add a limit to the retries.
The loop stops after three tries and reports the last error.
Issues: None
- The title is one line and ends with a full stop (edhil adds one to a draft that has none). Then a blank line, a description of 1 to 10 lines, a blank line and the
Issues:line. - An empty message ends the command:
The message is empty.,Nothing was committed., exit code 1. - A message that is not valid shows the reason and asks
(e)dit again or (a)bort?.eopens the editor again on your text with the reason added; anything else gives up. The changes stay staged. - A valid message is committed the same way as in a run, so the hooks of the repository run. The command prints
Committed 0123456: <title>. - If git or a hook refuses, the message is written to
.edhil/last-commit-message.txt, and the error says so and gives the path. Fix the problem and commit withgit commit -F .edhil/last-commit-message.txt, or run the command again.
The issue number
edhil commit 123 ends the message with Issues: #123. Without a number it ends with Issues: None, which is valid for commits that belong to no work item.
Options
| Option | Meaning |
|---|---|
ISSUE |
The work item the commit belongs to, such as 123 or '#123'. |
--no-edit |
Commit the drafted message without opening the editor. It fails, and says why, when there is no draft. This is the only way to commit without a terminal. |
--no-agent |
Do not ask the agent. The editor opens on an empty message with the Issues: line in place. The configuration file is not read, so it works without one. |
--agent NAME |
Ask this agent for the draft instead of the one in integration.agent. See implement for the names. It cannot be combined with --no-agent. |
--no-input |
Never ask a question. Editing is a question, so it needs --no-edit as well. |
Without a terminal, and without --no-edit, the command fails before it asks the agent anything.
Exit codes
0 when the commit was made. 1 for everything else: nothing to commit, an agent that changed the repository, an empty or refused message, a hook that refused. 2 for a wrong command line. 130 for Ctrl-C while the agent works.