Regexp::Pattern::Git - Regexp patterns related to git
This document describes version 0.002 of Regexp::Pattern::Git (from Perl distribution Regexp-Pattern-Git), released on 2020-03-26.
use Regexp::Pattern; # exports re() my $re = re("Git::ref");
Regexp::Pattern is a convention for organizing reusable regex patterns.
ref
Valid reference name.
This single regex pattern enforces the rules defined by the git-check-ref-format manpage, reproduced below:
Examples:
"foo/bar" =~ re("Git::ref"); # matches
A slash-separated component begins with dot (rule 1).
".foo/bar" =~ re("Git::ref"); # doesn't match
"foo/.bar" =~ re("Git::ref"); # doesn't match
A slash-separated component ends with ".lock" (rule 1).
"foo.lock/bar" =~ re("Git::ref"); # doesn't match "foo.locker/bar" =~ re("Git::ref"); # matches
"foo/bar.lock" =~ re("Git::ref"); # doesn't match
"foo/bar.lock/baz" =~ re("Git::ref"); # doesn't match "foo/bar.locker/baz" =~ re("Git::ref"); # matches
Does not contain at least one / (rule 2).
"foo" =~ re("Git::ref"); # doesn't match
Contains two consecutive dots (rule 3).
"foo../bar" =~ re("Git::ref"); # doesn't match
Contains colon (rule 4).
"foo:/bar" =~ re("Git::ref"); # doesn't match
Contains question mark (rule 5).
"foo?/bar" =~ re("Git::ref"); # doesn't match
Contains open bracket (rule 5).
"foo[2]/bar" =~ re("Git::ref"); # doesn't match
Begins with / (rule 6).
"/foo/bar" =~ re("Git::ref"); # doesn't match
Ends with / (rule 6).
"foo/bar/" =~ re("Git::ref"); # doesn't match
Contains multiple consecutive slashes.
"foo//bar" =~ re("Git::ref"); # doesn't match
Ends with . (rule 7).
"foo/bar." =~ re("Git::ref"); # doesn't match
Contains sequence @{ (rule 8).
"foo\@{/bar" =~ re("Git::ref"); # doesn't match
"foo\@{baz}/bar" =~ re("Git::ref"); # doesn't match
Cannot be single character @ (rule 9).
"\@" =~ re("Git::ref"); # doesn't match
release_tag
Common release tag pattern.
This is not defined by git, but just common convention.
Does not contain digit.
"release" =~ re("Git::release_tag"); # doesn't match 1 =~ re("Git::release_tag"); # matches "1.23-456-foobar" =~ re("Git::release_tag"); # matches "release-1.23" =~ re("Git::release_tag"); # matches "v1.23" =~ re("Git::release_tag"); # matches "ver-1.23" =~ re("Git::release_tag"); # matches
Please visit the project's homepage at https://metacpan.org/release/Regexp-Pattern-Git.
Source repository is at https://github.com/perlancar/perl-Regexp-Pattern-Git.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Regexp-Pattern-Git
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
Regexp::Pattern
Some utilities related to Regexp::Pattern: App::RegexpPatternUtils, rpgrep from App::rpgrep.
perlancar <perlancar@cpan.org>
This software is copyright (c) 2020 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Regexp::Pattern::Git, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Regexp::Pattern::Git
CPAN shell
perl -MCPAN -e shell install Regexp::Pattern::Git
For more information on module installation, please visit the detailed CPAN module installation guide.