Crates.io | gitignores |
lib.rs | gitignores |
version | 2.5.1 |
source | src |
created_at | 2021-10-07 15:33:23.487037 |
updated_at | 2024-10-18 13:46:09.727047 |
description | GitHub’s collection of gitignores, embedded, automatically updated |
homepage | https://watchexec.github.io/#gitignores |
repository | https://github.com/watchexec/gitignores |
max_upload_size | |
id | 461833 |
size | 264,687 |
GitHub’s collection of gitignores, embedded, automatically updated.
[dependencies]
gitignores = "1.0.0"
dbg!(gitignores::Root::Rust);
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);
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 = []
Feature name | Path in gitignore repo | Path in crate |
---|---|---|
root |
/*.gitignore |
Root:: |
global |
/Global/**/*.gitignore |
Global:: |
community |
/community/**/*.gitignore |
Community:: |
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.
no-contents
: omit the embedded file contents, leaving only the metadata.std
: implement the Display
trait on the enums.[dependencies.gitignores]
default-features = false
features = ["global", "root-rust"]
[dependencies.gitignores]
default-features = false
features = ["community-racket", "global-emacs", "root-commonlisp"]
This crate respects semver!
It will bump the major version (breaking release) when:
It will bump the minor version when:
It will bump the patch version when:
This repo checks for updates to the gitignore repo once a day, and automatically releases if changes are found.
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.