Documentation
¶
Overview ¶
Package gitcommit commits the files a selfdoc command generated.
Commands that write into the project directory -- `gen`, `layout migrate`, the post-build hash updates -- offer to commit what they wrote. The commit goes through rlsbl when it is installed (its Autogenerated trailer exempts the commit from changelog coverage), then safegit, then plain git, and is guarded against loops through the SELFDOC_AUTO_COMMIT environment variable: a git hook that runs selfdoc cannot start a commit of its own.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AutoCommit ¶
func AutoCommit(files []string, message, cwd string, h *effects.Handle) (committed bool, unsettled bool, err error)
AutoCommit commits files in the git repository at cwd with message.
committed reports whether a commit was made. unsettled reports that the commit was RECORDED rather than performed, which is what a handle in preview mode does with it; committed is then false, because nothing was committed. The returned error is non-nil when the commit was attempted and failed: the commit tool (or git add and git commit) exited nonzero, timed out, or could not be started. The error names the tool and carries its own stderr, so the command that asked for the commit fails instead of exiting 0 with its files left uncommitted. It is non-nil too when the effects handle itself fails. A probe that cannot answer and a working tree with nothing to commit are reported as committed false with no error.
Nothing is committed when:
- SELFDOC_AUTO_COMMIT is set, so a git hook running selfdoc cannot loop;
- cwd is not inside a git repository;
- every named file is unchanged, or untracked and gitignored.
A tracked file is committed whether or not it matches a gitignore pattern (gitignore governs untracked files only), and a tracked file missing from disk is committed as a deletion.
Types ¶
This section is empty.