NAME

Dist::Conformance::Snapshot - What a check can read of a repository: its paths, their blob SHAs and their contents

VERSION

version 0.001

SYNOPSIS

use 5.040;
use Dist::Conformance::Snapshot::Directory;

my $snapshot = Dist::Conformance::Snapshot::Directory->new( root => '/bogus/checkout' );
say 'has a profile' if $snapshot->contains('.perlcriticrc');
say $snapshot->sha('git-hooks/pre-commit') // 'no hook';
my $text = $snapshot->content('CLAUDE.md');

DESCRIPTION

A check never touches a repository directly. It reads a snapshot, which answers two questions: which paths exist, each with its git blob SHA, and what the content of one path is. So the same check runs against a local checkout, through Dist::Conformance::Snapshot::Directory, and against a repository that only an API can reach, through Dist::Conformance::Snapshot::Tree.

This class is the interface. A subclass implements "paths" and "content"; everything else here is built on those two. A snapshot that a check can also change is writable: Dist::Conformance::Snapshot::Directory is the only one, and it adds write and install_hook.

Paths are relative to the root of the repository, with / between the components, as git writes them. A snapshot lists files and symbolic links, not directories.

METHODS

paths

Returns a hash reference from each path to its git blob SHA, in lowercase hex. A subclass must implement it.

content

($path). Returns the bytes of the file at $path, or undef if the snapshot has no such path. A subclass must implement it.

contains

($path). Whether the snapshot has a file at $path.

sha

($path). The git blob SHA of $path, or undef.

under

($directory). The paths inside $directory, at any depth, relative to it and sorted.

writable

Whether a check can change this snapshot. False here.

FUNCTIONS

blob_sha

($bytes). The SHA that git gives a blob with this content, the same as git hash-object prints. So a check can compare a template with a file in a snapshot that it never downloaded.

WRITING A SNAPSHOT

Subclass this module, and implement "paths" and "content". Both can be lazy, and both can memoize, because a snapshot describes one moment of one repository. "contains" and "sha" call "paths". If listing every path costs much more than looking at one, override them as well.

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.