| 1 | # | ||||||||||||||||||||||||||||
| 2 | # This file is part of Dist-Zilla-PluginBundle-Git-CheckFor | ||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||
| 4 | # This software is Copyright (c) 2026 by Chris Weyl. | ||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||
| 6 | # This is free software, licensed under: | ||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||
| 8 | # The GNU Lesser General Public License, Version 2.1, February 1999 | ||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||
| 10 | package Dist::Zilla::Plugin::Git::CheckFor::Fixups; | ||||||||||||||||||||||||||||
| 11 | 2 | our $AUTHORITY = 'cpan:RSRCHBOY'; | |||||||||||||||||||||||||||
| 12 | 2 | $Dist::Zilla::Plugin::Git::CheckFor::Fixups::VERSION = '0.015'; | |||||||||||||||||||||||||||
| 13 | # ABSTRACT: Check your repo for fixup! and squash! before release | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 2 | ▶ | use autodie 'system'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 2 | ▶ | use IPC::System::Simple (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | # we depend on functionality first present in 1.120370 | ||||||||||||||||||||||||||||
| 22 | 2 | ▶ | use Dist::Zilla::Plugin::Git::NextVersion 1.120370 (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | 2 | ▶ | use List::Util 'first'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | 2 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | # debugging... | ||||||||||||||||||||||||||||
| 27 | #use Smart::Comments; | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 2 | with | |||||||||||||||||||||||||||
| 30 | 'Dist::Zilla::Role::BeforeRelease', | ||||||||||||||||||||||||||||
| 31 | 'Dist::Zilla::Role::Git::Repo::More', | ||||||||||||||||||||||||||||
| 32 | #-excludes => [ qw { _build_version_regexp _build_first_version } ], | ||||||||||||||||||||||||||||
| 33 | ; | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 2 | has _next_version_plugin => ( | |||||||||||||||||||||||||||
| 36 | is => 'ro', | ||||||||||||||||||||||||||||
| 37 | lazy => 1, | ||||||||||||||||||||||||||||
| 38 | builder => '_build__next_version_plugin', | ||||||||||||||||||||||||||||
| 39 | isa => 'Dist::Zilla::Plugin::Git::NextVersion', | ||||||||||||||||||||||||||||
| 40 | handles => [ qw{ version_regexp first_version } ], | ||||||||||||||||||||||||||||
| 41 | ); | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 3 | ▶ | sub _build__next_version_plugin { | ||||||||||||||||||||||||||
|
Subroutine
_build__next_version_plugin: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 44 | 3 | my $self = shift @_; | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | return | ||||||||||||||||||||||||||||
| 47 | 3 | ▶ | first { $_->isa('Dist::Zilla::Plugin::Git::NextVersion') } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 48 | 3 | @{ $self->zilla->plugins_with(-VersionProvider) } | |||||||||||||||||||||||||||
| 49 | ; | ||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 3 | ▶ | sub before_release { | ||||||||||||||||||||||||||
|
Subroutine
before_release: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 53 | 3 | my $self = shift @_; | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 3 | my $repo = $self->_repo; | |||||||||||||||||||||||||||
| 56 | 3 | my $last_ver = $self->last_version; | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | ### $last_ver | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 3 | my $log_opts = { pretty => 'oneline', 'abbrev-commit' => 1 }; | |||||||||||||||||||||||||||
| 61 | 3 | my @logs; | |||||||||||||||||||||||||||
| 62 | 3 | ▶ | if (defined $last_ver) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | # FIXME this should be corrected to work in a cleaner fashion, | ||||||||||||||||||||||||||||
| 65 | # possibly by mucking around with version_regexp and the tags in here, | ||||||||||||||||||||||||||||
| 66 | # or by splitting the common git stuff out into a stash and accessing | ||||||||||||||||||||||||||||
| 67 | # that, etc, etc | ||||||||||||||||||||||||||||
| 68 | # | ||||||||||||||||||||||||||||
| 69 | # But for now, this allows tags generated with a '-TRIAL' appended to | ||||||||||||||||||||||||||||
| 70 | # them to be found and used without too much fuss. | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 0 | ▶ | try { @logs = $self->_repo->log($log_opts, "$last_ver..HEAD") } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 73 | 0 | ▶ | catch { @logs = $self->_repo->log($log_opts, "$last_ver-TRIAL..HEAD") } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 74 | 0 | ; | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | else { | ||||||||||||||||||||||||||||
| 77 | 3 | @logs = $self->_repo->log($log_opts); | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 6 | ▶ | my $_checker = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 81 | 6 | my $lookfor = shift; | |||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | return | ||||||||||||||||||||||||||||
| 84 | 2 | map { $_ =~ s/\n.*$//; $_ } | |||||||||||||||||||||||||||
| 85 | 2 | map { $_->id . ': ' . $_->message } | |||||||||||||||||||||||||||
| 86 | 6 | grep { $_->message =~ /^$lookfor! / } | |||||||||||||||||||||||||||
| 87 | @logs; | ||||||||||||||||||||||||||||
| 88 | 3 | }; | |||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | ### @logs | ||||||||||||||||||||||||||||
| 91 | 3 | my @fixups = $_checker->('fixup'); | |||||||||||||||||||||||||||
| 92 | 3 | my @squashes = $_checker->('squash'); | |||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 3 | ▶ | if (@fixups || @squashes) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@fixups or @squashes
MC/DC100%2/2
@fixups or @squashes
@fixups
@squashes
Truth table100%3/3
A or B
A= @fixupsB= @squashes
| |||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 2 | $self->log_fatal( | |||||||||||||||||||||||||||
| 97 | "Aborting release; found squash or fixup commits:\n\n" | ||||||||||||||||||||||||||||
| 98 | . join("\n", @fixups) | ||||||||||||||||||||||||||||
| 99 | . join("\n", @squashes) | ||||||||||||||||||||||||||||
| 100 | ); | ||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 1 | $self->log('No fixup or squash commits found; OK to release'); | |||||||||||||||||||||||||||
| 104 | 1 | return; | |||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 2 | !!42; | |||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | __END__ | ||||||||||||||||||||||||||||