Contributing

Contribution to Minitar is encouraged: bug reports, feature requests, or code contributions. New features should be proposed and discussed in an issue.

Before contributing patches, please read the Licence.

Minitar is governed under the Contributor Covenant Code of Conduct.

Code Guidelines

I have several guidelines to contributing code through pull requests:

AI Contribution Policy

Minitar is a library that may have access to the underlying file system. It is extremely important that contributions of any sort be well understood by the submitter and that the developer can attest to the Developer Certificate of Origin for each pull request (see LICENCE).

Any contribution (bug, feature request, or pull request) that uses undeclared AI output will be rejected.

For an example of how this should be done, see #151 and its associated commits.

Commit Conventions

Minitar has adopted a variation of the Conventional Commits format for commit messages. The following types are permitted:

Type Purpose
feat A new feature
fix A bug fix
chore A code change that is neither a bug fix nor a feature
docs Documentation updates
deps Dependency updates, including GitHub Actions.

I encourage the use of Tim Pope’s or Chris Beam’s guidelines on the writing of commit messages

I require the use of git trailers for specific additional metadata and strongly encourage it for others. The conditionally required metadata trailers are:

Testing Minitar

Minitar uses Ryan Davis’s [Hoe][Hoe] to manage the release process, and it adds a number of rake tasks. You will mostly be interested in rake, which runs the tests the same way that rake test will do.

To assist with the installation of the development dependencies for Minitar, I have provided the simplest possible Gemfile pointing to the (generated) minitar.gemspec file. This will permit you to do bundle install to get the development dependencies.

You can run tests with code coverage analysis by running rake coverage.

Minitar includes a number of custom test assertions, constants, and test utility methods that are useful for writing tests. These are maintained through modules defined in test/support.

Fixture Utilities

Minitar uses fixture tarballs in various tests, referenced by their base name (test/fixtures/tar_input.tar.gz becomes tar_input, etc.). There are two utility methods:

Header Assertions and Utilities

Tar headers need to be built and compared in an exacting way, even for tests.

There are two assertions:

expected must be a string representation of the expected header and this assertion calls to_s on the actual value so that both PosixHeader and PaxHeader instances are converted to string representations for comparison.

There are several other helper methods available for working with headers:

Tarball Helpers

Minitar has several complex assertions and utilities to work with both in-memory and on-disk tarballs. These work using two concepts, file hashes (file_hash) and workspaces (workspace).

File Hashes (file_hash)

Many of these consume or produce a file_hash, which is a hash of {filename => content} where the tarball will be produced with such that each entry in the file_hash becomes a file named filename with the data content.

As an example, Minitar::TestHelpers has a MIXED_FILENAME_SCENARIOS constant that is a file_hash:

MIXED_FILENAME_SCENARIOS = {
  "short.txt" => "short content",
  "medium_length_filename_under_100_chars.txt" => "medium content",
  "dir1/medium_filename.js" => "medium nested content",
  "#{"x" * 120}.txt" => "long content",
  "nested/dir/#{"y" * 110}.css" => "long nested content"
}.freeze

This will produce a tarball that looks like:

short.txt
medium_length_filename_under_100_chars.txt
dir1/medium_filename.js
x[118 more 'x' characters...]x
nested/dir/y[108 more y' characters...]y.css

Each file will contain the text as the content.

If the content is nil, this will be ignored for in-memory tarballs, but will be created as empty directory entries for on-disk tarballs.

Workspace (workspace)

A workspace is a temporary directory used for on-disk tests. It is created with the workspace utility method (see below) and must be passed a block where all setup and tests will be run.

At most one workspace may be used per test method.

Assertions

There are five assertions:

In-Memory Tarball Utilities

On-Disk Workspace Tarball Utilities

A workspace has a source directory, a target directory, and thetarball` which will be created from the prepared files.

All other utility methods must be run inside of a workspace block.