Parse::Gitignore(3)
πΈ NAME πΈ
Bestie, welcome to Parse::Gitignore(3) from the User Contributed Perl Documentation crew π. This is the manual page for Parse::Gitignore β and the whole main-character job is: parse .gitignore files. Periodt.
β¨ SYNOPSIS β¨
Okay so here's the synopsis, and we are keeping every character exactly, no cap:
use FindBin '$Bin';
use Parse::Gitignore;
chdir "$Bin/../" or die $!;
my $gitignore = Parse::Gitignore->new (".gitignore");
for my $file ('examples/synopsis.pl', 'MANIFEST') {
if ($gitignore->ignored ($file)) {
print "$file is ignored.\n";
}
else {
print "$file is not ignored.\n";
}
}
And it produces output:
examples/synopsis.pl is not ignored.
MANIFEST is ignored.
(This example is included as synopsis.pl (https://fastapi.metacpan.org/source/BKB/Parse-Gitignore-1.0/examples/synopsis.pl) in the distribution.) π¦
π¦ VERSION π¦
This documents Parse::Gitignore version 1.0 corresponding to git commit 66d95b057677120fce6309993e9f9324d2d665ab (https://github.com/benkasminbullock/parse-gitignore/commit/66d95b057677120fce6309993e9f9324d2d665ab) released on Tue Nov 12 06:23:43 2024 +0900. Iconic timestamp behavior, honestly.
π DESCRIPTION π
Parse a .gitignore file and check whether a file matches it. That's the vibe check, and it ate. π
π METHODS π
new
my $pg = Parse::Gitignore->new ('./.gitignore');
To get messages on what it is doing, set "verbose" to a true value:
my $pg = Parse::Gitignore->new ('./.gitignore', verbose => 1);
Ngl, verbose is your little behind-the-scenes narrator π«Ά.
ignored
if ($pg->ignored ('./Makefile')) {
print "Makefile is ignored.\n";
}
Check whether a file matches a .gitignore. Literally the whole point, bestie β¨.
read_gitignore
$pg->read_gitignore ('.gitignore');
Read a .gitignore file. Because different directories in the same git repository may feature their own .gitignore files, the information is accumulated in $pg along with the specific directory of the gitignore file relative to the top directory of the repository, for example:
$pg->read_gitignore ("$top/.gitignore");
$pg->read_gitignore ("$top/src/.gitignore");
If the suggested .gitignore does not actually exist, a warning is printed and processing continues. If the argument is a directory, the module assumes that you intended to read a file called .gitignore in that directory. Lowkey helpful π§.
excludesfile
$pg->excludesfile ('/home/user/.gitignore');
Read an excludesfile which is applied to all directories where .git is found. Slay π.
π₯ DEPENDENCIES π₯
Carpβ used to report errors."read_lines" in File::Slurperβ used to read the gitignore file.File::Specβ used to disambiguate file path names.
π SEE ALSO π
"man gitignore"β (https://git-scm.com/docs/gitignore)"man git-check-ignore"β (https://git-scm.com/docs/git-check-ignore)
π HISTORY π
I wrote this because I wanted to have a way to ignore generated files for a desktop file search application. Fr fr, that's the origin story π.
Version 1.0 changes the way that subdirectories are dealt with. The older versions turned out to have a problem whereby files in subdirectories were not picked up correctly. Not me fixing the subdirectory situation and making it everyone's problem πβ¨.
π AUTHOR π
Ben Bullock, <benkasminbullock@gmail.com> π«Ά
π COPYRIGHT & LICENCE π
This package and associated files are copyright (C) 2016-2024 Ben Bullock.
You can use, copy, modify and redistribute this package and associated files under the Perl Artistic Licence or the GNU General Public Licence. π
Okay bestie, that's the whole page π
β this footer energy is perl v5.40.0, dated 2024-11-14, and the page is Parse::Gitignore(3). Go forth and ignore files with main character energy β¨π
π¦ where this page comes from
- epel 10: perl-Parse-Gitignore 1.0-1.el10_0 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms