refactor: cut remaining long comments down to what the code does
This commit is contained in:
1 parent
0cbb65c684
commit
cb6b8618c2
141 files changed
+610
-2622
No files matched your search
@@ -22,29 +22,8 @@ func MarkSafe(ctx context.Context, mountDir string, log *slog.Logger) bool {
|
||||
return markSafe(ctx, mountDir, runGit, log)
|
||||
}
|
||||
|
||||
// markSafe adds mountDir to git's global safe.directory list.
|
||||
//
|
||||
// The daemon bind-mounts the task worktree into the container from the host,
|
||||
// so the directory is owned by a UID the container user is not. Git refuses to
|
||||
// operate in a repository it does not own ("detected dubious ownership"), and
|
||||
// the Go toolchain shells out to git for VCS stamping during build/test/vet --
|
||||
// so without this every gate fails before the agent does any real work.
|
||||
//
|
||||
// Best-effort by design: git may be absent from a minimal image, and an agent
|
||||
// working a repo with no gate commands never needs it. A failure is logged and
|
||||
// the agent continues. Returns true only when git accepted the configuration.
|
||||
//
|
||||
// The guard is existence, not mount-ness: os.Stat confirms mountDir exists and
|
||||
// is a directory, which prevents a misconfigured archie-agent from writing to
|
||||
// the operator's own ~/.gitconfig for a workspace path that was never mounted.
|
||||
// Mandatory task boot metadata independently rejects non-task workers before
|
||||
// they subscribe. This check does not detect a
|
||||
// stale directory that happens to exist at the same path without actually
|
||||
// being a bind mount -- a real mount check would need platform-specific
|
||||
// parsing (e.g. /proc/self/mountinfo on Linux) that this deliberately does
|
||||
// without. The failure mode is inert: git only rejects operations in a
|
||||
// directory that both exists at this path and is a real repository, and
|
||||
// safe.directory entries for a stale non-repo path do nothing.
|
||||
// markSafe adds mountDir to git's global safe.directory when it is an
|
||||
// existing directory. Failures are logged. Returns true on success.
|
||||
func markSafe(ctx context.Context, mountDir string, run gitRunner, log *slog.Logger) bool {
|
||||
info, err := os.Stat(mountDir)
|
||||
if err != nil || !info.IsDir() {
|
||||
|
||||
Reference in new issue
Block a user