dirsh

Crates.iodirsh
lib.rsdirsh
version0.2.0
sourcesrc
created_at2020-05-04 20:34:07.153092
updated_at2020-07-02 22:09:37.019026
descriptionIgnore-file-respecting consistent hasher of directory contents
homepage
repositoryhttps://github.com/christian-blades-cb/dirsh
max_upload_size
id237539
size19,023
Christian Blades (christian-blades-cb)

documentation

README

dirsh

built with nix

Dirsh hashes the contents of a directory, but respects your .gitignore file and its own .hashignore.

Motivation

Hashing the inputs of a build is a convenient way to avoid rebuilding. Current solutions to this problem are either domain-specific, or lack a convenient way to configure which files should be included in the hash.

Usage

By default, dirsh hashes the current directory. .gitignore and .hashignore are parsed in the gitignore spec and used for filtering.

Dirsh calculates the md5 for the directory contents and returns the hash in base32 without padding.

$ dirsh -h
dirsh 0.2.0
Ignore-file-respecting consistent hasher of directory contents

USAGE:
    dirsh [FLAGS] [paths]...

FLAGS:
    -h, --help            Prints help information
        --no-gitignore    don't parse gitignore (including global gitignore and local git excludes)
    -V, --version         Prints version information

ARGS:
    <paths>...     [default: ./]

The algorithm

Paths are recursively walked in alphabetical order.

File contents are fed to the digest, followed by 64 bits of modification time, and 32 bits of mode.

The md5 hash is then computed and base32 encoded without padding (for ease of url encoding, and compatibility with filesystems which ignore capitalization).

Development

This project is built with nix, and the development environment is available with nix-shell, or even better, lorri.

You can build the release binary with nix-build.

Without nix

This is a standard rust project. You'll need the rust toolchain to build this project.

cargo build

Commit count: 9

cargo fmt