Git-Version-Compare-1.005/0000755000175000017500000000000014360467237013733 5ustar bookbookGit-Version-Compare-1.005/LICENSE0000644000175000017500000004370614360467237014752 0ustar bookbookThis software is copyright (c) 2023 by Philippe Bruhat (BooK). This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2023 by Philippe Bruhat (BooK). This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2023 by Philippe Bruhat (BooK). This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End Git-Version-Compare-1.005/Changes0000644000175000017500000000215614360467237015232 0ustar bookbookRevision history for Git-Version-Compare 1.005 2023-01-14 BOOK - Accepts Git non-standard version suffixes (GNUSTAVO) 1.004 2016-05-24 BOOK - Remove a dependency on namespace::clean - Update the cache using the normalized version string - Ignore minor versions of special builds (msysgit, windows, etc.) - Ensure the tests do not throw any warning - Add a few more version numbers to the tests 1.003 2016-05-03 BOOK - Added support for version strings with comments (thanks to PINE) 1.002 2016-04-27 BOOK - Increased the test coverage (from ~400 to ~11000 unit tests) 1.001 2016-02-20 BOOK - Changed the internal format used for comparisons to fix an issue with version numbers like v1.5.3.7-1198-g467f42c - looks_like_git returns a boolean if the string looks like a git version - _normalize now dies if the version does not look like a git version 1.000 2016-02-19 BOOK - Git::Version::Compare takes the knowledge about Git version numbers that was accumulated while working on Git::Repository and offers it in a module that does not depend on Git::Repository Git-Version-Compare-1.005/Makefile.PL0000644000175000017500000000252614360467237015712 0ustar bookbook# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.024. use strict; use warnings; use 5.006; use ExtUtils::MakeMaker; my %WriteMakefileArgs = ( "ABSTRACT" => "Functions to compare Git versions", "AUTHOR" => "Philippe Bruhat (BooK) ", "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => 0 }, "DISTNAME" => "Git-Version-Compare", "LICENSE" => "perl", "MIN_PERL_VERSION" => "5.006", "NAME" => "Git::Version::Compare", "PREREQ_PM" => { "Carp" => 0, "Exporter" => 0, "strict" => 0, "warnings" => 0 }, "TEST_REQUIRES" => { "ExtUtils::MakeMaker" => 0, "File::Spec" => 0, "List::Util" => 0, "Test::More" => 0, "Test::NoWarnings" => 0 }, "VERSION" => "1.005", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "Carp" => 0, "Exporter" => 0, "ExtUtils::MakeMaker" => 0, "File::Spec" => 0, "List::Util" => 0, "Test::More" => 0, "Test::NoWarnings" => 0, "strict" => 0, "warnings" => 0 ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); Git-Version-Compare-1.005/dist.ini0000644000175000017500000000231214360467237015375 0ustar bookbookname = Git-Version-Compare author = Philippe Bruhat (BooK) license = Perl_5 copyright_holder = Philippe Bruhat (BooK) ; copyright_year = 2016-2023 [PkgVersion] [@Filter] -bundle = @Basic -remove = Readme [PruneFiles] filename = setup match = \.patch$ match = mess/.* match = cover_db [AutoPrereqs] [Prereqs] perl = 5.006 [Test::ReportPrereqs] [Prereqs / TestRequires] Test::NoWarnings = [MetaJSON] [MetaResources] repository.web = http://github.com/book/Git-Version-Compare repository.url = http://github.com/book/Git-Version-Compare.git repository.type = git bugtracker.web = http://rt.cpan.org/NoAuth/Bugs.html?Dist=Git-Version-Compare bugtracker.mailto = bug-git-version-compare@rt.cpan.org [MetaTests] [PodSyntaxTests] [PodCoverageTests] [NextRelease] format = %v %{yyyy-MM-dd}d %P [@Git] changelog = Changes commit_msg = Changes for version %v tag_format = v%v tag_message = %N v%v push_to = origin push_to = github [Git::NextVersion] [Keywords] keywords = git version comparison [Meta::Contributors] contributor = Neil Bowers contributor = Pine Mizune contributor = Gustavo Leite de Mendonça Chaves Git-Version-Compare-1.005/META.yml0000644000175000017500000000206714360467237015211 0ustar bookbook--- abstract: 'Functions to compare Git versions' author: - 'Philippe Bruhat (BooK) ' build_requires: ExtUtils::MakeMaker: '0' File::Spec: '0' List::Util: '0' Test::More: '0' Test::NoWarnings: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 0 generated_by: 'Dist::Zilla version 6.024, CPAN::Meta::Converter version 2.150010' keywords: - git - version - comparison license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Git-Version-Compare requires: Carp: '0' Exporter: '0' perl: '5.006' strict: '0' warnings: '0' resources: bugtracker: http://rt.cpan.org/NoAuth/Bugs.html?Dist=Git-Version-Compare repository: http://github.com/book/Git-Version-Compare.git version: '1.005' x_contributors: - 'Neil Bowers ' - 'Pine Mizune ' - 'Gustavo Leite de Mendonça Chaves ' x_generated_by_perl: v5.32.1 x_serialization_backend: 'YAML::Tiny version 1.73' x_spdx_expression: 'Artistic-1.0-Perl OR GPL-1.0-or-later' Git-Version-Compare-1.005/META.json0000644000175000017500000000413614360467237015360 0ustar bookbook{ "abstract" : "Functions to compare Git versions", "author" : [ "Philippe Bruhat (BooK) " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 6.024, CPAN::Meta::Converter version 2.150010", "keywords" : [ "git", "version", "comparison" ], "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Git-Version-Compare", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "develop" : { "requires" : { "Pod::Coverage::TrustPod" : "0", "Test::CPAN::Meta" : "0", "Test::Pod" : "1.41", "Test::Pod::Coverage" : "1.08" } }, "runtime" : { "requires" : { "Carp" : "0", "Exporter" : "0", "perl" : "5.006", "strict" : "0", "warnings" : "0" } }, "test" : { "recommends" : { "CPAN::Meta" : "2.120900" }, "requires" : { "ExtUtils::MakeMaker" : "0", "File::Spec" : "0", "List::Util" : "0", "Test::More" : "0", "Test::NoWarnings" : "0" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "mailto" : "bug-git-version-compare@rt.cpan.org", "web" : "http://rt.cpan.org/NoAuth/Bugs.html?Dist=Git-Version-Compare" }, "repository" : { "type" : "git", "url" : "http://github.com/book/Git-Version-Compare.git", "web" : "http://github.com/book/Git-Version-Compare" } }, "version" : "1.005", "x_contributors" : [ "Neil Bowers ", "Pine Mizune ", "Gustavo Leite de Mendon\u00e7a Chaves " ], "x_generated_by_perl" : "v5.32.1", "x_serialization_backend" : "Cpanel::JSON::XS version 4.25", "x_spdx_expression" : "Artistic-1.0-Perl OR GPL-1.0-or-later" } Git-Version-Compare-1.005/README0000644000175000017500000000170014360467237014611 0ustar bookbookNAME Git::Version::Compare - Functions to compare Git versions SYNOPSIS use Git::Version::Compare qw( cmp_git ); # result: 1.2.3 1.7.0.rc0 1.7.4.rc1 1.8.3.4 1.9.3 2.0.0.rc2 2.0.3 2.3.0.rc1 my @versions = sort cmp_git qw( 1.7.4.rc1 1.9.3 1.7.0.rc0 2.0.0.rc2 1.2.3 1.8.3.4 2.3.0.rc1 2.0.3 ); DESCRIPTION Git::Version::Compare contains a selection of subroutines that make dealing with Git-related things (like versions) a little bit easier. The strings to compare can be version numbers, tags from "git.git" or the output of "git version" or "git describe". These routines collect the knowledge about Git versions that was accumulated while developing Git::Repository. COPYRIGHT AND LICENSE This software is copyright (c) 2016 by Philippe Bruhat (BooK). This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Git-Version-Compare-1.005/MANIFEST0000644000175000017500000000053014360467237015062 0ustar bookbook# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.024. Changes LICENSE MANIFEST META.json META.yml Makefile.PL README dist.ini lib/Git/Version/Compare.pm t/00-report-prereqs.dd t/00-report-prereqs.t t/author-distmeta.t t/author-pod-coverage.t t/author-pod-syntax.t t/cmp_git.t t/looks_like_git.t t/normalize.t t/ops.t Git-Version-Compare-1.005/lib/0000755000175000017500000000000014360467237014501 5ustar bookbookGit-Version-Compare-1.005/lib/Git/0000755000175000017500000000000014360467237015224 5ustar bookbookGit-Version-Compare-1.005/lib/Git/Version/0000755000175000017500000000000014360467237016651 5ustar bookbookGit-Version-Compare-1.005/lib/Git/Version/Compare.pm0000644000175000017500000002273714360467237020610 0ustar bookbookpackage Git::Version::Compare; $Git::Version::Compare::VERSION = '1.005'; use strict; use warnings; use Exporter; use Carp (); my @ops = qw( lt gt le ge eq ne ); our @ISA = qw(Exporter); our @EXPORT_OK = ( looks_like_git => map "${_}_git", cmp => @ops ); our %EXPORT_TAGS = ( ops => [ map "${_}_git", @ops ], all => \@EXPORT_OK ); # A few versions have two tags, or non-standard numbering: # - the left-hand side is what `git --version` reports # - the right-hand side is an internal canonical name # # We turn versions into strings, so we can use the fast `eq` and `gt`. # The 6 elements are integers padded with 0: # - the 4 parts of the dotted version (padded with as many .0 as needed) # - '.000' if not an RC, or '-xxx' if an RC (- sorts before . in ascii) # - the number of commits since the previous tag (for dev versions) # # The special cases are pre-computed below, the rest is computed as needed. my %version_alias = ( '0.99.7a' => '00.99.07.01.00.0000', '0.99.7b' => '00.99.07.02.00.0000', '0.99.7c' => '00.99.07.03.00.0000', '0.99.7d' => '00.99.07.04.00.0000', '0.99.8a' => '00.99.08.01.00.0000', '0.99.8b' => '00.99.08.02.00.0000', '0.99.8c' => '00.99.08.03.00.0000', '0.99.8d' => '00.99.08.04.00.0000', '0.99.8e' => '00.99.08.05.00.0000', '0.99.8f' => '00.99.08.06.00.0000', '0.99.8g' => '00.99.08.07.00.0000', '0.99.9a' => '00.99.09.01.00.0000', '0.99.9b' => '00.99.09.02.00.0000', '0.99.9c' => '00.99.09.03.00.0000', '0.99.9d' => '00.99.09.04.00.0000', '0.99.9e' => '00.99.09.05.00.0000', '0.99.9f' => '00.99.09.06.00.0000', '0.99.9g' => '00.99.09.07.00.0000', '0.99.9h' => '00.99.09.08.00.0000', # 1.0.rc1 '1.0.rc1' => '00.99.09.08.00.0000', '0.99.9i' => '00.99.09.09.00.0000', # 1.0.rc2 '1.0.rc2' => '00.99.09.09.00.0000', '0.99.9j' => '00.99.09.10.00.0000', # 1.0.rc3 '1.0.rc3' => '00.99.09.10.00.0000', '0.99.9k' => '00.99.09.11.00.0000', '0.99.9l' => '00.99.09.12.00.0000', # 1.0.rc4 '1.0.rc4' => '00.99.09.12.00.0000', '0.99.9m' => '00.99.09.13.00.0000', # 1.0.rc5 '1.0.rc5' => '00.99.09.13.00.0000', '0.99.9n' => '00.99.09.14.00.0000', # 1.0.rc6 '1.0.rc6' => '00.99.09.14.00.0000', '1.0.0a' => '01.00.01.00.00.0000', '1.0.0b' => '01.00.02.00.00.0000', ); sub looks_like_git { return scalar $_[0] =~ /^(?:v|git\ version\ )? # prefix [0-9]+(?:[.-](?:0[ab]?|[1-9][0-9a-z]*|[a-zA-Z]+))* # x.y.z.* (?:[.-]?[a-z]+[0-9]+)? # rc or vendor specific suffixes (?:[.-](GIT|[1-9][0-9]*[.-]g[A-Fa-f0-9]+))? # devel (?:\ .*)? # comment $/x; } sub _normalize { my ($v) = @_; return undef if !defined $v; # minimal consistency check Carp::croak "$v does not look like a Git version" if !looks_like_git($v); # reformat git.git tag names, output of `git --version` $v =~ s/^v|^git version |\.[a-zA-Z]+\..*|[\012\015]+\z//g; $v =~ y/-/./; $v =~ s/0rc/0.rc/; ($v) = split / /, $v; # drop anything after the version # can't use exists() because the assignment in the @ops created the slot return $version_alias{$v} if defined $version_alias{$v}; # split the dotted version string my @v = split /\./, $v; my ( $r, $c ) = ( 0, 0 ); # commit count since the previous tag ($c) = ( 1, splice @v, -1 ) if $v[-1] eq 'GIT'; # before 1.4 ($c) = splice @v, -2 if substr( $v[-1], 0, 1 ) eq 'g'; # after 1.4 # release candidate number ($r) = splice @v, -1 if substr( $v[-1], 0, 2 ) eq 'rc'; $r &&= do { $r =~ s/rc//; sprintf '-%02d', $r }; # compute and cache normalized string return $version_alias{$v} = join( '.', map sprintf( '%02d', $_ ), ( @v, 0, 0, 0 )[ 0 .. 3 ] ) . ( $r || '.00' ) . sprintf( '.%04d', $c ); } for my $op (@ops) { no strict 'refs'; *{"${op}_git"} = eval << "OP"; sub { my ( \$v1, \$v2 ) = \@_; \$_ = \$version_alias{\$_} ||= _normalize( \$_ ) for \$v1, \$v2; return \$v1 $op \$v2; } OP } sub cmp_git ($$) { my ( $v1, $v2 ) = @_; $_ = $version_alias{$_} ||= _normalize( $_ ) for $v1, $v2; return $v1 cmp $v2; } 1; __END__ =head1 NAME Git::Version::Compare - Functions to compare Git versions =head1 SYNOPSIS use Git::Version::Compare qw( cmp_git ); # result: 1.2.3 1.7.0.rc0 1.7.4.rc1 1.8.3.4 1.9.3 2.0.0.rc2 2.0.3 2.3.0.rc1 my @versions = sort cmp_git qw( 1.7.4.rc1 1.9.3 1.7.0.rc0 2.0.0.rc2 1.2.3 1.8.3.4 2.3.0.rc1 2.0.3 ); =head1 DESCRIPTION L contains a selection of subroutines that make dealing with Git-related things (like versions) a little bit easier. The strings to compare can be version numbers, tags from C or the output of C or C. These routines collect the knowledge about Git versions that was accumulated while developing L. =head1 AVAILABLE FUNCTIONS By default L does not export any subroutines. All the comparison version functions die when given strings that do not look like Git version numbers (the check is done with L). =head2 lt_git if ( lt_git( $v1, $v2 ) ) { ... } A Git-aware version of the C operator. =head2 gt_git if ( gt_git( $v1, $v2 ) ) { ... } A Git-aware version of the C operator. =head2 le_git if ( le_git( $v1, $v2 ) ) { ... } A Git-aware version of the C operator. =head2 ge_git if ( ge_git( $v1, $v2 ) ) { ... } A Git-aware version of the C operator. =head2 eq_git if ( eq_git( $v1, $v2 ) ) { ... } A Git-aware version of the C operator. =head2 ne_git if ( ne_git( $v1, $v2 ) ) { ... } A Git-aware version of the C operator. =head2 cmp_git @versions = sort cmp_git @versions; A Git-aware version of the C operator. =head2 looks_like_git # true looks_like_git(`git version`); # duh # false looks_like_git('v1.7.3_02'); # no _ in git versions Given a string, returns true if it looks like a Git version number (and can therefore be parsed by C) and false otherwise. It accepts the version strings from all standard Git versions and from some non-standard Gits as well, such as GitLab's embedded Git which uses a special suffix like C<.gl1>. =head1 EXPORT TAGS =head2 :ops Exports C, C, C, C, C, and C. =head2 :all Exports C, C, C, C, C, C, C, and C. =head1 EVERYTHING YOU EVER WANTED TO KNOW ABOUT GIT VERSION NUMBERS =head1 Version numbers Version numbers as returned by C are in the following formats (since the C<1.4> series, in 2006): # stable version 1.6.0 2.7.1 # maintenance release 1.8.5.6 # release candidate 1.6.0.rc2 # development version # (the last two elements come from `git describe`) 1.7.1.209.gd60ad 1.8.5.1.21.gb2a0afd 2.3.0.rc0.36.g63a0e83 In the C repository, several commits have multiple tags (e.g. C and C point respectively to C and C). Pre-1.0.0 versions also have non-standard formats like C<0.99.9j> or C<1.0rc2>. This explains why: # this is true eq_git( '0.99.9l', '1.0rc4' ); eq_git( '1.0.0a', '1.0.1' ); # this is false ge_git( '1.0rc3', '0.99.9m' ); C appeared in version C<1.3.0>. C appeared in version C<0.99.7>. Before that, there is no way to know which version of Git one is dealing with. C converts all version numbers to an internal format before performing a simple string comparison. =head2 Development versions Prior to C<1.4.0-rc1> (June 2006), compiling a development version of Git would lead C to output C<1.x-GIT> (with C in C<0 .. 3>), which would make comparing versions that are very close a futile exercise. Other issues exist when comparing development version numbers with one another. For example, C<1.7.1.1> is greater than both C<1.7.1.1.gc8c07> and C<1.7.1.1.g5f35a>, and C<1.7.1> is less than both. Obviously, C<1.7.1.1.gc8c07> will compare as greater than C<1.7.1.1.g5f35a> (asciibetically), but in fact these two version numbers cannot be compared, as they are two siblings children of the commit tagged C). For practical purposes, the version-comparison methods declares them equal. Therefore: # this is true lt_git( '1.8.5.4.8.g7c9b668', '1.8.5.4.19.g5032098' ); gt_git( '1.3.GIT', '1.3.0' ); # this is false ne_git( '1.7.1.1.gc8c07', '1.7.1.1.g5f35a' ); gt_git( '1.3.GIT', '1.3.1' ); If one were to compute the set of all possible version numbers (as returned by C) for all git versions that can be compiled from each commit in the F repository, the result would not be a totally ordered set. Big deal. Also, don't be too precise when requiring the minimum version of Git that supported a given feature. The precise commit in git.git at which a given feature was added doesn't mean as much as the release branch in which that commit was merged. =head1 SEE ALSO L, for defining Git version requirements in test scripts that need B. =head1 COPYRIGHT Copyright 2016-2023 Philippe Bruhat (BooK), all rights reserved. =head1 LICENSE This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Git-Version-Compare-1.005/t/0000755000175000017500000000000014360467237014176 5ustar bookbookGit-Version-Compare-1.005/t/author-distmeta.t0000644000175000017500000000037414360467237017501 0ustar bookbook#!perl BEGIN { unless ($ENV{AUTHOR_TESTING}) { print qq{1..0 # SKIP these tests are for testing by the author\n}; exit } } # This file was automatically generated by Dist::Zilla::Plugin::MetaTests. use Test::CPAN::Meta; meta_yaml_ok(); Git-Version-Compare-1.005/t/ops.t0000644000175000017500000001122614360467237015166 0ustar bookbookuse strict; use warnings; use Test::More; use Test::NoWarnings; use List::Util qw( sum shuffle ); use Git::Version::Compare qw( :all ); # a few useful subroutines my $shuffle = 3; sub plan_for { my $sorted = shift; return $shuffle # shuffle rounds + @$sorted * 7 # self-equality + 7 * ( @$sorted * ( @$sorted - 1 ) ) # compare with all successors } sub test_sorted { my $sorted = shift; # shuffle + sort for ( 1 .. $shuffle ) { my @shuffled = shuffle @$sorted; is_deeply( [ sort cmp_git @shuffled ], $sorted, 'sort with cmp_git' ) or diag "@$sorted"; } while ( my $v1 = shift @$sorted ) { # reflexivity test_same( $v1, $v1 ); for my $v2 (@$sorted) { # lt gt le ge eq ne cmp ok( lt_git( $v1, $v2 ), "lt_git( $v1, $v2 )" ); ok( !gt_git( $v1, $v2 ), "lt_git( $v1, $v2 )" ); ok( le_git( $v1, $v2 ), "le_git( $v1, $v2 )" ); ok( !ge_git( $v1, $v2 ), "ge_git( $v1, $v2 )" ); ok( !eq_git( $v1, $v2 ), "not eq_git( $v1, $v2 )" ); ok( ne_git( $v1, $v2 ), "ne_git( $v1, $v2 )" ); is( cmp_git( $v1, $v2 ), -1, "cmp_git( $v1, $v2 )" ); # reverse all ok( !lt_git( $v2, $v1 ), "not lt_git( $v2, $v1 )" ); ok( gt_git( $v2, $v1 ), "gt_git( $v2, $v1 )" ); ok( !le_git( $v2, $v1 ), "le_git( $v2, $v1 )" ); ok( ge_git( $v2, $v1 ), "ge_git( $v2, $v1 )" ); ok( !eq_git( $v2, $v1 ), "not eq_git( $v2, $v1 )" ); ok( ne_git( $v2, $v1 ), "ne_git( $v2, $v1 )" ); is( cmp_git( $v2, $v1 ), 1, "cmp_git( $v2, $v1 )" ); } } } sub test_same { my ( $v1, $v2 ) = @_; ok( !lt_git( $v1, $v2 ), "lt_git( $v1, $v2 )" ); ok( !gt_git( $v1, $v2 ), "lt_git( $v1, $v2 )" ); ok( le_git( $v1, $v2 ), "le_git( $v1, $v2 )" ); ok( ge_git( $v1, $v2 ), "ge_git( $v1, $v2 )" ); ok( eq_git( $v1, $v2 ), "eq_git( $v1, $v2 )" ); ok( !ne_git( $v1, $v2 ), "not ne_git( $v1, $v2 )" ); is( cmp_git( $v1, $v2 ), 0, "cmp_git( $v1, $v2 )" ); } # the test data my @sorted = ( '0.99', '0.99.7a', '0.99.7c', '0.99.7d', '0.99.8', '0.99.9c', '0.99.9g', '1.0', '1.0.0a', '1.0.2', '1.0.3', '1.3.0', '1.3.GIT', '1.3.1', '1.3.2', '1.4.0.rc1', '1.4.1', 'v1.5.3.7-976-gcd39076', 'v1.5.3.7-1198-g467f42c', '1.6.6', '1.7.0.2.msysgit.0', '1.7.0.4', '1.7.1.rc0', '1.7.1.rc1', '1.7.1.rc2', 'v1.7.1', '1.7.1.1.gc8c07', '1.7.1.209.gd60ad81', '1.7.1.211.g54fcb21', '1.7.1.236.g81fa0', '1.7.1.1', '1.7.1.1.1.g66bd8ab', '1.7.2.rc0', '1.7.2.rc0.1.g078e', '1.7.2.rc0.10.g1ba5c', '1.7.2.rc0.13.gc9eaaa', '1.9.4.msysgit.0', 'git version 1.9.5.msysgit.1', 'git version 2.6.4 (Apple Git-63)', 'git version 2.8.0.rc3', 'git version 2.8.0.windows.1', 'v2.8.0.2', ); my @same = ( [ '0.99.9l', '1.0rc4' ], [ '1.0.0', 'v1.0.0', '1.0' ], [ '1.0.0a', '1.0.1' ], [ '1.0.0b', 'v1.0.0b', '1.0.2' ], [ '1.0.rc2', '0.99.9i' ], [ '1.7.1', 'v1.7.1', '1.7.1.0' ], [ '1.7.1.1.gc8c07', '1.7.1.1.g5f35a' ], [ '1.7.2.rc0.13.gc9eaaa', '1.7.2.rc0.13.gc9eaaa' ], [ 'git version 2.6.4 (Apple Git-63)', '2.6.4' ], [ 'git version 2.7.0', '2.7', '2.7.0', '2.7.0.0' ], [ 'git version 2.8.0.windows.1', 'git version 2.8.0'], ); # pick up a random git version my $random = shift @ARGV || join '.', int( 1 + rand 4 ), map int rand 13, 1 .. 2 + rand 2; diag "fake git version $random"; # an RC is always lesser my @random = ( "$random.rc1", $random ); # compute a sorted list around $random # other versions based on the current one { my @parts = split /\./, $random; for ( reverse 0 .. $#parts ) { local $" = '.'; my @v = @parts; $v[$_]++; push @random, "@v"; next if 0 > ( $v[$_] -= 2 ); unshift @random, "@v"; } } # the actual tests plan tests => plan_for( \@sorted ) + plan_for( \@random ) # all sorted lists + 7 * sum( map @$_ * @$_, @same ) # all comparisons with all siblings + 1; # Test::NoWarnings test_sorted( \@sorted ); test_sorted( \@random ); for my $twins (@same) { for my $v1 (@$twins) { for my $v2 (@$twins) { test_same( $v1, $v2 ); } } } Git-Version-Compare-1.005/t/00-report-prereqs.dd0000644000175000017500000000302614360467237017717 0ustar bookbookdo { my $x = { 'configure' => { 'requires' => { 'ExtUtils::MakeMaker' => '0' } }, 'develop' => { 'requires' => { 'Pod::Coverage::TrustPod' => '0', 'Test::CPAN::Meta' => '0', 'Test::Pod' => '1.41', 'Test::Pod::Coverage' => '1.08' } }, 'runtime' => { 'requires' => { 'Carp' => '0', 'Exporter' => '0', 'perl' => '5.006', 'strict' => '0', 'warnings' => '0' } }, 'test' => { 'recommends' => { 'CPAN::Meta' => '2.120900' }, 'requires' => { 'ExtUtils::MakeMaker' => '0', 'File::Spec' => '0', 'List::Util' => '0', 'Test::More' => '0', 'Test::NoWarnings' => '0' } } }; $x; }Git-Version-Compare-1.005/t/author-pod-syntax.t0000644000175000017500000000045414360467237017774 0ustar bookbook#!perl BEGIN { unless ($ENV{AUTHOR_TESTING}) { print qq{1..0 # SKIP these tests are for testing by the author\n}; exit } } # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use strict; use warnings; use Test::More; use Test::Pod 1.41; all_pod_files_ok(); Git-Version-Compare-1.005/t/author-pod-coverage.t0000644000175000017500000000053614360467237020242 0ustar bookbook#!perl BEGIN { unless ($ENV{AUTHOR_TESTING}) { print qq{1..0 # SKIP these tests are for testing by the author\n}; exit } } # This file was automatically generated by Dist::Zilla::Plugin::PodCoverageTests. use Test::Pod::Coverage 1.08; use Pod::Coverage::TrustPod; all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' }); Git-Version-Compare-1.005/t/00-report-prereqs.t0000644000175000017500000001345214360467237017577 0ustar bookbook#!perl use strict; use warnings; # This test was generated by Dist::Zilla::Plugin::Test::ReportPrereqs 0.028 use Test::More tests => 1; use ExtUtils::MakeMaker; use File::Spec; # from $version::LAX my $lax_version_re = qr/(?: undef | (?: (?:[0-9]+) (?: \. | (?:\.[0-9]+) (?:_[0-9]+)? )? | (?:\.[0-9]+) (?:_[0-9]+)? ) | (?: v (?:[0-9]+) (?: (?:\.[0-9]+)+ (?:_[0-9]+)? )? | (?:[0-9]+)? (?:\.[0-9]+){2,} (?:_[0-9]+)? ) )/x; # hide optional CPAN::Meta modules from prereq scanner # and check if they are available my $cpan_meta = "CPAN::Meta"; my $cpan_meta_pre = "CPAN::Meta::Prereqs"; my $HAS_CPAN_META = eval "require $cpan_meta; $cpan_meta->VERSION('2.120900')" && eval "require $cpan_meta_pre"; ## no critic # Verify requirements? my $DO_VERIFY_PREREQS = 1; sub _max { my $max = shift; $max = ( $_ > $max ) ? $_ : $max for @_; return $max; } sub _merge_prereqs { my ($collector, $prereqs) = @_; # CPAN::Meta::Prereqs object if (ref $collector eq $cpan_meta_pre) { return $collector->with_merged_prereqs( CPAN::Meta::Prereqs->new( $prereqs ) ); } # Raw hashrefs for my $phase ( keys %$prereqs ) { for my $type ( keys %{ $prereqs->{$phase} } ) { for my $module ( keys %{ $prereqs->{$phase}{$type} } ) { $collector->{$phase}{$type}{$module} = $prereqs->{$phase}{$type}{$module}; } } } return $collector; } my @include = qw( ); my @exclude = qw( ); # Add static prereqs to the included modules list my $static_prereqs = do './t/00-report-prereqs.dd'; # Merge all prereqs (either with ::Prereqs or a hashref) my $full_prereqs = _merge_prereqs( ( $HAS_CPAN_META ? $cpan_meta_pre->new : {} ), $static_prereqs ); # Add dynamic prereqs to the included modules list (if we can) my ($source) = grep { -f } 'MYMETA.json', 'MYMETA.yml'; my $cpan_meta_error; if ( $source && $HAS_CPAN_META && (my $meta = eval { CPAN::Meta->load_file($source) } ) ) { $full_prereqs = _merge_prereqs($full_prereqs, $meta->prereqs); } else { $cpan_meta_error = $@; # capture error from CPAN::Meta->load_file($source) $source = 'static metadata'; } my @full_reports; my @dep_errors; my $req_hash = $HAS_CPAN_META ? $full_prereqs->as_string_hash : $full_prereqs; # Add static includes into a fake section for my $mod (@include) { $req_hash->{other}{modules}{$mod} = 0; } for my $phase ( qw(configure build test runtime develop other) ) { next unless $req_hash->{$phase}; next if ($phase eq 'develop' and not $ENV{AUTHOR_TESTING}); for my $type ( qw(requires recommends suggests conflicts modules) ) { next unless $req_hash->{$phase}{$type}; my $title = ucfirst($phase).' '.ucfirst($type); my @reports = [qw/Module Want Have/]; for my $mod ( sort keys %{ $req_hash->{$phase}{$type} } ) { next if $mod eq 'perl'; next if grep { $_ eq $mod } @exclude; my $file = $mod; $file =~ s{::}{/}g; $file .= ".pm"; my ($prefix) = grep { -e File::Spec->catfile($_, $file) } @INC; my $want = $req_hash->{$phase}{$type}{$mod}; $want = "undef" unless defined $want; $want = "any" if !$want && $want == 0; my $req_string = $want eq 'any' ? 'any version required' : "version '$want' required"; if ($prefix) { my $have = MM->parse_version( File::Spec->catfile($prefix, $file) ); $have = "undef" unless defined $have; push @reports, [$mod, $want, $have]; if ( $DO_VERIFY_PREREQS && $HAS_CPAN_META && $type eq 'requires' ) { if ( $have !~ /\A$lax_version_re\z/ ) { push @dep_errors, "$mod version '$have' cannot be parsed ($req_string)"; } elsif ( ! $full_prereqs->requirements_for( $phase, $type )->accepts_module( $mod => $have ) ) { push @dep_errors, "$mod version '$have' is not in required range '$want'"; } } } else { push @reports, [$mod, $want, "missing"]; if ( $DO_VERIFY_PREREQS && $type eq 'requires' ) { push @dep_errors, "$mod is not installed ($req_string)"; } } } if ( @reports ) { push @full_reports, "=== $title ===\n\n"; my $ml = _max( map { length $_->[0] } @reports ); my $wl = _max( map { length $_->[1] } @reports ); my $hl = _max( map { length $_->[2] } @reports ); if ($type eq 'modules') { splice @reports, 1, 0, ["-" x $ml, "", "-" x $hl]; push @full_reports, map { sprintf(" %*s %*s\n", -$ml, $_->[0], $hl, $_->[2]) } @reports; } else { splice @reports, 1, 0, ["-" x $ml, "-" x $wl, "-" x $hl]; push @full_reports, map { sprintf(" %*s %*s %*s\n", -$ml, $_->[0], $wl, $_->[1], $hl, $_->[2]) } @reports; } push @full_reports, "\n"; } } } if ( @full_reports ) { diag "\nVersions for all modules listed in $source (including optional ones):\n\n", @full_reports; } if ( $cpan_meta_error || @dep_errors ) { diag "\n*** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING ***\n"; } if ( $cpan_meta_error ) { my ($orig_source) = grep { -f } 'MYMETA.json', 'MYMETA.yml'; diag "\nCPAN::Meta->load_file('$orig_source') failed with: $cpan_meta_error\n"; } if ( @dep_errors ) { diag join("\n", "\nThe following REQUIRED prerequisites were not satisfied:\n", @dep_errors, "\n" ); } pass('Reported prereqs'); # vim: ts=4 sts=4 sw=4 et: Git-Version-Compare-1.005/t/cmp_git.t0000644000175000017500000000303114360467237016002 0ustar bookbookuse strict; use warnings; use Test::More; use Test::NoWarnings; use Git::Version::Compare qw( cmp_git ); plan tests => 3; is_deeply( [ sort cmp_git qw( 1.7.4.rc1 1.9.3 1.7.0.rc0 2.0.0.rc2 1.2.3 1.8.3.4 1.7.1.3 1.8.2.1 2.3.0.rc1 2.0.0.rc1 1.7.12.rc0 1.6.3.rc1 1.4.3.3 2.0.3 ) ], [ qw( 1.2.3 1.4.3.3 1.6.3.rc1 1.7.0.rc0 1.7.1.3 1.7.4.rc1 1.7.12.rc0 1.8.2.1 1.8.3.4 1.9.3 2.0.0.rc1 2.0.0.rc2 2.0.3 2.3.0.rc1 ) ], 'cmp_git' ); # the 0.99 series is_deeply( [ sort cmp_git qw( 1.0.rc2 0.99.7a 0.99.8d 0.99.7c 0.99.4 0.99.9c 0.99.9g 0.99.8c 0.99.9 1.0.rc3 0.99.9i 0.99.9d 0.99.9b 0.99.9l 1.0.rc1 0.99.1 1.0.rc4 0.99.5 0.99.8e 0.99.3 0.99 0.99.9k 0.99.8f 1.0.rc5 0.99.9n 0.99.7d 0.99.9h 0.99.8 1.0.rc6 0.99.7 0.99.9m 0.99.9a 0.99.8b 0.99.8a 0.99.9e 0.99.9j 0.99.7b 1.0.0 0.99.8g 0.99.9f 0.99.2 0.99.6 0.99.9.GIT ) ], [ # sort is stable, so identical items stay in the same order qw( 0.99 0.99.1 0.99.2 0.99.3 0.99.4 0.99.5 0.99.6 0.99.7 0.99.7a 0.99.7b 0.99.7c 0.99.7d 0.99.8 0.99.8a 0.99.8b 0.99.8c 0.99.8d 0.99.8e 0.99.8f 0.99.8g 0.99.9 0.99.9.GIT 0.99.9a 0.99.9b 0.99.9c 0.99.9d 0.99.9e 0.99.9f 0.99.9g 1.0.rc1 0.99.9h 1.0.rc2 0.99.9i 1.0.rc3 0.99.9j 0.99.9k 0.99.9l 1.0.rc4 1.0.rc5 0.99.9m 0.99.9n 1.0.rc6 1.0.0 ) ], 'cmp_git (0.99 series)' ); Git-Version-Compare-1.005/t/normalize.t0000644000175000017500000000334114360467237016364 0ustar bookbookuse strict; use warnings; use Test::More; use Git::Version::Compare; my @tests = ( [ undef, undef ], # actual output from `git --version` [ '0.99.7', '00.99.07.00.00.0000' ], [ '0.99.9l', '00.99.09.12.00.0000' ], [ '1.2.3', '01.02.03.00.00.0000' ], [ '1.2.3', '01.02.03.00.00.0000' ], [ '1.8.0.rc3', '01.08.00.00-03.0000' ], [ '1.8.0', '01.08.00.00.00.0000' ], [ '1.8.0.3', '01.08.00.03.00.0000' ], [ '1.8.5.4.19.g5032098', '01.08.05.04.00.0019' ], [ '2.3.0.rc0.36.g63a0e83', '02.03.00.00-00.0036' ], [ "git version 2.7.0\n", '02.07.00.00.00.0000' ], [ "git version 2.6.4 (Apple Git-63)\n", '02.06.04.00.00.0000' ], # Win32 msysgit [ '1.9.4.msysgit.0', '01.09.04.00.00.0000' ], [ '1.9.5.msysgit.1', '01.09.05.00.00.0000' ], # plausible version numbers [ '1.0.rc4', '00.99.09.12.00.0000' ], [ '1.0rc4', '00.99.09.12.00.0000' ], [ '1.6', '01.06.00.00.00.0000' ], # tags from git.git [ 'v1.0rc4', '00.99.09.12.00.0000' ], [ 'v1.7.12-rc2', '01.07.12.00-02.0000' ], [ 'v1.8.4.5', '01.08.04.05.00.0000' ], [ 'v1.8.5.4-19-g5032098', '01.08.05.04.00.0019' ], [ 'v2.0.0-rc0', '02.00.00.00-00.0000' ], [ 'v1.5.3.7-971-g61fd255', '01.05.03.07.00.0971' ], [ 'v1.5.3.7-1198-g467f42c', '01.05.03.07.00.1198' ], ); plan tests => scalar @tests; for my $t (@tests) { is( Git::Version::Compare::_normalize( $t->[0] ), $t->[1], $t->[0] || 'undef' ); } Git-Version-Compare-1.005/t/looks_like_git.t0000644000175000017500000000333114360467237017361 0ustar bookbookuse strict; use warnings; use Test::More; use Test::NoWarnings; use Git::Version::Compare qw( looks_like_git eq_git ); my @ok = ( # actual output from `git --version` "git version 1.0.0a\n", "git version 2.7.0\n", "git version 2.6.4 (Apple Git-63)\n", # just the version number '0.99.7', '0.99.9l', '1.2.3', '1.2.3', '1.8.0.rc3', '1.8.0', '1.8.0.3', '1.8.5.4.19.g5032098', '2.3.0.rc0.36.g63a0e83', # Win32 msysgit '1.9.4.msysgit.0', '1.9.5.msysgit.1', # plausible version numbers '1.0.rc4', '1.0rc4', '1.6', # tags from git.git 'v1.0rc4', 'v1.7.12-rc2', 'v1.8.4.5', 'v1.8.5.4-19-g5032098', 'v2.0.0-rc0', 'v0.99.8-255-g0f8fdc3', 'v1.7.12-301-g382a967', 'v1.5.4.3-197-gdc31cd8', 'v2.0.0-rc3-5-g50b54fd', 'v1.5.3.7-971-g61fd255', 'v1.5.3.7-1198-g467f42c', # the pre-computed aliases from Git::Version::Compare '0.99.7a', '0.99.7b', '0.99.7c', '0.99.7d', '0.99.8a', '0.99.8b', '0.99.8c', '0.99.8d', '0.99.8e', '0.99.8f', '0.99.8g', '0.99.9a', '0.99.9b', '0.99.9c', '0.99.9d', '0.99.9e', '0.99.9f', '0.99.9g', '0.99.9h', '1.0.rc1', '0.99.9i', '1.0.rc2', '0.99.9j', '1.0.rc3', '0.99.9k', '0.99.9l', '1.0.rc4', '0.99.9m', '1.0.rc5', '0.99.9n', '1.0.rc6', '1.0.0a', '1.0.0b', # vendor specific versions # GitLab embedded git '2.37.1.gl1', ); # non-git version my @fail = ( 'this is a test', '1.0203', '1.02_03', ); plan tests => @ok + @fail + 2 + 1; ok( looks_like_git($_), $_ ) for @ok; ok( !looks_like_git($_), "'$_' is not a Git version" ) for @fail; ok( !eval { eq_git( 'not-a-git-version', '1.0.0' ); 1 }, 'not a git version' ); like( $@, qr/^not-a-git-version does not look like a Git version /, '... expected error message' );