| 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::CorrectBranch; | ||||||||||||||||||
| 11 | 2 | our $AUTHORITY = 'cpan:RSRCHBOY'; | |||||||||||||||||
| 12 | 2 | $Dist::Zilla::Plugin::Git::CheckFor::CorrectBranch::VERSION = '0.015'; | |||||||||||||||||
| 13 | # ABSTRACT: Check that you're on the correct branch 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 | with | |||||||||||||||||
| 19 | 'Dist::Zilla::Role::BeforeRelease', | ||||||||||||||||||
| 20 | 'Dist::Zilla::Role::Git::Repo::More', | ||||||||||||||||||
| 21 | ; | ||||||||||||||||||
| 22 | |||||||||||||||||||
| 23 | 4 | ▶ | sub mvp_multivalue_args { qw(release_branch) } | ||||||||||||||||
|
Subroutine
mvp_multivalue_args: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 24 | |||||||||||||||||||
| 25 | has release_branch => ( | ||||||||||||||||||
| 26 | isa => 'ArrayRef[Str]', | ||||||||||||||||||
| 27 | traits => ['Array'], | ||||||||||||||||||
| 28 | handles => { release_branch => 'elements' }, | ||||||||||||||||||
| 29 | 1 | ▶ | default => sub { [ 'master' ] }, | ||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 30 | 2 | ); | |||||||||||||||||
| 31 | |||||||||||||||||||
| 32 | 4 | ▶ | sub current_branch { | ||||||||||||||||
|
Subroutine
current_branch: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||
| 33 | 4 | my $self = shift @_; | |||||||||||||||||
| 34 | |||||||||||||||||||
| 35 | 4 | ▶ | my ($branch) = map { /^\*\s+(.+)/ ? $1 : () } $self->_repo->branch; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 36 | 4 | return $branch; | |||||||||||||||||
| 37 | } | ||||||||||||||||||
| 38 | |||||||||||||||||||
| 39 | 4 | ▶ | sub before_release { | ||||||||||||||||
|
Subroutine
before_release: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||
| 40 | 4 | my $self = shift @_; | |||||||||||||||||
| 41 | |||||||||||||||||||
| 42 | 4 | my $cbranch = $self->current_branch; | |||||||||||||||||
| 43 | 4 | my @rbranch = $self->release_branch; | |||||||||||||||||
| 44 | |||||||||||||||||||
| 45 | my $fatal_msg | ||||||||||||||||||
| 46 | = !$cbranch ? 'Cannot determine current branch!' | ||||||||||||||||||
| 47 | : $cbranch eq '(no branch)' ? 'You do not appear to be on any branch. This is almost certainly an error.' | ||||||||||||||||||
| 48 | 4 | ▶ | : (!grep { $cbranch eq $_ } @rbranch) ? "Your current branch ($cbranch) is not the release branch (". join(', ', @rbranch). ")" | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 49 | : undef | ||||||||||||||||||
| 50 | ; | ||||||||||||||||||
| 51 | |||||||||||||||||||
| 52 | 4 | ▶ | $self->log_fatal($fatal_msg) if $fatal_msg; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 53 | |||||||||||||||||||
| 54 | # if we're here, we're good | ||||||||||||||||||
| 55 | 2 | $self->log("Current branch ($cbranch) and release branch match (" . join(', ', @rbranch) .')'); | |||||||||||||||||
| 56 | 2 | return; | |||||||||||||||||
| 57 | } | ||||||||||||||||||
| 58 | |||||||||||||||||||
| 59 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||
| 60 | |||||||||||||||||||
| 61 | 2 | !!42; | |||||||||||||||||
| 62 | |||||||||||||||||||
| 63 | __END__ | ||||||||||||||||||