Documentation
¶
Overview ¶
Package gitguard finds what git on this machine runs, or reads, from the folders a VM can write: hooks, and commands its config names. The VM can write the project and the writable volumes; git runs hooks and commands from paths anywhere, in the repository's own share, in another share (core.hooksPath into a volume), or from git's own config kept in one. Each path is followed through every symlink on the way, and checked against every share.
Index ¶
Constants ¶
const ( BareOK = "ok" BareUnset = "unset" BareOld = "old" // git before 2.38, which ignores the setting BareNoGit = "nogit" )
Bare-repository states.
const BareHint = `Git treats any folder with HEAD, objects/ and refs/ as a repository, even without .git, and runs commands its config names (on ` + "`git log`" + `, for one). A VM could create one in your projects, and the .git protection does not cover it.
This makes git ignore such folders unless named with --git-dir:
git config --global safe.bareRepository explicit
`
BareHint is why the setting matters and how to set it, one paragraph per line.
Variables ¶
This section is empty.
Functions ¶
func BareState ¶
BareState is whether git on this machine ignores bare repositories it is not told about. Read from /, outside any repository: git only honours the setting from the system and global config.
func HooksName ¶
HooksName is the name that keeps the hooks folder rel read-only: its first component, which covers the folder and what it calls next to it (husky's hooks call .husky/<hook>). False for the project itself, and for a name the shares cannot carry.
Types ¶
type Result ¶
type Result struct {
// Hooks are the hooks folders, or links on the way to them, in a share
// and outside the names always listed, each once: where (relative to
// the project when it is there, else absolute), a tab, then what names
// it (see HooksName): relative to the top of its repository when that
// is in a share, else to the share; "." when no name covers it (a share
// itself, or a name at or above the root of the share holding it),
// empty for a name no share can carry.
Hooks []string
// contains filtered or unexported fields
}
Result is what git on this machine runs, or reads, from the shares.
func Scan ¶
Scan is what git on this machine runs, or reads, from the shares (see Shares; the project first). home is the user's home folder.
func (*Result) Lines ¶
Lines are the hooks folders and the risks, every hooks name accepted, as 0.2 printed them: "H\t" or "R\t" and the rest.
func (*Result) Names ¶
Names are the names always listed, then those keeping every hooks folder read-only, each once: the names when every one is accepted.
func (*Result) Risks ¶
Risks are the risks to accept, as text, each once, when the shares get names (the names always listed, and the hooks names accepted): a config file in a share, a setting whose command is in one, a hook linked to a file in one, a share with more repositories than are checked, something git could not be asked about (an error, no answer in time). What a name keeps read-only is no risk; a declined hooks name keeps nothing.