sane

command module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2022 License: MIT Imports: 4 Imported by: 0

README

Sane: Validate Repository Structure

A Git repository structure validation tool that follows a gitignore like syntax to define a desired repository structure.

TL;DR

Quick install

go install github.com/abhisek/sane@latest

Create a .sane file declaring the acceptable repository structure in repository root

README.md
docs/*.md
docs/**/*.png
main.go
cmd/**/*.go
pkg/**/*.go

Run sane to validate the current repository structure based on .sane file

sane validate

On successful validation, exit code is 0.

Things to note
  1. Current directory is picked for validation by default
  2. Target directory for validation must be a git repository
  3. Validation rules are picked from .sane in current directory by default
  4. Only git objects are validated, ignoring unstaged or git ignored paths

Using Docker

docker run -v `pwd`:/app ghcr.io/abhisek/sane:latest -p /app

Multi-arch container image support is work in progress.

Usage

Normal Mode

Run sane in normal mode where it will validate any file observed in the repository against the rules in .sane file found in the root of the directory

./sane -p /path/to/dir
Strict Mode

Run sane in strict mode to ensure that every rule in .sane file must have at least one match. This mode helps ensure that required files are created and available in the repository. For example, in strict mode, sane will fail if README.md is declared in .sane file but does not exist in the repository root.

./sane --strict -p /path/to/dir
Other options

Optionally provide a rules path instead of the default .sane

./sane -p /path/to/dir -r /path/to/dir/rules/sane.rules

Rules Format

The .sane rules format is syntactically similar to .gitignore but semantically inverse. Refer to RULE.spec.md for details.

FAQ

Why couple with a Git repository?

The rule engine is capable of validating any file path against he rules. As such the rules are not coupled with a git repository. However, this tool seems to be useful within the scope of a Git (or equivalent) repository while ignoring the unstaged or ignored files.

Why use .gitignore style rules?

To reduce cognitive load of learning another format and re-use conventional syntax of gitignore but in an inverse context i.e. .sane rules define what is acceptable instead of what should be ignored. Refer RULE.spec.md for more information on rule format

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL