NAME
Dist::Conformance::Snapshot::Directory - A snapshot of a checkout on this machine, which an update can change
VERSION
version 0.002
SYNOPSIS
use 5.040;
use Dist::Conformance::Snapshot::Directory;
my $snapshot = Dist::Conformance::Snapshot::Directory->new( root => '/bogus/checkout' );
$snapshot->write( '.perltidyrc', "-l=400\n" );
$snapshot->write( 'git-hooks/pre-commit', "#!/bin/sh\n", 0755 );
$snapshot->install_hook( 'pre-commit', "#!/bin/sh\n" );
DESCRIPTION
The working tree of a checkout, as it is on disk now: not the index, and not a commit. Nothing is cached, so a check that runs after an update sees what the update wrote.
"paths" walks the whole tree except each .git, and hashes every file. "contains" in Dist::Conformance::Snapshot, "sha" in Dist::Conformance::Snapshot and "content" look at one file only.
Every path that this class takes is relative to "root". It dies on an absolute path and on a path with a .. component, so that a flavor cannot make an update write outside the checkout.
ATTRIBUTES
root
Required. The directory of the checkout.
METHODS
new
Dies unless "root" is a directory.
file
($path). The Mojo::File of $path under the root. Dies on a path that leaves the root.
paths
Every file and symbolic link below the root, except inside .git, with its blob SHA. A symbolic link is hashed as git hashes it, by its target.
contains
($path). Whether $path is a file or a symbolic link.
sha
($path). The blob SHA of the one file, or undef.
content
($path). The bytes of the file, or undef. For a symbolic link, the bytes of what it points at.
writable
True.
write
($path, $bytes, $mode). Writes $bytes to $path through a temporary file and a rename, so that no reader sees half a file. Makes the missing directories. $mode defaults to 0644.
hooks_dir
The directory that git runs the hooks of this checkout from, or undef when the root is not a checkout. In a worktree that is the hooks of the main checkout. core.hooksPath is not read.
installed_hook
($name). The bytes of the hook $name that git runs now, or undef.
install_hook
($name, $bytes). Writes the hook $name into "hooks_dir", executable. Dies when the root is not a checkout.
SEE ALSO
Please see those modules/websites for more information related to this module.
BUGS
Please report any bugs or feature requests on the bugtracker website https://github.com/Troglodyne-Internet-Widgets/Dist-Conformance/issues
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
AUTHORS
Current Maintainers:
George S. Baugh <george@troglodyne.net>
COPYRIGHT AND LICENSE
Copyright (c) 2026 Troglodyne LLC
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.