Skip to content
internal/gitcommit
On this page

Committing the files a selfdoc command generated, preferring rlsbl, then safegit, then plain git, guarded so a hook that runs selfdoc cannot start a loop.

#internal/gitcommit

#internal/gitcommit

Package gitcommit commits the files a selfdoc command generated.

Commands that write into the project directory -- gen, check, 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.

#AutoCommit

Go go
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 never the repository's -- a missing git, a timed-out probe, a failing commit tool and a working tree with nothing to commit are all reported as committed false, with the tool's own stderr forwarded to this process's stderr. It is non-nil only when the effects handle itself fails, which a live run cannot do.

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.

Search