#gitignore #git #embed

no-std gitignores

GitHub’s collection of gitignores, embedded, automatically updated

18 stable releases

2.5.1 Oct 18, 2024
2.4.0 Sep 20, 2024
2.3.3 Oct 28, 2023
2.3.2 May 11, 2022
1.0.1 Oct 14, 2021

#87 in Development tools

Download history 151/week @ 2024-07-29 9/week @ 2024-08-05 1/week @ 2024-08-12 3/week @ 2024-08-19 9/week @ 2024-08-26 2/week @ 2024-09-09 213/week @ 2024-09-16 69/week @ 2024-09-23 117/week @ 2024-09-30 39/week @ 2024-10-07 288/week @ 2024-10-14 29/week @ 2024-10-21 4/week @ 2024-10-28 18/week @ 2024-11-04

340 downloads per month
Used in 6 crates (3 directly)

CC0 license

265KB
2K SLoC

Crate release version Crate license: CC0-1.0 MSRV: 1.37.0 (breaking) CI status

Gitignores

GitHub’s collection of gitignores, embedded, automatically updated.

Quick start

[dependencies]
gitignores = "1.0.0"
dbg!(gitignores::Root::Rust);

API

Each gitignore is available as a variant of one of three enums:

(
	gitignores::Root::Rust,
	gitignores::Global::Emacs,
	gitignores::Community::Racket,
)

The enums implement Display / .to_string(), which will return the contents of the gitignore (only when the std feature is enabled):

println!("{}", gitignores::Root::Rust);
gitignores::Global::Emacs.to_string();

The enums also implement a GitIgnore trait:

trait GitIgnore {
	/// The contents of the gitignore
	///
	/// Returns an empty string if the `no-contents` feature is enabled.
	fn contents(self) -> &'static str;

	/// The file name of the gitignore
	fn file_name(self) -> &'static str;

	/// The full path of the gitignore relative to repo root
	fn file_path(self) -> &'static str;

	/// The list of all included gitignores
	fn list() -> Vec<&'static str>;
}

Finally, there is a constant with the git reference of the commit the crate was built from:

dbg!(gitignores::GIT_COMMIT_REF);

Features

By default all gitignores are included, but you can customise this as granularily as you wish. To get started with selecting your custom set, first disable the default features:

[dependencies.gitignores]
default-features = false
features = []

Collections

Feature name Path in gitignore repo Path in crate
root /*.gitignore Root::
global /Global/**/*.gitignore Global::
community /community/**/*.gitignore Community::

Individual gitignores

Each gitignore can be enabled with the <collection>-<name> feature. Gitignores in subfolders have the folder name prepended to the name, like <collection>-<folder>-<name>. All are lowercased.

Other

  • no-contents: omit the embedded file contents, leaving only the metadata.
  • std: implement the Display trait on the enums.

Examples

All globals and only Rust root

[dependencies.gitignores]
default-features = false
features = ["global", "root-rust"]

Some specific gitignores

[dependencies.gitignores]
default-features = false
features = ["community-racket", "global-emacs", "root-commonlisp"]

Versioning

This crate respects semver!

It will bump the major version (breaking release) when:

  • Gitignores disappear from a collection
  • Gitignores move from a collection to another
  • Gitignores are renamed
  • The minimum required Rust version increases

It will bump the minor version when:

  • New gitignores are added to a collection

It will bump the patch version when:

  • Gitignore contents change

This repo checks for updates to the gitignore repo once a day, and automatically releases if changes are found.

License

The published crate (gitignores) is generated from the data, which is CC0-1.0, and so it itself is CC0-1.0 (Public Domain).

The generator code is Apache 2.0 / MIT.

No runtime deps

Features