Module::Release::Git - Use Git with Module::Release


Module-Release-Git documentation Contained in the Module-Release-Git distribution.

Index


Code Index:

NAME

Top

Module::Release::Git - Use Git with Module::Release

SYNOPSIS

Top

The release script automatically loads this module if it sees a .git directory. The module exports check_vcs, vcs_tag, and make_vcs_tag.

DESCRIPTION

Top

Module::Release::Git subclasses Module::Release, and provides its own implementations of the check_vcs() and vcs_tag() methods that are suitable for use with a Git repository.

These methods are automatically exported in to the callers namespace using Exporter.

This module depends on the external git binary (so far).

check_vcs()

Check the state of the Git repository.

vcs_tag(TAG)

Tag the release in local Git.

make_vcs_tag

By default, examines the name of the remote file (i.e. Foo-Bar-0.04.tar.gz) and constructs a tag string like RELEASE_0_04 from it. Override this method if you want to use a different tagging scheme, or don't even call it.

TO DO

Top

Use Gitlib.pm whenever it exists
More options for tagging

SEE ALSO

Top

Module::Release::Subversion, Module::Release

SOURCE AVAILABILITY

Top

This module is in Github:

	git://github.com/briandfoy/module--release--git.git

AUTHOR

Top

brian d foy, <bdfoy@cpan.org>

COPYRIGHT AND LICENSE

Top


Module-Release-Git documentation Contained in the Module-Release-Git distribution.
package Module::Release::Git;

use strict;
use warnings;
use base qw(Exporter);

our @EXPORT = qw(check_vcs vcs_tag make_vcs_tag);

use vars qw($VERSION);
$VERSION = '0.14';

sub check_vcs 
	{
	my $self = shift;
	
	$self->_print( "Checking state of Git... " );
	
	my $git_status = $self->run('git status 2>&1');
		
	no warnings 'uninitialized';

	my( $branch ) = $git_status =~ /^# On branch (\w+)/;
	
	my $up_to_date = $git_status =~ /^nothing to commit \(working directory clean\)/m;
	
	$self->_die( "\nERROR: Git is not up-to-date: Can't release files\n\n$git_status\n" )
		unless $up_to_date;
	
	$self->_print( "Git up-to-date on branch $branch\n" );
	
	return 1;
	}

sub vcs_tag 
	{
	my( $self, $tag ) = @_;
	
	$tag ||= $self->make_vcs_tag;
	
	$self->_print( "Tagging release with $tag\n" );

	return 0 unless defined $tag;
	
	$self->run( "git tag $tag" );

	return 1;
	}

sub make_vcs_tag
	{
	no warnings 'uninitialized';
	
	my( $major, $minor ) = $_[0]->remote_file
		=~ /(\d+) \. (\d+(?:_\d+)?) (?: \.tar\.gz | \.tgz | \.zip )? $/xg;

	$_[0]->_warn( "Could not parse remote [$_[0]->{remote_file}] to get major and minor versions" )
		unless defined $major;
		
	return "RELEASE_${major}_${minor}";
	}

1;