.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Test::Git 3pm" .TH Test::Git 3pm "2023-03-22" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Test::Git \- Helper functions for test scripts using Git .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& use Test::More; \& use Test::Git; \& \& # check there is a git binary available, or skip all \& has_git(); \& \& # check there is a minimum version of git available, or skip all \& has_git( \*(Aq1.6.5\*(Aq ); \& \& # check the git we want to test has a minimum version, or skip all \& has_git( \*(Aq1.6.5\*(Aq, { git => \*(Aq/path/to/alternative/git\*(Aq } ); \& \& # normal plan \& plan tests => 2; \& \& # create a new, empty repository in a temporary location \& # and return a Git::Repository object \& my $r = test_repository(); \& \& # clone an existing repository in a temporary location \& # and return a Git::Repository object \& my $c = test_repository( clone => [ $url ] ); \& \& # run some tests on the repository \& ... .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Test::Git provides a number of helpful functions when running test scripts that require the creation and management of a Git repository. .SH "EXPORTED FUNCTIONS" .IX Header "EXPORTED FUNCTIONS" .SS "has_git" .IX Subsection "has_git" .Vb 1 \& has_git( $version, \e%options ); .Ve .PP Checks if there is a git binary available, or skips all tests. .PP If the optional \f(CW$version\fR argument is provided, also checks if the available git binary has a version greater or equal to \f(CW$version\fR. .PP This function also accepts an option hash of the same kind as those accepted by Git::Repository and Git::Repository::Command. .PP This function must be called before \f(CW\*(C`plan()\*(C'\fR, as it performs a \fBskip_all\fR if requirements are not met. .PP \&\f(CW\*(C`has_git\*(C'\fR is now \fBobsolete\fR and will print a warning when used. The \f(CW\*(C`test_requires_git\*(C'\fR function provided by the Test::Requires::Git module is a much more flexible replacement. .PP \&\f(CW\*(C`has_git\*(C'\fR will be removed in a future release. .SS "test_repository" .IX Subsection "test_repository" .Vb 1 \& test_repository( %options ); .Ve .PP Creates a new empty git repository in a temporary location, and returns a Git::Repository object pointing to it. .PP This function takes options as a hash. Each key will influence a different part of the creation process. .PP The keys are: .IP "temp" 4 .IX Item "temp" Array reference containing parameters to File::Temp \f(CW\*(C`tempdir\*(C'\fR function. .Sp Default: \f(CW\*(C`<[ CLEANUP =\*(C'\fR 1 ]>> .IP "init" 4 .IX Item "init" Array reference containing parameters to \f(CW\*(C`git init\*(C'\fR. Must not contain the target directory parameter, which is provided by \f(CW\*(C`test_repository()\*(C'\fR (via File::Temp). .Sp Default: \f(CW\*(C`[]\*(C'\fR .Sp The \f(CW\*(C`init\*(C'\fR option is only supported with Git versions higher or equal to 1.6.2.rc0. .IP "clone" 4 .IX Item "clone" Array reference containing parameters to \f(CW\*(C`git clone\*(C'\fR. Must not contain the target directory parameter, which is provided by \f(CW\*(C`test_repository()\*(C'\fR (via File::Temp). .Sp Note that \f(CW\*(C`clone\*(C'\fR and \f(CW\*(C`init\*(C'\fR are mutually exclusive and that \&\f(CW\*(C`test_repository()\*(C'\fR will croak if both are provided. This option has no default value, since at least a Git \s-1URL\s0 must be provided to the \f(CW\*(C`clone\*(C'\fR option. .Sp The \f(CW\*(C`clone\*(C'\fR option is only supported with Git versions higher or equal to 1.6.2.rc0. .IP "git" 4 .IX Item "git" Hash reference containing options for Git::Repository. .Sp Default: \f(CW\*(C`{}\*(C'\fR .PP This call is the equivalent of the default call with no options: .PP .Vb 5 \& test_repository( \& temp => [ CLEANUP => 1 ], # File::Temp::tempdir options \& init => [], # git init options \& git => {}, # Git::Repository options \& ); .Ve .PP To create a \fIbare\fR repository: .PP .Vb 1 \& test_repository( init => [ \*(Aq\-\-bare\*(Aq ] ); .Ve .PP To leave the repository in its location after the end of the test: .PP .Vb 1 \& test_repository( temp => [ CLEANUP => 0 ] ); .Ve .PP Note that since \f(CW\*(C`test_repository()\*(C'\fR uses \f(CW\*(C`git init\*(C'\fR to create the test repository, it requires at least Git version \f(CW\*(C`1.5.0.rc1\*(C'\fR. .SH "AUTHOR" .IX Header "AUTHOR" Philippe Bruhat (BooK) .SH "ACKNOWLEDGEMENTS" .IX Header "ACKNOWLEDGEMENTS" The \f(CW\*(C`clone\*(C'\fR option and capability of \f(CW\*(C`test_repository()\*(C'\fR owes a lot to Nathan Nutter (\s-1NNUTTER\s0), who wanted to be able to clone into a test repository. .SH "SEE ALSO" .IX Header "SEE ALSO" Test::Requires::Git. .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright 2010\-2016 Philippe Bruhat (BooK), all rights reserved. .SH "LICENSE" .IX Header "LICENSE" This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.