Dist-Zilla-Plugin-ChangelogFromGit-0.015/000755 000765 000024 00000000000 12202155010 020202 5ustar00trocstaff000000 000000 Dist-Zilla-Plugin-ChangelogFromGit-0.015/CHANGES000644 000765 000024 00000013404 12202155010 021177 0ustar00trocstaff000000 000000 ================================================== Changes from 2012-08-12 00:00:00 +0000 to present. ================================================== ------------------------------------------ version 0.014 at 2013-08-11 16:35:25 +0000 ------------------------------------------ Change: 26417b1c0c702540ab07e88e0cf3310c1b43c002 Author: Rocco Caputo Date : 2013-08-11 12:35:25 +0000 Exclude some more perl core modules from the versioned dependencies. ------------------------------------------ version 0.012 at 2013-08-10 21:11:07 +0000 ------------------------------------------ Change: e4f06498bfb41e0465bfb90f1fc46377aa2dc651 Author: Rocco Caputo Date : 2013-08-10 17:11:07 +0000 Exclude versions for modules that would upgrade Perl. ------------------------------------------ version 0.011 at 2013-08-10 20:37:39 +0000 ------------------------------------------ Change: 28486ef8e4d364f31df78cf7ccbf2437ca0d4fa6 Author: Rocco Caputo Date : 2013-08-10 16:37:39 +0000 Set all prerequisite versions to what's installed. Thanks, Kent Fredric, for responding to my bug report/wishlist request with Dist::Zilla::Plugin::Prereqs::MatchInstalled::All. ------------------------------------------ version 0.010 at 2013-08-06 00:49:34 +0000 ------------------------------------------ Change: 4683677453582bf655374e531f8ccb11ca017875 Author: Rocco Caputo Date : 2013-08-05 20:49:34 +0000 More dist.ini modernization. ------------------------------------------ version 0.009 at 2013-08-05 07:08:02 +0000 ------------------------------------------ Change: 2f3694e12d62da200657ada6e25b94275614a3db Author: Rocco Caputo Date : 2013-08-05 03:08:02 +0000 Modernize dependencies and dist.ini idioms. ------------------------------------------ version 0.008 at 2013-08-04 18:44:32 +0000 ------------------------------------------ Change: 5c00f5cd94ded7c9a19999d8c7f0dbc960ddbdc1 Author: Rocco Caputo Date : 2013-08-04 14:44:32 +0000 It's August 2013. About time I changed the copyright notice. Change: 4cd053ec73ce66858dd8b709cc55eb16b9acdce0 Author: Rocco Caputo Date : 2013-07-05 02:09:44 +0000 Add the new dependency upon IPC::Cmd. Change: 668a94a07d6ad4d07b0a644a9ec7d7cba6c5651e Author: Rocco Caputo Date : 2013-07-04 23:07:12 +0000 Merge pull request #9 from jddurand/master Portability + log on HEAD detection Change: 2cfaaa70ee7f344d17e6a0de0072dd16daea6fd3 Author: Jean-Damien Durand Date : 2013-06-04 01:59:25 +0000 Portability + logic on detection of HEAD ------------------------------------------ version 0.007 at 2013-04-19 03:37:25 +0000 ------------------------------------------ Change: b75ebd08c22edcc99fc07268c737e654cd89a826 Author: Rocco Caputo Date : 2013-04-18 20:37:25 +0000 Merge pull request #8 from zengargoyle/patch-1 [rt.cpan.org 83445] Fix include_message to include, not exclude. Change: 2b4a47c0fa57eeaf94bdec09fe1129bfe10f25a7 Author: zengargoyle Date : 2013-02-20 23:08:33 +0000 Update lib/Dist/Zilla/Plugin/ChangelogFromGit.pm log messages should be skipped if there is a include_message_re and the message *DOESN'T* match the include_message_re. ------------------------------------------ version 0.006 at 2012-10-11 04:01:29 +0000 ------------------------------------------ Change: d6966f4c00c8b48f978c9eb03871d89a15b52533 Author: Rocco Caputo Date : 2012-10-11 00:01:29 +0000 Update dist.ini to personal best practices. Change: c513827d82c6bc1758d32cf4215913a4905ede0f Author: Rocco Caputo Date : 2012-10-11 00:01:29 +0000 Rename filter_in and filter_out to include_message and exclude_message. Change: f4110ec9a2e7969dd5ef1677bcd66b9db4a15195 Author: Rocco Caputo Date : 2012-10-10 20:59:55 +0000 Merge pull request #6 from ironcamel/pr/synopsis-tag_regexp Fixing the SYNOPSIS describing the default tag_regexp value Change: ae720c1e7207a79363c3d70e97d1f121f6fbb5c2 Author: Rocco Caputo Date : 2012-10-10 20:44:22 +0000 Merge pull request #7 from andrefs/master Adding filter_out and filter_in options. Change: 8507a954f6e8096802a80299233b0fb3345eae26 Author: André Santos Date : 2012-09-26 21:58:19 +0000 added filter_out and filter_in options Change: df7d696a90f8af78ff6305386e371160941fb442 Author: Naveed Massjouni Date : 2012-07-23 02:17:48 +0000 Fixing the SYNOPSIS describing the default tag_regexp value Change: 0061b3a8322478f04cddecf91a521b5179219a1d Author: Rocco Caputo Date : 2012-04-29 14:52:54 +0000 Merge pull request #5 from kentfredric/no-releases-bug Fix a lovely little error scenario which occurs when it can find no previous releases. Change: e26a496ebc85445dfe0a6190b99bf4fb968d257d Author: Kent Fredric Date : 2012-03-19 06:26:51 +0000 Fix a lovely little error scenario which occurs when it can find no previous releases. A. It tries to get_release(-1), which returns undef , and then it tries undef->version() , which can't work. B. When you avoid the former by checking for an empty release set first, it dies trying to dereference "undef" to an array to return elements(), so pre-populating the array with a default empty array-reference is required for it to work. ================================================ Plus 4 releases after 2012-08-12 00:00:00 +0000. ================================================ Dist-Zilla-Plugin-ChangelogFromGit-0.015/dist.ini000644 000765 000024 00000001466 12202155010 021655 0ustar00trocstaff000000 000000 name = Dist-Zilla-Plugin-ChangelogFromGit author = Rocco Caputo copyright_holder = Rocco Caputo license = Perl_5 [AutoMetaResources] bugtracker.rt = 1 license = http://dev.perl.org/licenses/ repository.github = user:rcaputo;lcdist:dzp-changelogfromgit [AutoPrereqs] [CheckPrereqsIndexed] [Prereqs::MatchInstalled::All] exclude = bytes exclude = constant exclude = lib exclude = perl exclude = strict exclude = vars exclude = warnings [Homepage] [ReadmeFromPod] [ReadmeMarkdownFromPod] [ReportVersions] [Repository] git_remote = gh [Git::Check] [Git::NextVersion] first_version = 0.002 version_regexp = ^v(\d+\.\d+)$ [ChangelogFromGit] tag_regexp = v(\d+[_.]\d+) [Git::Tag] tag_format = v%v tag_message = Release %v. [@Classic] [MetaJSON] Dist-Zilla-Plugin-ChangelogFromGit-0.015/lib/000755 000765 000024 00000000000 12202155010 020750 5ustar00trocstaff000000 000000 Dist-Zilla-Plugin-ChangelogFromGit-0.015/LICENSE000644 000765 000024 00000043744 12202155010 021223 0ustar00trocstaff000000 000000 This software is copyright (c) 2013 by Rocco Caputo . 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) 2013 by Rocco Caputo . 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, Suite 500, Boston, MA 02110-1335 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) 2013 by Rocco Caputo . 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 MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End Dist-Zilla-Plugin-ChangelogFromGit-0.015/Makefile.PL000644 000765 000024 00000003523 12202155010 022157 0ustar00trocstaff000000 000000 use strict; use warnings; use ExtUtils::MakeMaker 6.30; my %WriteMakefileArgs = ( "ABSTRACT" => "Write a Changes file from a project's git log.", "AUTHOR" => "Rocco Caputo ", "BUILD_REQUIRES" => {}, "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => "6.30" }, "DISTNAME" => "Dist-Zilla-Plugin-ChangelogFromGit", "EXE_FILES" => [], "LICENSE" => "perl", "NAME" => "Dist::Zilla::Plugin::ChangelogFromGit", "PREREQ_PM" => { "DateTime" => "1.03", "DateTime::Infinite" => "1.03", "Dist::Zilla::Role::FileGatherer" => "4.300035", "Git::Repository::Log::Iterator" => "1.307", "IPC::Cmd" => "0.82", "Moose" => "2.1005", "Moose::Autobox" => "0.13", "Software::Release" => "0.03", "Software::Release::Change" => "0.03", "Text::Wrap" => "2013.0523" }, "TEST_REQUIRES" => { "Carp" => "1.26", "Scalar::Util" => "1.29", "Test::More" => "0.98", "strict" => 0, "warnings" => 0 }, "VERSION" => "0.015", "test" => { "TESTS" => "t/*.t" } ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { my $tr = delete $WriteMakefileArgs{TEST_REQUIRES}; my $br = $WriteMakefileArgs{BUILD_REQUIRES}; for my $mod ( keys %$tr ) { if ( exists $br->{$mod} ) { $br->{$mod} = $tr->{$mod} if $tr->{$mod} > $br->{$mod}; } else { $br->{$mod} = $tr->{$mod}; } } } unless ( eval { ExtUtils::MakeMaker->VERSION(6.56) } ) { my $br = delete $WriteMakefileArgs{BUILD_REQUIRES}; my $pp = $WriteMakefileArgs{PREREQ_PM}; for my $mod ( keys %$br ) { if ( exists $pp->{$mod} ) { $pp->{$mod} = $br->{$mod} if $br->{$mod} > $pp->{$mod}; } else { $pp->{$mod} = $br->{$mod}; } } } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); Dist-Zilla-Plugin-ChangelogFromGit-0.015/MANIFEST000644 000765 000024 00000000324 12202155010 021332 0ustar00trocstaff000000 000000 CHANGES LICENSE MANIFEST MANIFEST.SKIP META.json META.yml Makefile.PL README README.mkdn dist.ini lib/Dist/Zilla/Plugin/ChangelogFromGit.pm t/000-report-versions.t t/release-pod-coverage.t t/release-pod-syntax.t Dist-Zilla-Plugin-ChangelogFromGit-0.015/MANIFEST.SKIP000600 000765 000024 00000000320 12202155010 022063 0ustar00trocstaff000000 000000 CVS \.\# \.bak$ \.cvsignore \.git \.gz$ \.orig$ \.patch$ \.ppd$ \.rej$ \.rej$ \.svn \.swo$ \.swp$ ^Makefile$ ^Makefile\.old$ ^\. ^_Inline ^_build ^blib/ ^comptest ^cover_db ^coverage\.report$ ^pm_to_blib$ ~$ Dist-Zilla-Plugin-ChangelogFromGit-0.015/META.json000644 000765 000024 00000004142 12202155010 021624 0ustar00trocstaff000000 000000 { "abstract" : "Write a Changes file from a project's git log.", "author" : [ "Rocco Caputo " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 4.300035, CPAN::Meta::Converter version 2.132140", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Dist-Zilla-Plugin-ChangelogFromGit", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "6.30" } }, "develop" : { "requires" : { "Pod::Coverage::TrustPod" : "0", "Test::Pod" : "1.41", "Test::Pod::Coverage" : "1.08" } }, "runtime" : { "requires" : { "DateTime" : "1.03", "DateTime::Infinite" : "1.03", "Dist::Zilla::Role::FileGatherer" : "4.300035", "Git::Repository::Log::Iterator" : "1.307", "IPC::Cmd" : "0.82", "Moose" : "2.1005", "Moose::Autobox" : "0.13", "Software::Release" : "0.03", "Software::Release::Change" : "0.03", "Text::Wrap" : "2013.0523" } }, "test" : { "requires" : { "Carp" : "1.26", "Scalar::Util" : "1.29", "Test::More" : "0.98", "perl" : "5.004", "strict" : "0", "warnings" : "0" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "mailto" : "bug-Dist-Zilla-Plugin-ChangelogFromGit@rt.cpan.org", "web" : "https://rt.cpan.org/Public/Dist/Display.html?Name=Dist-Zilla-Plugin-ChangelogFromGit" }, "homepage" : "http://search.cpan.org/dist/Dist-Zilla-Plugin-ChangelogFromGit/", "license" : [ "http://dev.perl.org/licenses/" ], "repository" : { "type" : "git", "url" : "git://github.com/rcaputo/dzp-changelogfromgit.git", "web" : "https://github.com/rcaputo/dzp-changelogfromgit" } }, "version" : "0.015" } Dist-Zilla-Plugin-ChangelogFromGit-0.015/META.yml000644 000765 000024 00000002111 12202155010 021446 0ustar00trocstaff000000 000000 --- abstract: "Write a Changes file from a project's git log." author: - 'Rocco Caputo ' build_requires: Carp: 1.26 Scalar::Util: 1.29 Test::More: 0.98 perl: 5.004 strict: 0 warnings: 0 configure_requires: ExtUtils::MakeMaker: 6.30 dynamic_config: 0 generated_by: 'Dist::Zilla version 4.300035, CPAN::Meta::Converter version 2.132140' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Dist-Zilla-Plugin-ChangelogFromGit requires: DateTime: 1.03 DateTime::Infinite: 1.03 Dist::Zilla::Role::FileGatherer: 4.300035 Git::Repository::Log::Iterator: 1.307 IPC::Cmd: 0.82 Moose: 2.1005 Moose::Autobox: 0.13 Software::Release: 0.03 Software::Release::Change: 0.03 Text::Wrap: 2013.0523 resources: bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=Dist-Zilla-Plugin-ChangelogFromGit homepage: http://search.cpan.org/dist/Dist-Zilla-Plugin-ChangelogFromGit/ license: http://dev.perl.org/licenses/ repository: git://github.com/rcaputo/dzp-changelogfromgit.git version: 0.015 Dist-Zilla-Plugin-ChangelogFromGit-0.015/README000644 000765 000024 00000044346 12202155010 021075 0ustar00trocstaff000000 000000 NAME Dist::Zilla::Plugin::ChangelogFromGit - Write a Changes file from a project's git log. VERSION version 0.015 SYNOPSIS Here's an example dist.ini section showing all the current options and their default values. [ChangelogFromGit] max_age = 365 tag_regexp = ^v(\d+\.\d+)$ file_name = CHANGES wrap_column = 74 debug = 0 Variables don't need to be set to their default values. This is equivalent to the configuration above. [ChangelogFromGit] DESCRIPTION This Dist::Zilla plugin turns a project's git commit log into a change log file. It's better than simply running `git log > CHANGES` in at least two ways. First, it understands release tags, and it uses them to group changes by release. Second, it reformats the changes to make them easier to read. And third, subclasses can change some or all of the reformatting to make change logs even easier to read. See this project's CHANGES file for sample output. Yes, this project uses itself to generate its own change log. Why not? CONFIGURATION / PUBLIC ATTRIBUTES As seen in the "SYNOPSIS", this plugin has a number of public attributes that may be set using dist.ini configuration variables. max_age = INTEGER The "max_age" configuration variable limits the age of releases to be included in the change log. The default is to include releases going back about a year. To include about two years, one would double the default value: [ChangelogFromGit] max_age = 730 "max_age" is intended to limit the size of change logs for large, long-term projects that don't want to include the entire, huge commit history in every release. tag_regexp = REGULAR_EXPRESSION "tag_regexp" sets the regular expression that detects which tags mark releases. It also extracts the version numbers from these tags using a regular expression back reference or capture. For example, a project's release tags might match 'release-1.000', 'release-1.001', etc. This "tag_regexp" will find them and extract their versions. [ChangelogFromGit] tag_regexp = ^release-(\d+.*)$ There is no single standard format for release tags. "tag_regexp" defaults to the author's convention. It will most likely need to be changed. file_name = STRING "file_name" sets the name of the change log that will be written. It defaults to "CHANGES", but some people may prefer "Changes", "Changelog", or something else. [ChangelogFromGit] file_name = Changes wrap_column = INTEGER Different contributors tend to use different commit message formats, which can be disconcerting to the typographically aware release engineer. "wrap_column" sets the line length to which all commit messages will be re-wrapped. It's 74 columns by default. If this is too short: [ChangelogFromGit] wrap_column = 78 debug = BOOLEAN Developers are people, too. The "debug" option enables some noisy runtime tracing on STDERR. [ChangelogFromGit] debug = 1 exclude_message = REGULAR_EXPRESSION "exclude_message" sets a regular expression which discards matching commit messages. This provides a way to exclude commit messages such as 'forgot to include file X' or 'typo'. The regular expression is case sensitive. [ChangelogFromGit] exclude_message = ^(forgot|typo) "include_message" can be used to do the opposite: exclude all changes except ones that match a regular expression. Using both at once is liable to generate empty change logs. include_message = REGULAR_EXPRESSION "include_message" does the opposite of "exclude_message": it sets a regular expression which commit messages must match in order to be included in the Changes file. This means that when making a commit with a relevant message, you must include text that matches the regular expression pattern to have it included in the Changes file. All other commit messages are ignored. The regular expression is case sensitive. [ChangelogFromGit] include_message = ^Major Using both "include_message" and "exclude_message" at the same time will most likely result in empty change logs. HOW IT WORKS Dist::Zilla::ChangelogFromGit collects the tags matching "tag_regexp" that are not older than "max_age" days old. These are used to identify and time stamp releases. Each release is encapsulated into a Software::Release object. Git::Repository::Log::Iterator is used to collect the changes prior to each release but after the previous release. Change log entries are added to their respective Software::Release objects. "$self->render_changelog()" is called after all the relevant releases and changes are known. It must return the rendered change log as a string. That string will be used as the content for a Dist::Zilla::File::InMemory object representing the new change log. SUBCLASSING FOR NEW FORMATS Dist::Zilla::ChangelogFromGit implement about a dozen methods to render the various parts of a change log. Subclasses may override or augment any or all of these methods to alter the way change logs are rendered. All methods beginning with "render" return strings that will be incorporated into the change log. Methods that will not contribute to the change log must return empty strings. Rendering Entire Change Logs Methods beginning with "render_changelog" receive no parameters other than $self. Everything they need to know about the change log is included in the object's attributes: "wrap_column", "releases", "skipped_release_count", "earliest_date". render_changelog render_changelog() returns the text of the entire change log. By default, the change log is built from a header, zero or more releases, and a footer. sub render_changelog { my $self = shift(); return( $self->render_changelog_header() . $self->render_changelog_releases() . $self->render_changelog_footer() ); } render_changelog_header render_changelog_header() renders some text that introduces the reader to the change log. sub render_changelog_header { my $self = shift(); my $header = ( "Changes from " . $self->format_datetime($self->earliest_date()) . " to present." ); return $self->surround_line("=", $header) . "\n"; } render_changelog_releases render_changelog_releases() iterates through each release, calling upon $self to render them one at a time. sub render_changelog_releases { my $self = shift(); my $changelog = ''; RELEASE: foreach my $release (reverse $self->all_releases()) { next RELEASE if $release->has_no_changes(); $changelog .= $self->render_release($release); } return $changelog; } render_changelog_footer render_changelog_footer() tells the reader that the change log is over. Normally the end of the file is sufficient warning, but a truncated change log is friendlier when the reader knows what they're missing. sub render_changelog_footer { my $self = shift(); my $skipped_count = $self->skipped_release_count(); my $changelog_footer; if ($skipped_count) { my $releases = "release" . ($skipped_count == 1 ? "" : "s"); $changelog_footer = ( "Plus $skipped_count $releases after " . $self->format_datetime($self->earliest_date()) . '.' ); } else { $changelog_footer = "End of releases."; } return $self->surround_line("=", $changelog_footer); } Rendering Individual Releases Methods beginning with "render_release" receive $self plus one additional parameter: a Software::Release object encapsulating the release and its changes. See Software::Release to learn the information that object encapsulates. render_release render_release() is called upon to render a single release. In the change log, a release consists of a header, one or more changes, and a footer. sub render_release { my ($self, $release) = @_; return( $self->render_release_header($release) . $self->render_release_changes($release) . $self->render_release_footer($release) ); } render_release_header render_release_header() introduces a release. sub render_release_header { my ($self, $release) = @_; my $version = $release->version(); $version = $self->zilla()->version() if $version eq 'HEAD'; my $release_header = ( $self->format_release_tag($release->version()) . ' at ' . $self->format_datetime($release->date()) ); return $self->surround_line("-", $release_header) . "\n"; } render_release_changes render_release_changes() iterates through the changes associated with each Software::Release object. It calls upon render_change() to render each change. sub render_release_changes { my ($self, $release) = @_; my $changelog = ''; foreach my $change (@{ $release->changes() }) { $changelog .= $self->render_change($release, $change); } return $changelog; } render_release_footer render_release_footer() may be used to divide releases. It's not used by default, but it's implemented for completeness. sub render_release_footer { my ($self, $release) = @_; return ''; } Rendering Individual Changes Methods beginning with "render_change" receive two parameters in addition to $self: a Software::Release object encapsulating the release containing this change, and a Software::Release::Change object encapsulating the change itself. render_change render_change() renders a single change, which is the catenation of a change header, change message, and footer. sub render_change { my ($self, $release, $change) = @_; return( $self->render_change_header($release, $change) . $self->render_change_message($release, $change) . $self->render_change_footer($release, $change) ); } render_change_header render_change_header() generally renders identifying information about each change. This method's responsibility is to produce useful information in a pleasant format. sub render_change_header { my ($self, $release, $change) = @_; use Text::Wrap qw(fill); local $Text::Wrap::huge = 'wrap'; local $Text::Wrap::columns = $self->wrap_column(); my @indent = (" ", " "); return( fill( " ", " ", 'Change: ' . $change->change_id ) . "\n" . fill( " ", " ", 'Author: ' . $change->author_name.' <'.$change->author_email.'>' ) . "\n" . fill( " ", " ", 'Date : ' . $self->format_datetime($change->date()) ) . "\n\n" ); } render_change_message render_change_message() renders the commit message for the change log. sub render_change_message { my ($self, $release, $change) = @_; use Text::Wrap qw(fill); return '' if $change->description() =~ /^\s/; local $Text::Wrap::huge = 'wrap'; local $Text::Wrap::columns = $self->wrap_column(); return fill(" ", " ", $change->description) . "\n"; } render_change_footer render_change_footer() returns summary and/or divider text for the change. sub render_change_footer { my ($self, $release, $change) = @_; return "\n"; } Formatting Data Dist::Zilla::Plugin::ChangelogFromGit includes a few methods to consistently format certain data types. format_datetime format_datetime() converts the DateTime objects used internally into friendly, human readable dates and times for the change log. sub format_datetime { my ($self, $datetime) = @_; return $datetime->strftime("%F %T %z"); } format_release_tag format_release_tag() turns potentially cryptic release tags into friendly version numbers for the change log. By default, it also replaces the 'HEAD' version with the current version being released. This accommodates release managers who prefer to tag their distributions after releasing them. sub format_release_tag { my ($self, $release_tag) = @_; return 'version ' . $self->zilla()->version() if $release_tag eq 'HEAD'; my $tag_regexp = $self->tag_regexp(); $release_tag =~ s/$tag_regexp/version $1/; return $release_tag; } surround_line surround_line() will surround a line of output with lines of dashes or other characters. It's used to help heading stand out. This method takes two strings: a character (or string) that will repeat to fill surrounding lines, and the line to surround. It returns a three-line string: the original line preceded and followed by surrounding lines. sub surround_line { my ($self, $character, $string) = @_; my $surrounder = substr( ($character x (length($string) / length($character) + 1)), 0, length($string) ); return "$surrounder\n$string\n$surrounder\n"; } INTERNAL ATTRIBUTES Dist::Zilla::Plugin::ChangelogFromGit accumulates useful information into a few internal attributes. These aren't intended to be configured by dist.ini, but they are important for rendering change logs. earliest_date earliest_date() contains a DateTime object that represents the date and time of the earliest release to include. It's initialized as midnight for the date max_age() days ago. releases releases() contains an array reference of Software::Release objects that will be included in the change log. all_releases all_releases() returns a list of the Software::Release objects that should be included in the change log. It's a friendly equivalent of "@{$self->releases()}". get_release get_release() returns a single release by index. The first release in the change log may be retrieved as "$self->get_release(0)". releae_count release_count() returns the number of Software::Release objects in the "releases" attribute. sort_releases sort_releases() sorts the Software::Release objects in the releases() using some comparator. For example, to sort releases in time order: $self->sort_releases( sub { DateTime->compare( $_[0]->date(), $_[1]->date() ) } ); skipped_release_count skipped_release_count() contains the number of releases truncated by max_age(). The default render_changelog_footer() uses it to display the number of changes that have been omitted from the log. Subversion and CVS This plugin is almost entirely a copy-and-paste port of a command-line tool I wrote a while ago. I also have tools to generate similar change logs for CVS and Subversion projects. I'm happy to contribute that code to people interested in creating Dist::Zilla plugins for other version control systems. We should also consider abstracting the formatting code out to a role so that it can be shared among different plugins. BUGS The documentation includes copies of the renderer methods. This increases technical debt, since changes to those methods must also be copied into the documentation. Rocco needs to finish Pod::Plexus and use it here to simplify maintenance of the documentation. Collecting all releases and changes before rendering the change log may be considered harmful for extremely large projects. If someone thinks they can generate change logs incrementally, their assistance would be appreciated. AUTHORS Rocco Caputo - Initial release, and ongoing management and maintenance. Cory G. Watson - Made formatting extensible and overridable. COPYRIGHT AND LICENSE This software is copyright (c) 2010-2013 by Rocco Caputo. This is free software; you may redistribute it and/or modify it under the same terms as the Perl 5 programming language itself. Dist-Zilla-Plugin-ChangelogFromGit-0.015/README.mkdn000644 000765 000024 00000036736 12202155010 022031 0ustar00trocstaff000000 000000 # NAME Dist::Zilla::Plugin::ChangelogFromGit - Write a Changes file from a project's git log. # VERSION version 0.015 # SYNOPSIS Here's an example dist.ini section showing all the current options and their default values. [ChangelogFromGit] max_age = 365 tag_regexp = ^v(\d+\.\d+)$ file_name = CHANGES wrap_column = 74 debug = 0 Variables don't need to be set to their default values. This is equivalent to the configuration above. [ChangelogFromGit] # DESCRIPTION This Dist::Zilla plugin turns a project's git commit log into a change log file. It's better than simply running \`git log > CHANGES\` in at least two ways. First, it understands release tags, and it uses them to group changes by release. Second, it reformats the changes to make them easier to read. And third, subclasses can change some or all of the reformatting to make change logs even easier to read. See this project's CHANGES file for sample output. Yes, this project uses itself to generate its own change log. Why not? # CONFIGURATION / PUBLIC ATTRIBUTES As seen in the ["SYNOPSIS"](#SYNOPSIS), this plugin has a number of public attributes that may be set using dist.ini configuration variables. ## max\_age = INTEGER The `max_age` configuration variable limits the age of releases to be included in the change log. The default is to include releases going back about a year. To include about two years, one would double the default value: [ChangelogFromGit] max_age = 730 `max_age` is intended to limit the size of change logs for large, long-term projects that don't want to include the entire, huge commit history in every release. ## tag\_regexp = REGULAR\_EXPRESSION `tag_regexp` sets the regular expression that detects which tags mark releases. It also extracts the version numbers from these tags using a regular expression back reference or capture. For example, a project's release tags might match 'release-1.000', 'release-1.001', etc. This `tag_regexp` will find them and extract their versions. [ChangelogFromGit] tag_regexp = ^release-(\d+.*)$ There is no single standard format for release tags. `tag_regexp` defaults to the author's convention. It will most likely need to be changed. ## file\_name = STRING `file_name` sets the name of the change log that will be written. It defaults to "CHANGES", but some people may prefer "Changes", "Changelog", or something else. [ChangelogFromGit] file_name = Changes ## wrap\_column = INTEGER Different contributors tend to use different commit message formats, which can be disconcerting to the typographically aware release engineer. `wrap_column` sets the line length to which all commit messages will be re-wrapped. It's 74 columns by default. If this is too short: [ChangelogFromGit] wrap_column = 78 ## debug = BOOLEAN Developers are people, too. The `debug` option enables some noisy runtime tracing on STDERR. [ChangelogFromGit] debug = 1 ## exclude\_message = REGULAR\_EXPRESSION `exclude_message` sets a regular expression which discards matching commit messages. This provides a way to exclude commit messages such as 'forgot to include file X' or 'typo'. The regular expression is case sensitive. [ChangelogFromGit] exclude_message = ^(forgot|typo) `include_message` can be used to do the opposite: exclude all changes except ones that match a regular expression. Using both at once is liable to generate empty change logs. ## include\_message = REGULAR\_EXPRESSION `include_message` does the opposite of `exclude_message`: it sets a regular expression which commit messages must match in order to be included in the Changes file. This means that when making a commit with a relevant message, you must include text that matches the regular expression pattern to have it included in the Changes file. All other commit messages are ignored. The regular expression is case sensitive. [ChangelogFromGit] include_message = ^Major Using both `include_message` and `exclude_message` at the same time will most likely result in empty change logs. # HOW IT WORKS Dist::Zilla::ChangelogFromGit collects the tags matching `tag_regexp` that are not older than `max_age` days old. These are used to identify and time stamp releases. Each release is encapsulated into a [Software::Release](http://search.cpan.org/perldoc?Software::Release) object. Git::Repository::Log::Iterator is used to collect the changes prior to each release but after the previous release. Change log entries are added to their respective Software::Release objects. `$self->render_changelog()` is called after all the relevant releases and changes are known. It must return the rendered change log as a string. That string will be used as the content for a [Dist::Zilla::File::InMemory](http://search.cpan.org/perldoc?Dist::Zilla::File::InMemory) object representing the new change log. # SUBCLASSING FOR NEW FORMATS Dist::Zilla::ChangelogFromGit implement about a dozen methods to render the various parts of a change log. Subclasses may override or augment any or all of these methods to alter the way change logs are rendered. All methods beginning with "render" return strings that will be incorporated into the change log. Methods that will not contribute to the change log must return empty strings. ## Rendering Entire Change Logs Methods beginning with "render\_changelog" receive no parameters other than $self. Everything they need to know about the change log is included in the object's attributes: `wrap_column`, `releases`, `skipped_release_count`, `earliest_date`. ### render\_changelog render\_changelog() returns the text of the entire change log. By default, the change log is built from a header, zero or more releases, and a footer. sub render_changelog { my $self = shift(); return( $self->render_changelog_header() . $self->render_changelog_releases() . $self->render_changelog_footer() ); } ### render\_changelog\_header render\_changelog\_header() renders some text that introduces the reader to the change log. sub render_changelog_header { my $self = shift(); my $header = ( "Changes from " . $self->format_datetime($self->earliest_date()) . " to present." ); return $self->surround_line("=", $header) . "\n"; } ### render\_changelog\_releases render\_changelog\_releases() iterates through each release, calling upon $self to render them one at a time. sub render_changelog_releases { my $self = shift(); my $changelog = ''; RELEASE: foreach my $release (reverse $self->all_releases()) { next RELEASE if $release->has_no_changes(); $changelog .= $self->render_release($release); } return $changelog; } ### render\_changelog\_footer render\_changelog\_footer() tells the reader that the change log is over. Normally the end of the file is sufficient warning, but a truncated change log is friendlier when the reader knows what they're missing. sub render_changelog_footer { my $self = shift(); my $skipped_count = $self->skipped_release_count(); my $changelog_footer; if ($skipped_count) { my $releases = "release" . ($skipped_count == 1 ? "" : "s"); $changelog_footer = ( "Plus $skipped_count $releases after " . $self->format_datetime($self->earliest_date()) . '.' ); } else { $changelog_footer = "End of releases."; } return $self->surround_line("=", $changelog_footer); } ## Rendering Individual Releases Methods beginning with "render\_release" receive $self plus one additional parameter: a Software::Release object encapsulating the release and its changes. See [Software::Release](http://search.cpan.org/perldoc?Software::Release) to learn the information that object encapsulates. ### render\_release render\_release() is called upon to render a single release. In the change log, a release consists of a header, one or more changes, and a footer. sub render_release { my ($self, $release) = @_; return( $self->render_release_header($release) . $self->render_release_changes($release) . $self->render_release_footer($release) ); } ### render\_release\_header render\_release\_header() introduces a release. sub render_release_header { my ($self, $release) = @_; my $version = $release->version(); $version = $self->zilla()->version() if $version eq 'HEAD'; my $release_header = ( $self->format_release_tag($release->version()) . ' at ' . $self->format_datetime($release->date()) ); return $self->surround_line("-", $release_header) . "\n"; } ### render\_release\_changes render\_release\_changes() iterates through the changes associated with each Software::Release object. It calls upon render\_change() to render each change. sub render_release_changes { my ($self, $release) = @_; my $changelog = ''; foreach my $change (@{ $release->changes() }) { $changelog .= $self->render_change($release, $change); } return $changelog; } ### render\_release\_footer render\_release\_footer() may be used to divide releases. It's not used by default, but it's implemented for completeness. sub render_release_footer { my ($self, $release) = @_; return ''; } ## Rendering Individual Changes Methods beginning with "render\_change" receive two parameters in addition to $self: a [Software::Release](http://search.cpan.org/perldoc?Software::Release) object encapsulating the release containing this change, and a [Software::Release::Change](http://search.cpan.org/perldoc?Software::Release::Change) object encapsulating the change itself. ### render\_change render\_change() renders a single change, which is the catenation of a change header, change message, and footer. sub render_change { my ($self, $release, $change) = @_; return( $self->render_change_header($release, $change) . $self->render_change_message($release, $change) . $self->render_change_footer($release, $change) ); } ### render\_change\_header render\_change\_header() generally renders identifying information about each change. This method's responsibility is to produce useful information in a pleasant format. sub render_change_header { my ($self, $release, $change) = @_; use Text::Wrap qw(fill); local $Text::Wrap::huge = 'wrap'; local $Text::Wrap::columns = $self->wrap_column(); my @indent = (" ", " "); return( fill( " ", " ", 'Change: ' . $change->change_id ) . "\n" . fill( " ", " ", 'Author: ' . $change->author_name.' <'.$change->author_email.'>' ) . "\n" . fill( " ", " ", 'Date : ' . $self->format_datetime($change->date()) ) . "\n\n" ); } ### render\_change\_message render\_change\_message() renders the commit message for the change log. sub render_change_message { my ($self, $release, $change) = @_; use Text::Wrap qw(fill); return '' if $change->description() =~ /^\s/; local $Text::Wrap::huge = 'wrap'; local $Text::Wrap::columns = $self->wrap_column(); return fill(" ", " ", $change->description) . "\n"; } ### render\_change\_footer render\_change\_footer() returns summary and/or divider text for the change. sub render_change_footer { my ($self, $release, $change) = @_; return "\n"; } ## Formatting Data Dist::Zilla::Plugin::ChangelogFromGit includes a few methods to consistently format certain data types. ### format\_datetime format\_datetime() converts the [DateTime](http://search.cpan.org/perldoc?DateTime) objects used internally into friendly, human readable dates and times for the change log. sub format_datetime { my ($self, $datetime) = @_; return $datetime->strftime("%F %T %z"); } ### format\_release\_tag format\_release\_tag() turns potentially cryptic release tags into friendly version numbers for the change log. By default, it also replaces the 'HEAD' version with the current version being released. This accommodates release managers who prefer to tag their distributions after releasing them. sub format_release_tag { my ($self, $release_tag) = @_; return 'version ' . $self->zilla()->version() if $release_tag eq 'HEAD'; my $tag_regexp = $self->tag_regexp(); $release_tag =~ s/$tag_regexp/version $1/; return $release_tag; } ### surround\_line surround\_line() will surround a line of output with lines of dashes or other characters. It's used to help heading stand out. This method takes two strings: a character (or string) that will repeat to fill surrounding lines, and the line to surround. It returns a three-line string: the original line preceded and followed by surrounding lines. sub surround_line { my ($self, $character, $string) = @_; my $surrounder = substr( ($character x (length($string) / length($character) + 1)), 0, length($string) ); return "$surrounder\n$string\n$surrounder\n"; } # INTERNAL ATTRIBUTES Dist::Zilla::Plugin::ChangelogFromGit accumulates useful information into a few internal attributes. These aren't intended to be configured by dist.ini, but they are important for rendering change logs. ## earliest\_date earliest\_date() contains a [DateTime](http://search.cpan.org/perldoc?DateTime) object that represents the date and time of the earliest release to include. It's initialized as midnight for the date max\_age() days ago. ## releases releases() contains an array reference of [Software::Release](http://search.cpan.org/perldoc?Software::Release) objects that will be included in the change log. ### all\_releases all\_releases() returns a list of the Software::Release objects that should be included in the change log. It's a friendly equivalent of `@{$self->releases()}`. ### get\_release get\_release() returns a single release by index. The first release in the change log may be retrieved as `$self->get_release(0)`. ### releae\_count release\_count() returns the number of Software::Release objects in the ["releases"](#releases) attribute. ### sort\_releases sort\_releases() sorts the Software::Release objects in the releases() using some comparator. For example, to sort releases in time order: $self->sort_releases( sub { DateTime->compare( $_[0]->date(), $_[1]->date() ) } ); ## skipped\_release\_count skipped\_release\_count() contains the number of releases truncated by max\_age(). The default render\_changelog\_footer() uses it to display the number of changes that have been omitted from the log. # Subversion and CVS This plugin is almost entirely a copy-and-paste port of a command-line tool I wrote a while ago. I also have tools to generate similar change logs for CVS and Subversion projects. I'm happy to contribute that code to people interested in creating Dist::Zilla plugins for other version control systems. We should also consider abstracting the formatting code out to a role so that it can be shared among different plugins. # BUGS The documentation includes copies of the renderer methods. This increases technical debt, since changes to those methods must also be copied into the documentation. Rocco needs to finish [Pod::Plexus](http://search.cpan.org/perldoc?Pod::Plexus) and use it here to simplify maintenance of the documentation. Collecting all releases and changes before rendering the change log may be considered harmful for extremely large projects. If someone thinks they can generate change logs incrementally, their assistance would be appreciated. # AUTHORS Rocco Caputo - Initial release, and ongoing management and maintenance. Cory G. Watson - Made formatting extensible and overridable. # COPYRIGHT AND LICENSE This software is copyright (c) 2010-2013 by Rocco Caputo. This is free software; you may redistribute it and/or modify it under the same terms as the Perl 5 programming language itself. Dist-Zilla-Plugin-ChangelogFromGit-0.015/t/000755 000765 000024 00000000000 12202155010 020445 5ustar00trocstaff000000 000000 Dist-Zilla-Plugin-ChangelogFromGit-0.015/t/000-report-versions.t000644 000765 000024 00000031270 12202155010 024313 0ustar00trocstaff000000 000000 #!perl use warnings; use strict; use Test::More 0.94; # Include a cut-down version of YAML::Tiny so we don't introduce unnecessary # dependencies ourselves. package Local::YAML::Tiny; use strict; use Carp 'croak'; # UTF Support? sub HAVE_UTF8 () { $] >= 5.007003 } BEGIN { if ( HAVE_UTF8 ) { # The string eval helps hide this from Test::MinimumVersion eval "require utf8;"; die "Failed to load UTF-8 support" if $@; } # Class structure require 5.004; $YAML::Tiny::VERSION = '1.40'; # Error storage $YAML::Tiny::errstr = ''; } # Printable characters for escapes my %UNESCAPES = ( z => "\x00", a => "\x07", t => "\x09", n => "\x0a", v => "\x0b", f => "\x0c", r => "\x0d", e => "\x1b", '\\' => '\\', ); ##################################################################### # Implementation # Create an empty YAML::Tiny object sub new { my $class = shift; bless [ @_ ], $class; } # Create an object from a file sub read { my $class = ref $_[0] ? ref shift : shift; # Check the file my $file = shift or return $class->_error( 'You did not specify a file name' ); return $class->_error( "File '$file' does not exist" ) unless -e $file; return $class->_error( "'$file' is a directory, not a file" ) unless -f _; return $class->_error( "Insufficient permissions to read '$file'" ) unless -r _; # Slurp in the file local $/ = undef; local *CFG; unless ( open(CFG, $file) ) { return $class->_error("Failed to open file '$file': $!"); } my $contents = ; unless ( close(CFG) ) { return $class->_error("Failed to close file '$file': $!"); } $class->read_string( $contents ); } # Create an object from a string sub read_string { my $class = ref $_[0] ? ref shift : shift; my $self = bless [], $class; my $string = $_[0]; unless ( defined $string ) { return $self->_error("Did not provide a string to load"); } # Byte order marks # NOTE: Keeping this here to educate maintainers # my %BOM = ( # "\357\273\277" => 'UTF-8', # "\376\377" => 'UTF-16BE', # "\377\376" => 'UTF-16LE', # "\377\376\0\0" => 'UTF-32LE' # "\0\0\376\377" => 'UTF-32BE', # ); if ( $string =~ /^(?:\376\377|\377\376|\377\376\0\0|\0\0\376\377)/ ) { return $self->_error("Stream has a non UTF-8 BOM"); } else { # Strip UTF-8 bom if found, we'll just ignore it $string =~ s/^\357\273\277//; } # Try to decode as utf8 utf8::decode($string) if HAVE_UTF8; # Check for some special cases return $self unless length $string; unless ( $string =~ /[\012\015]+\z/ ) { return $self->_error("Stream does not end with newline character"); } # Split the file into lines my @lines = grep { ! /^\s*(?:\#.*)?\z/ } split /(?:\015{1,2}\012|\015|\012)/, $string; # Strip the initial YAML header @lines and $lines[0] =~ /^\%YAML[: ][\d\.]+.*\z/ and shift @lines; # A nibbling parser while ( @lines ) { # Do we have a document header? if ( $lines[0] =~ /^---\s*(?:(.+)\s*)?\z/ ) { # Handle scalar documents shift @lines; if ( defined $1 and $1 !~ /^(?:\#.+|\%YAML[: ][\d\.]+)\z/ ) { push @$self, $self->_read_scalar( "$1", [ undef ], \@lines ); next; } } if ( ! @lines or $lines[0] =~ /^(?:---|\.\.\.)/ ) { # A naked document push @$self, undef; while ( @lines and $lines[0] !~ /^---/ ) { shift @lines; } } elsif ( $lines[0] =~ /^\s*\-/ ) { # An array at the root my $document = [ ]; push @$self, $document; $self->_read_array( $document, [ 0 ], \@lines ); } elsif ( $lines[0] =~ /^(\s*)\S/ ) { # A hash at the root my $document = { }; push @$self, $document; $self->_read_hash( $document, [ length($1) ], \@lines ); } else { croak("YAML::Tiny failed to classify the line '$lines[0]'"); } } $self; } # Deparse a scalar string to the actual scalar sub _read_scalar { my ($self, $string, $indent, $lines) = @_; # Trim trailing whitespace $string =~ s/\s*\z//; # Explitic null/undef return undef if $string eq '~'; # Quotes if ( $string =~ /^\'(.*?)\'\z/ ) { return '' unless defined $1; $string = $1; $string =~ s/\'\'/\'/g; return $string; } if ( $string =~ /^\"((?:\\.|[^\"])*)\"\z/ ) { # Reusing the variable is a little ugly, # but avoids a new variable and a string copy. $string = $1; $string =~ s/\\"/"/g; $string =~ s/\\([never\\fartz]|x([0-9a-fA-F]{2}))/(length($1)>1)?pack("H2",$2):$UNESCAPES{$1}/gex; return $string; } # Special cases if ( $string =~ /^[\'\"!&]/ ) { croak("YAML::Tiny does not support a feature in line '$lines->[0]'"); } return {} if $string eq '{}'; return [] if $string eq '[]'; # Regular unquoted string return $string unless $string =~ /^[>|]/; # Error croak("YAML::Tiny failed to find multi-line scalar content") unless @$lines; # Check the indent depth $lines->[0] =~ /^(\s*)/; $indent->[-1] = length("$1"); if ( defined $indent->[-2] and $indent->[-1] <= $indent->[-2] ) { croak("YAML::Tiny found bad indenting in line '$lines->[0]'"); } # Pull the lines my @multiline = (); while ( @$lines ) { $lines->[0] =~ /^(\s*)/; last unless length($1) >= $indent->[-1]; push @multiline, substr(shift(@$lines), length($1)); } my $j = (substr($string, 0, 1) eq '>') ? ' ' : "\n"; my $t = (substr($string, 1, 1) eq '-') ? '' : "\n"; return join( $j, @multiline ) . $t; } # Parse an array sub _read_array { my ($self, $array, $indent, $lines) = @_; while ( @$lines ) { # Check for a new document if ( $lines->[0] =~ /^(?:---|\.\.\.)/ ) { while ( @$lines and $lines->[0] !~ /^---/ ) { shift @$lines; } return 1; } # Check the indent level $lines->[0] =~ /^(\s*)/; if ( length($1) < $indent->[-1] ) { return 1; } elsif ( length($1) > $indent->[-1] ) { croak("YAML::Tiny found bad indenting in line '$lines->[0]'"); } if ( $lines->[0] =~ /^(\s*\-\s+)[^\'\"]\S*\s*:(?:\s+|$)/ ) { # Inline nested hash my $indent2 = length("$1"); $lines->[0] =~ s/-/ /; push @$array, { }; $self->_read_hash( $array->[-1], [ @$indent, $indent2 ], $lines ); } elsif ( $lines->[0] =~ /^\s*\-(\s*)(.+?)\s*\z/ ) { # Array entry with a value shift @$lines; push @$array, $self->_read_scalar( "$2", [ @$indent, undef ], $lines ); } elsif ( $lines->[0] =~ /^\s*\-\s*\z/ ) { shift @$lines; unless ( @$lines ) { push @$array, undef; return 1; } if ( $lines->[0] =~ /^(\s*)\-/ ) { my $indent2 = length("$1"); if ( $indent->[-1] == $indent2 ) { # Null array entry push @$array, undef; } else { # Naked indenter push @$array, [ ]; $self->_read_array( $array->[-1], [ @$indent, $indent2 ], $lines ); } } elsif ( $lines->[0] =~ /^(\s*)\S/ ) { push @$array, { }; $self->_read_hash( $array->[-1], [ @$indent, length("$1") ], $lines ); } else { croak("YAML::Tiny failed to classify line '$lines->[0]'"); } } elsif ( defined $indent->[-2] and $indent->[-1] == $indent->[-2] ) { # This is probably a structure like the following... # --- # foo: # - list # bar: value # # ... so lets return and let the hash parser handle it return 1; } else { croak("YAML::Tiny failed to classify line '$lines->[0]'"); } } return 1; } # Parse an array sub _read_hash { my ($self, $hash, $indent, $lines) = @_; while ( @$lines ) { # Check for a new document if ( $lines->[0] =~ /^(?:---|\.\.\.)/ ) { while ( @$lines and $lines->[0] !~ /^---/ ) { shift @$lines; } return 1; } # Check the indent level $lines->[0] =~ /^(\s*)/; if ( length($1) < $indent->[-1] ) { return 1; } elsif ( length($1) > $indent->[-1] ) { croak("YAML::Tiny found bad indenting in line '$lines->[0]'"); } # Get the key unless ( $lines->[0] =~ s/^\s*([^\'\" ][^\n]*?)\s*:(\s+|$)// ) { if ( $lines->[0] =~ /^\s*[?\'\"]/ ) { croak("YAML::Tiny does not support a feature in line '$lines->[0]'"); } croak("YAML::Tiny failed to classify line '$lines->[0]'"); } my $key = $1; # Do we have a value? if ( length $lines->[0] ) { # Yes $hash->{$key} = $self->_read_scalar( shift(@$lines), [ @$indent, undef ], $lines ); } else { # An indent shift @$lines; unless ( @$lines ) { $hash->{$key} = undef; return 1; } if ( $lines->[0] =~ /^(\s*)-/ ) { $hash->{$key} = []; $self->_read_array( $hash->{$key}, [ @$indent, length($1) ], $lines ); } elsif ( $lines->[0] =~ /^(\s*)./ ) { my $indent2 = length("$1"); if ( $indent->[-1] >= $indent2 ) { # Null hash entry $hash->{$key} = undef; } else { $hash->{$key} = {}; $self->_read_hash( $hash->{$key}, [ @$indent, length($1) ], $lines ); } } } } return 1; } # Set error sub _error { $YAML::Tiny::errstr = $_[1]; undef; } # Retrieve error sub errstr { $YAML::Tiny::errstr; } ##################################################################### # Use Scalar::Util if possible, otherwise emulate it BEGIN { eval { require Scalar::Util; }; if ( $@ ) { # Failed to load Scalar::Util eval <<'END_PERL'; sub refaddr { my $pkg = ref($_[0]) or return undef; if (!!UNIVERSAL::can($_[0], 'can')) { bless $_[0], 'Scalar::Util::Fake'; } else { $pkg = undef; } "$_[0]" =~ /0x(\w+)/; my $i = do { local $^W; hex $1 }; bless $_[0], $pkg if defined $pkg; $i; } END_PERL } else { Scalar::Util->import('refaddr'); } } ##################################################################### # main test ##################################################################### package main; BEGIN { # Skip modules that either don't want to be loaded directly, such as # Module::Install, or that mess with the test count, such as the Test::* # modules listed here. # # Moose::Role conflicts if Moose is loaded as well, but Moose::Role is in # the Moose distribution and it's certain that someone who uses # Moose::Role also uses Moose somewhere, so if we disallow Moose::Role, # we'll still get the relevant version number. my %skip = map { $_ => 1 } qw( App::FatPacker Class::Accessor::Classy Devel::Cover Module::Install Moose::Role POE::Loop::Tk Template::Test Test::Kwalitee Test::Pod::Coverage Test::Portability::Files Test::YAML::Meta open ); my $Test = Test::Builder->new; $Test->plan(skip_all => "META.yml could not be found") unless -f 'META.yml' and -r _; my $meta = (Local::YAML::Tiny->read('META.yml'))->[0]; my %requires; for my $require_key (grep { /requires/ } keys %$meta) { my %h = %{ $meta->{$require_key} }; $requires{$_}++ for keys %h; } delete $requires{perl}; diag("Testing with Perl $], $^X"); for my $module (sort keys %requires) { if ($skip{$module}) { note "$module doesn't want to be loaded directly, skipping"; next; } local $SIG{__WARN__} = sub { note "$module: $_[0]" }; require_ok $module or BAIL_OUT("can't load $module"); my $version = $module->VERSION; $version = 'undefined' unless defined $version; diag(" $module version is $version"); } done_testing; } Dist-Zilla-Plugin-ChangelogFromGit-0.015/t/release-pod-coverage.t000644 000765 000024 00000000765 12202155010 024633 0ustar00trocstaff000000 000000 #!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use Test::More; eval "use Test::Pod::Coverage 1.08"; plan skip_all => "Test::Pod::Coverage 1.08 required for testing POD coverage" if $@; eval "use Pod::Coverage::TrustPod"; plan skip_all => "Pod::Coverage::TrustPod required for testing POD coverage" if $@; all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' }); Dist-Zilla-Plugin-ChangelogFromGit-0.015/t/release-pod-syntax.t000644 000765 000024 00000000450 12202155010 024355 0ustar00trocstaff000000 000000 #!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use Test::More; eval "use Test::Pod 1.41"; plan skip_all => "Test::Pod 1.41 required for testing POD" if $@; all_pod_files_ok(); Dist-Zilla-Plugin-ChangelogFromGit-0.015/lib/Dist/000755 000765 000024 00000000000 12202155010 021653 5ustar00trocstaff000000 000000 Dist-Zilla-Plugin-ChangelogFromGit-0.015/lib/Dist/Zilla/000755 000765 000024 00000000000 12202155010 022726 5ustar00trocstaff000000 000000 Dist-Zilla-Plugin-ChangelogFromGit-0.015/lib/Dist/Zilla/Plugin/000755 000765 000024 00000000000 12202155010 024164 5ustar00trocstaff000000 000000 Dist-Zilla-Plugin-ChangelogFromGit-0.015/lib/Dist/Zilla/Plugin/ChangelogFromGit.pm000755 000765 000024 00000057202 12202155010 027712 0ustar00trocstaff000000 000000 package Dist::Zilla::Plugin::ChangelogFromGit; { $Dist::Zilla::Plugin::ChangelogFromGit::VERSION = '0.015'; } # Indent style: # http://www.emacswiki.org/emacs/SmartTabs # http://www.vim.org/scripts/script.php?script_id=231 # # vim: noexpandtab # ABSTRACT: Write a Changes file from a project's git log. use Moose; use Moose::Autobox; with 'Dist::Zilla::Role::FileGatherer'; use DateTime; use DateTime::Infinite; use Software::Release; use Software::Release::Change; use Git::Repository::Log::Iterator; use IPC::Cmd qw/run/; has max_age => ( is => 'ro', isa => 'Int', default => 365, ); has tag_regexp => ( is => 'ro', isa => 'Str', default => '^v(\\d+\\.\\d+)$', ); has file_name => ( is => 'ro', isa => 'Str', default => 'CHANGES', ); has wrap_column => ( is => 'ro', isa => 'Int', default => 74, ); has debug => ( is => 'ro', isa => 'Int', default => 0, ); has releases => ( is => 'rw', isa => 'ArrayRef[Software::Release]', traits => [ 'Array' ], handles => { push_release => 'push', sort_releases => 'sort_in_place', release_count => 'count', get_release => 'get', all_releases => 'elements', }, default => sub { [] }, ); has skipped_release_count => ( is => 'rw', isa => 'Int', default => 0, traits => [ 'Number' ], handles => { add_skipped_release => 'add', }, ); has earliest_date => ( is => 'ro', isa => 'DateTime', lazy => 1, default => sub { my $self = shift(); DateTime->now()->subtract(days => $self->max_age())->truncate(to=> 'day'); }, ); has include_message => ( is => 'ro', isa => 'Str', ); has exclude_message => ( is => 'ro', isa => 'Str', ); sub gather_files { my ($self, $arg) = @_; # Find all release tags back to the earliest changelog date. my $earliest_date = $self->earliest_date(); my @tags = $self->rungit([qw/git tag/]); my @head_version_per_tag = (); { my $tag_pattern = $self->tag_regexp(); my $i = @tags; while ($i--) { unless ($tags[$i] =~ /$tag_pattern/o) { splice @tags, $i, 1; next; } my $commit = ''; foreach ($self->rungit(['git', 'show', "refs/tags/$tags[$i]", "--pretty='tformat:(((((%ct)))))"])) { next if (! /\(\(\(\(\(/); $commit = $_; last; } die "Failed to find our pretty print format ((((( for tag $tags[$i]: $commit" unless $commit =~ /\(\(\(\(\((\d+?)\)\)\)\)\)/; push(@head_version_per_tag, ($self->rungit(['git', 'rev-list', "refs/tags/$tags[$i]"]))[0]); $self->push_release( Software::Release->new( date => DateTime->from_epoch(epoch => $1), version => $tags[$i] ) ); } } # Add a virtual release for the most recent change in the # repository. This lets us include changes after the last # releases, up to "HEAD". { my $head_version = ($self->rungit([qw/git rev-list HEAD/]))[0]; if ( not $self->all_releases or ! grep {$head_version eq $_} @head_version_per_tag) { $self->push_release( Software::Release->new( date => DateTime->now(), version => 'HEAD', ) ); } } $self->sort_releases( sub { DateTime->compare( $_[0]->date(), $_[1]->date() ) } ); { my $i = $self->release_count(); while ($i--) { my $this_release = $self->get_release($i); if (DateTime->compare($this_release->date, $earliest_date) == -1) { $self->add_skipped_release(1); next; } my $prev_version = ( $i ? ($self->get_release($i-1)->version() . '..') : '' ); my $release_range = $prev_version . $this_release->version(); warn ">>> $release_range\n" if $self->debug(); my $exclude_message_re = $self->exclude_message(); my $include_message_re = $self->include_message(); my $iter = Git::Repository::Log::Iterator->new($release_range); while (my $log = $iter->next) { next if ( defined $exclude_message_re and $log->message() =~ /$exclude_message_re/o ); next if ( defined $include_message_re and $log->message() !~ /$include_message_re/o ); #print STDERR "LOG: ".$log->message."\n"; warn(" ", $log->commit(), " ", $log->committer_localtime, "\n") if ( $self->debug() ); $this_release->add_to_changes( Software::Release::Change->new( author_email => $log->author_email, author_name => $log->author_name, change_id => $log->commit, committer_email => $log->committer_email, committer_name => $log->committer_name, date => DateTime->from_epoch(epoch => $log->committer_localtime), description => $log->message ) ); }; } } my $file = Dist::Zilla::File::InMemory->new( { content => $self->render_changelog(), name => $self->file_name(), } ); $self->add_file($file); } ### Render the changelog. sub render_changelog { my $self = shift(); return( $self->render_changelog_header() . $self->render_changelog_releases() . $self->render_changelog_footer() ); } sub render_changelog_header { my $self = shift(); my $header = ( "Changes from " . $self->format_datetime($self->earliest_date()) . " to present." ); return $self->surround_line("=", $header) . "\n"; } sub render_changelog_footer { my $self = shift(); my $skipped_count = $self->skipped_release_count(); my $changelog_footer; if ($skipped_count) { my $releases = "release" . ($skipped_count == 1 ? "" : "s"); $changelog_footer = ( "Plus $skipped_count $releases after " . $self->format_datetime($self->earliest_date()) . '.' ); } else { $changelog_footer = "End of releases."; } return $self->surround_line("=", $changelog_footer); } sub render_changelog_releases { my $self = shift(); my $changelog = ''; RELEASE: foreach my $release (reverse $self->all_releases()) { next RELEASE if $release->has_no_changes(); $changelog .= $self->render_release($release); } return $changelog; } ### Render a release. sub render_release { my ($self, $release) = @_; return( $self->render_release_header($release) . $self->render_release_changes($release) . $self->render_release_footer($release) ); } sub render_release_header { my ($self, $release) = @_; my $version = $release->version(); $version = $self->zilla()->version() if $version eq 'HEAD'; my $release_header = ( $self->format_release_tag($release->version()) . ' at ' . $self->format_datetime($release->date()) ); return $self->surround_line("-", $release_header) . "\n"; } sub render_release_footer { my ($self, $release) = @_; return ''; } sub render_release_changes { my ($self, $release) = @_; my $changelog = ''; foreach my $change (@{ $release->changes() }) { $changelog .= $self->render_change($release, $change); } return $changelog; } ### Render a change. sub render_change { my ($self, $release, $change) = @_; return( $self->render_change_header($release, $change) . $self->render_change_message($release, $change) . $self->render_change_footer($release, $change) ); } sub render_change_header { my ($self, $release, $change) = @_; use Text::Wrap qw(fill); local $Text::Wrap::huge = 'wrap'; local $Text::Wrap::columns = $self->wrap_column(); my @indent = (" ", " "); return( fill( " ", " ", 'Change: ' . $change->change_id ) . "\n" . fill( " ", " ", 'Author: ' . $change->author_name.' <'.$change->author_email.'>' ) . "\n" . fill( " ", " ", 'Date : ' . $self->format_datetime($change->date()) ) . "\n\n" ); } sub render_change_footer { my ($self, $release, $change) = @_; return "\n"; } sub render_change_message { my ($self, $release, $change) = @_; use Text::Wrap qw(fill); return '' if $change->description() =~ /^\s/; local $Text::Wrap::huge = 'wrap'; local $Text::Wrap::columns = $self->wrap_column(); return fill(" ", " ", $change->description) . "\n"; } ### Helpers. sub surround_line { my ($self, $character, $string) = @_; my $surrounder = substr( ($character x (length($string) / length($character) + 1)), 0, length($string) ); return "$surrounder\n$string\n$surrounder\n"; } sub format_release_tag { my ($self, $release_tag) = @_; return 'version ' . $self->zilla()->version() if $release_tag eq 'HEAD'; my $tag_regexp = $self->tag_regexp(); $release_tag =~ s/$tag_regexp/version $1/; return $release_tag; } sub format_datetime { my ($self, $datetime) = @_; return $datetime->strftime("%F %T %z"); } sub rungit { my ($self, $arrayp) = @_; my $buf; run(command => $arrayp, buffer => \$buf); return split("\n", $buf); } __PACKAGE__->meta->make_immutable; no Moose; 1; __END__ =head1 NAME Dist::Zilla::Plugin::ChangelogFromGit - Write a Changes file from a project's git log. =head1 VERSION version 0.015 =head1 SYNOPSIS Here's an example dist.ini section showing all the current options and their default values. [ChangelogFromGit] max_age = 365 tag_regexp = ^v(\d+\.\d+)$ file_name = CHANGES wrap_column = 74 debug = 0 Variables don't need to be set to their default values. This is equivalent to the configuration above. [ChangelogFromGit] =head1 DESCRIPTION This Dist::Zilla plugin turns a project's git commit log into a change log file. It's better than simply running `git log > CHANGES` in at least two ways. First, it understands release tags, and it uses them to group changes by release. Second, it reformats the changes to make them easier to read. And third, subclasses can change some or all of the reformatting to make change logs even easier to read. See this project's CHANGES file for sample output. Yes, this project uses itself to generate its own change log. Why not? =head1 CONFIGURATION / PUBLIC ATTRIBUTES As seen in the L, this plugin has a number of public attributes that may be set using dist.ini configuration variables. =head2 max_age = INTEGER The C configuration variable limits the age of releases to be included in the change log. The default is to include releases going back about a year. To include about two years, one would double the default value: [ChangelogFromGit] max_age = 730 C is intended to limit the size of change logs for large, long-term projects that don't want to include the entire, huge commit history in every release. =head2 tag_regexp = REGULAR_EXPRESSION C sets the regular expression that detects which tags mark releases. It also extracts the version numbers from these tags using a regular expression back reference or capture. For example, a project's release tags might match 'release-1.000', 'release-1.001', etc. This C will find them and extract their versions. [ChangelogFromGit] tag_regexp = ^release-(\d+.*)$ There is no single standard format for release tags. C defaults to the author's convention. It will most likely need to be changed. =head2 file_name = STRING C sets the name of the change log that will be written. It defaults to "CHANGES", but some people may prefer "Changes", "Changelog", or something else. [ChangelogFromGit] file_name = Changes =head2 wrap_column = INTEGER Different contributors tend to use different commit message formats, which can be disconcerting to the typographically aware release engineer. C sets the line length to which all commit messages will be re-wrapped. It's 74 columns by default. If this is too short: [ChangelogFromGit] wrap_column = 78 =head2 debug = BOOLEAN Developers are people, too. The C option enables some noisy runtime tracing on STDERR. [ChangelogFromGit] debug = 1 =head2 exclude_message = REGULAR_EXPRESSION C sets a regular expression which discards matching commit messages. This provides a way to exclude commit messages such as 'forgot to include file X' or 'typo'. The regular expression is case sensitive. [ChangelogFromGit] exclude_message = ^(forgot|typo) C can be used to do the opposite: exclude all changes except ones that match a regular expression. Using both at once is liable to generate empty change logs. =head2 include_message = REGULAR_EXPRESSION C does the opposite of C: it sets a regular expression which commit messages must match in order to be included in the Changes file. This means that when making a commit with a relevant message, you must include text that matches the regular expression pattern to have it included in the Changes file. All other commit messages are ignored. The regular expression is case sensitive. [ChangelogFromGit] include_message = ^Major Using both C and C at the same time will most likely result in empty change logs. =head1 HOW IT WORKS Dist::Zilla::ChangelogFromGit collects the tags matching C that are not older than C days old. These are used to identify and time stamp releases. Each release is encapsulated into a L object. Git::Repository::Log::Iterator is used to collect the changes prior to each release but after the previous release. Change log entries are added to their respective Software::Release objects. C<< $self->render_changelog() >> is called after all the relevant releases and changes are known. It must return the rendered change log as a string. That string will be used as the content for a L object representing the new change log. =head1 SUBCLASSING FOR NEW FORMATS Dist::Zilla::ChangelogFromGit implement about a dozen methods to render the various parts of a change log. Subclasses may override or augment any or all of these methods to alter the way change logs are rendered. All methods beginning with "render" return strings that will be incorporated into the change log. Methods that will not contribute to the change log must return empty strings. =head2 Rendering Entire Change Logs Methods beginning with "render_changelog" receive no parameters other than $self. Everything they need to know about the change log is included in the object's attributes: C, C, C, C. =head3 render_changelog render_changelog() returns the text of the entire change log. By default, the change log is built from a header, zero or more releases, and a footer. sub render_changelog { my $self = shift(); return( $self->render_changelog_header() . $self->render_changelog_releases() . $self->render_changelog_footer() ); } =head3 render_changelog_header render_changelog_header() renders some text that introduces the reader to the change log. sub render_changelog_header { my $self = shift(); my $header = ( "Changes from " . $self->format_datetime($self->earliest_date()) . " to present." ); return $self->surround_line("=", $header) . "\n"; } =head3 render_changelog_releases render_changelog_releases() iterates through each release, calling upon $self to render them one at a time. sub render_changelog_releases { my $self = shift(); my $changelog = ''; RELEASE: foreach my $release (reverse $self->all_releases()) { next RELEASE if $release->has_no_changes(); $changelog .= $self->render_release($release); } return $changelog; } =head3 render_changelog_footer render_changelog_footer() tells the reader that the change log is over. Normally the end of the file is sufficient warning, but a truncated change log is friendlier when the reader knows what they're missing. sub render_changelog_footer { my $self = shift(); my $skipped_count = $self->skipped_release_count(); my $changelog_footer; if ($skipped_count) { my $releases = "release" . ($skipped_count == 1 ? "" : "s"); $changelog_footer = ( "Plus $skipped_count $releases after " . $self->format_datetime($self->earliest_date()) . '.' ); } else { $changelog_footer = "End of releases."; } return $self->surround_line("=", $changelog_footer); } =head2 Rendering Individual Releases Methods beginning with "render_release" receive $self plus one additional parameter: a Software::Release object encapsulating the release and its changes. See L to learn the information that object encapsulates. =head3 render_release render_release() is called upon to render a single release. In the change log, a release consists of a header, one or more changes, and a footer. sub render_release { my ($self, $release) = @_; return( $self->render_release_header($release) . $self->render_release_changes($release) . $self->render_release_footer($release) ); } =head3 render_release_header render_release_header() introduces a release. sub render_release_header { my ($self, $release) = @_; my $version = $release->version(); $version = $self->zilla()->version() if $version eq 'HEAD'; my $release_header = ( $self->format_release_tag($release->version()) . ' at ' . $self->format_datetime($release->date()) ); return $self->surround_line("-", $release_header) . "\n"; } =head3 render_release_changes render_release_changes() iterates through the changes associated with each Software::Release object. It calls upon render_change() to render each change. sub render_release_changes { my ($self, $release) = @_; my $changelog = ''; foreach my $change (@{ $release->changes() }) { $changelog .= $self->render_change($release, $change); } return $changelog; } =head3 render_release_footer render_release_footer() may be used to divide releases. It's not used by default, but it's implemented for completeness. sub render_release_footer { my ($self, $release) = @_; return ''; } =head2 Rendering Individual Changes Methods beginning with "render_change" receive two parameters in addition to $self: a L object encapsulating the release containing this change, and a L object encapsulating the change itself. =head3 render_change render_change() renders a single change, which is the catenation of a change header, change message, and footer. sub render_change { my ($self, $release, $change) = @_; return( $self->render_change_header($release, $change) . $self->render_change_message($release, $change) . $self->render_change_footer($release, $change) ); } =head3 render_change_header render_change_header() generally renders identifying information about each change. This method's responsibility is to produce useful information in a pleasant format. sub render_change_header { my ($self, $release, $change) = @_; use Text::Wrap qw(fill); local $Text::Wrap::huge = 'wrap'; local $Text::Wrap::columns = $self->wrap_column(); my @indent = (" ", " "); return( fill( " ", " ", 'Change: ' . $change->change_id ) . "\n" . fill( " ", " ", 'Author: ' . $change->author_name.' <'.$change->author_email.'>' ) . "\n" . fill( " ", " ", 'Date : ' . $self->format_datetime($change->date()) ) . "\n\n" ); } =head3 render_change_message render_change_message() renders the commit message for the change log. sub render_change_message { my ($self, $release, $change) = @_; use Text::Wrap qw(fill); return '' if $change->description() =~ /^\s/; local $Text::Wrap::huge = 'wrap'; local $Text::Wrap::columns = $self->wrap_column(); return fill(" ", " ", $change->description) . "\n"; } =head3 render_change_footer render_change_footer() returns summary and/or divider text for the change. sub render_change_footer { my ($self, $release, $change) = @_; return "\n"; } =head2 Formatting Data Dist::Zilla::Plugin::ChangelogFromGit includes a few methods to consistently format certain data types. =head3 format_datetime format_datetime() converts the L objects used internally into friendly, human readable dates and times for the change log. sub format_datetime { my ($self, $datetime) = @_; return $datetime->strftime("%F %T %z"); } =head3 format_release_tag format_release_tag() turns potentially cryptic release tags into friendly version numbers for the change log. By default, it also replaces the 'HEAD' version with the current version being released. This accommodates release managers who prefer to tag their distributions after releasing them. sub format_release_tag { my ($self, $release_tag) = @_; return 'version ' . $self->zilla()->version() if $release_tag eq 'HEAD'; my $tag_regexp = $self->tag_regexp(); $release_tag =~ s/$tag_regexp/version $1/; return $release_tag; } =head3 surround_line surround_line() will surround a line of output with lines of dashes or other characters. It's used to help heading stand out. This method takes two strings: a character (or string) that will repeat to fill surrounding lines, and the line to surround. It returns a three-line string: the original line preceded and followed by surrounding lines. sub surround_line { my ($self, $character, $string) = @_; my $surrounder = substr( ($character x (length($string) / length($character) + 1)), 0, length($string) ); return "$surrounder\n$string\n$surrounder\n"; } =head1 INTERNAL ATTRIBUTES Dist::Zilla::Plugin::ChangelogFromGit accumulates useful information into a few internal attributes. These aren't intended to be configured by dist.ini, but they are important for rendering change logs. =head2 earliest_date earliest_date() contains a L object that represents the date and time of the earliest release to include. It's initialized as midnight for the date max_age() days ago. =head2 releases releases() contains an array reference of L objects that will be included in the change log. =head3 all_releases all_releases() returns a list of the Software::Release objects that should be included in the change log. It's a friendly equivalent of C<< @{$self->releases()} >>. =head3 get_release get_release() returns a single release by index. The first release in the change log may be retrieved as C<< $self->get_release(0) >>. =head3 releae_count release_count() returns the number of Software::Release objects in the L attribute. =head3 sort_releases sort_releases() sorts the Software::Release objects in the releases() using some comparator. For example, to sort releases in time order: $self->sort_releases( sub { DateTime->compare( $_[0]->date(), $_[1]->date() ) } ); =head2 skipped_release_count skipped_release_count() contains the number of releases truncated by max_age(). The default render_changelog_footer() uses it to display the number of changes that have been omitted from the log. =head1 Subversion and CVS This plugin is almost entirely a copy-and-paste port of a command-line tool I wrote a while ago. I also have tools to generate similar change logs for CVS and Subversion projects. I'm happy to contribute that code to people interested in creating Dist::Zilla plugins for other version control systems. We should also consider abstracting the formatting code out to a role so that it can be shared among different plugins. =head1 BUGS The documentation includes copies of the renderer methods. This increases technical debt, since changes to those methods must also be copied into the documentation. Rocco needs to finish L and use it here to simplify maintenance of the documentation. Collecting all releases and changes before rendering the change log may be considered harmful for extremely large projects. If someone thinks they can generate change logs incrementally, their assistance would be appreciated. =head1 AUTHORS Rocco Caputo - Initial release, and ongoing management and maintenance. Cory G. Watson - Made formatting extensible and overridable. =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010-2013 by Rocco Caputo. This is free software; you may redistribute it and/or modify it under the same terms as the Perl 5 programming language itself. =cut