view release on metacpan or search on metacpan
# =========================================================================
# THIS FILE IS AUTOMATICALLY GENERATED BY MINILLA.
# DO NOT EDIT DIRECTLY.
# =========================================================================
use 5.008_001;
use strict;
use warnings;
use utf8;
use Module::Build;
use File::Basename;
use File::Spec;
my %args = (
license => 'perl',
dynamic_config => 0,
configure_requires => {
'Module::Build' => 0.38,
},
name => 'Plack-App-GitSmartHttp',
module_name => 'Plack::App::GitSmartHttp',
allow_pureperl => 0,
script_files => [glob('script/*'), glob('bin/*')],
c_source => [qw()],
PL_files => {},
test_files => ((-d '.git' || $ENV{RELEASE_TESTING}) && -d 'xt') ? 't/ xt/' : 't/',
recursive_test_files => 1,
);
if (-d 'share') {
$args{share_dir} = 'share';
}
my $builder = Module::Build->subclass(
class => 'MyBuilder',
code => q{
sub ACTION_distmeta {
die "Do not run distmeta. Install Minilla and `minil install` instead.\n";
}
sub ACTION_installdeps {
die "Do not run installdeps. Run `cpanm --installdeps .` instead.\n";
}
}
)->new(%args);
$builder->create_build_script();
use File::Copy;
print "cp META.json MYMETA.json\n";
copy("META.json","MYMETA.json") or die "Copy failed(META.json): $!";
if (-f 'META.yml') {
print "cp META.yml MYMETA.yml\n";
copy("META.yml","MYMETA.yml") or die "Copy failed(META.yml): $!";
} else {
print "There is no META.yml... You may install this module from the repository...\n";
}
Revision history for Perl extension Plack::App::GitSmartHttp
0.07 2014-11-22T08:08:10Z
- add missing dependency module for test
https://github.com/dragon3/Plack-App-GitSmartHttp/issues/1
0.06 2014-11-03T14:14:45Z
- minil migrate
0.05 Wed Nov 21 23:49:11 JST 2012
- improve response handling ( fix bad on memory handling )
0.04 Mon Oct 22 15:55:35 2012
- improve request body handling ( fix bad on memory handling )
0.03 Wed Aug 15 13:46:41 2012
- fix gzipped request body handling
0.02 Sat Mar 3 13:49:00 2012
- fix tests
0.01 Thu Apr 28 15:39:53 2011
- original version
This software is copyright (c) 2014 by Ryuzo Yamamoto <ryuzo.yamamoto@gmail.com>.
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) 2014 by Ryuzo Yamamoto <ryuzo.yamamoto@gmail.com>.
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.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
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.
<signature of Ty Coon>, 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) 2014 by Ryuzo Yamamoto <ryuzo.yamamoto@gmail.com>.
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
Build.PL
Changes
LICENSE
META.json
README.md
cpanfile
eg/app-auth-basic.psgi
eg/app-simple.psgi
lib/Plack/App/GitSmartHttp.pm
minil.toml
t/00_compile.t
t/01_match_routing.t
t/02_get_service.t
t/03_get_git_repo_dir.t
t/04_upload_pack_advertisement.t
t/05_no_access_wrong_content_type_up.t
t/06_no_access_wrong_content_type_rp.t
t/07_no_access_wrong_method_rcp.t
t/08_no_access_wrong_command_rcp.t
t/09_no_access_wrong_path_rcp.t
t/10_upload_pack_rpc.t
t/11_receive_pack_advertisement.t
t/12_recieve_pack_rpc.t
t/13_info_refs_dumb.t
t/14_info_packs.t
t/15_loose_objects.t
t/16_pack_file.t
t/17_index_file.t
t/18_text_file.t
t/19_config_upload_pack_off.t
t/20_config_receive_pack_off.t
t/test_repos/repo1/HEAD
t/test_repos/repo1/config
t/test_repos/repo1/description
t/test_repos/repo1/hooks/applypatch-msg.sample
t/test_repos/repo1/hooks/commit-msg.sample
t/test_repos/repo1/hooks/post-commit.sample
t/test_repos/repo1/hooks/post-receive.sample
t/test_repos/repo1/hooks/post-update.sample
t/test_repos/repo1/hooks/pre-applypatch.sample
t/test_repos/repo1/hooks/pre-commit.sample
t/test_repos/repo1/hooks/pre-rebase.sample
t/test_repos/repo1/hooks/prepare-commit-msg.sample
t/test_repos/repo1/hooks/update.sample
t/test_repos/repo1/info/exclude
t/test_repos/repo1/info/refs
t/test_repos/repo1/objects/00/750edc07d6415dcc07ae0351e9397b0222b7ba
t/test_repos/repo1/objects/0c/fbf08886fca9a91cb753ec8734c84fcbe52c9f
t/test_repos/repo1/objects/38/fd29697b220f7e4ca15b044c3222eefe5afdc1
t/test_repos/repo1/objects/43/4943a8265129a744745e5d12fa2625a784b283
t/test_repos/repo1/objects/64/10316f2ed260666a8a6b9a223ad3c95d7abaed
t/test_repos/repo1/objects/7e/ab585dfd08ca9f7524e71369236c074c9e4d93
t/test_repos/repo1/objects/80/5c96a6ed4f2b3d61bab765596220f31e80d3ba
t/test_repos/repo1/objects/85/342b0f7a4d078f05952766e243435d8f60ef68
t/test_repos/repo1/objects/d0/0491fd7e5bb6fa28c517a0bb32b8b506539d4d
t/test_repos/repo1/objects/info/packs
t/test_repos/repo1/objects/pack/pack-4d80b52a389143ec922a6a3f1437c732eaa6ceea.idx
t/test_repos/repo1/objects/pack/pack-4d80b52a389143ec922a6a3f1437c732eaa6ceea.pack
t/test_repos/repo1/refs/heads/master
xt/02_perlcritic.t
xt/perlcriticrc
META.yml
MANIFEST
{
"abstract" : "Git Smart HTTP Server PSGI(Plack) Implementation",
"author" : [
"Ryuzo Yamamoto <ryuzo.yamamoto@gmail.com>"
],
"dynamic_config" : 0,
"generated_by" : "Minilla/v2.2.1",
"license" : [
"perl_5"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
"version" : "2"
},
"name" : "Plack-App-GitSmartHttp",
"no_index" : {
"directory" : [
"t",
"xt",
"inc",
"share",
"eg",
"examples",
"author",
"builder"
]
},
"prereqs" : {
"build" : {
"requires" : {
"ExtUtils::MakeMaker" : "6.36"
}
},
"configure" : {
"requires" : {
"Module::Build" : "0.38"
}
},
"develop" : {
"requires" : {
"Test::CPAN::Meta" : "0",
"Test::MinimumVersion::Fast" : "0.04",
"Test::PAUSE::Permissions" : "0.04",
"Test::Pod" : "1.41",
"Test::Spellunker" : "v0.2.7"
}
},
"runtime" : {
"requires" : {
"Cwd" : "0",
"File::Spec" : "0",
"File::Which" : "0",
"File::chdir" : "0",
"HTTP::Date" : "0",
"IO::Uncompress::Gunzip" : "2.055",
"IPC::Open3" : "0",
"Plack" : "0",
"parent" : "0"
}
},
"test" : {
"requires" : {
"File::Copy::Recursive" : "0"
}
}
},
"provides" : {
"Plack::App::GitSmartHttp" : {
"file" : "lib/Plack/App/GitSmartHttp.pm",
"version" : "0.07"
}
},
"release_status" : "stable",
"resources" : {
"bugtracker" : {
"web" : "https://github.com/dragon3/Plack-App-GitSmartHttp/issues"
},
"homepage" : "https://github.com/dragon3/Plack-App-GitSmartHttp",
"repository" : {
"url" : "git://github.com/dragon3/Plack-App-GitSmartHttp.git",
"web" : "https://github.com/dragon3/Plack-App-GitSmartHttp"
}
},
"version" : "0.07"
}
---
abstract: 'Git Smart HTTP Server PSGI(Plack) Implementation'
author:
- 'Ryuzo Yamamoto <ryuzo.yamamoto@gmail.com>'
build_requires:
ExtUtils::MakeMaker: '6.36'
File::Copy::Recursive: '0'
configure_requires:
Module::Build: '0.38'
dynamic_config: 0
generated_by: 'Minilla/v2.2.1, CPAN::Meta::Converter version 2.142690'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: '1.4'
name: Plack-App-GitSmartHttp
no_index:
directory:
- t
- xt
- inc
- share
- eg
- examples
- author
- builder
provides:
Plack::App::GitSmartHttp:
file: lib/Plack/App/GitSmartHttp.pm
version: '0.07'
requires:
Cwd: '0'
File::Spec: '0'
File::Which: '0'
File::chdir: '0'
HTTP::Date: '0'
IO::Uncompress::Gunzip: '2.055'
IPC::Open3: '0'
Plack: '0'
parent: '0'
resources:
bugtracker: https://github.com/dragon3/Plack-App-GitSmartHttp/issues
homepage: https://github.com/dragon3/Plack-App-GitSmartHttp
repository: git://github.com/dragon3/Plack-App-GitSmartHttp.git
version: '0.07'
[](https://travis-ci.org/dragon3/Plack-App-GitSmartHttp) [](https://c...
# NAME
Plack::App::GitSmartHttp - Git Smart HTTP Server PSGI(Plack) Implementation
# SYNOPSIS
use Plack::App::GitSmartHttp;
Plack::App::GitSmartHttp->new(
root => '/var/git/repos',
git_path => '/usr/bin/git',
upload_pack => 1,
received_pack => 1
)->to_app;
# DESCRIPTION
Plack::App::GitSmartHttp is Git Smart HTTP Server PSGI(Plack) Implementation.
# AUTHOR
Ryuzo Yamamoto E<lt>ryuzo.yamamoto@gmail.comE<gt>
# SEE ALSO
Smart HTTP Transport : <http://progit.org/2010/03/04/smart-http.html>
Grack : <https://github.com/schacon/grack>
# LICENSE
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
requires 'Cwd';
requires 'File::Spec';
requires 'File::Which';
requires 'File::chdir';
requires 'HTTP::Date';
requires 'IO::Uncompress::Gunzip', '2.055';
requires 'IPC::Open3';
requires 'Plack';
requires 'parent';
on build => sub {
requires 'ExtUtils::MakeMaker', '6.36';
};
on test => sub {
requires 'File::Copy::Recursive';
};
eg/app-auth-basic.psgi view on Meta::CPAN
use File::Spec;
use File::Basename;
use lib File::Spec->catdir( dirname(__FILE__), '..', 'extlib', 'lib', 'perl5' );
use lib File::Spec->catdir( dirname(__FILE__), '..', 'lib' );
use Plack::Builder;
use Plack::App::GitSmartHttp;
builder {
enable "Plack::Middleware::AccessLog", format => "combined";
enable "Auth::Basic", authenticator => \&authen_cb;
Plack::App::GitSmartHttp->new(
root => 'repos',
git_path => '/usr/bin/git',
upload_pack => 1,
received_pack => 1
)->to_app;
};
sub authen_cb {
my ( $username, $password ) = @_;
return $username eq 'admin' && $password eq 's3cr3t';
}
eg/app-simple.psgi view on Meta::CPAN
use File::Spec;
use File::Basename;
use lib File::Spec->catdir( dirname(__FILE__), '..', 'extlib', 'lib', 'perl5' );
use lib File::Spec->catdir( dirname(__FILE__), '..', 'lib' );
use Plack::Builder;
use Plack::App::GitSmartHttp;
builder {
enable "Plack::Middleware::AccessLog", format => "combined";
Plack::App::GitSmartHttp->new(
root => 'repos',
git_path => '/usr/bin/git',
upload_pack => 1,
received_pack => 1
)->to_app;
};
lib/Plack/App/GitSmartHttp.pm view on Meta::CPAN
package Plack::App::GitSmartHttp;
use strict;
use warnings;
use parent qw/Plack::Component/;
use Plack::Request;
use Plack::Util;
use Plack::Util::Accessor qw( root git_path upload_pack received_pack );
use HTTP::Date;
use Cwd ();
use File::Spec::Functions;
use File::chdir;
use File::Which qw(which);
use Symbol qw(gensym);
use IPC::Open3;
use IO::Select;
use IO::Uncompress::Gunzip qw($GunzipError);
use constant BUFFER_SIZE => 8192;
our $VERSION = '0.07';
my @SERVICES = (
[ 'POST', 'service_rpc', qr{(.*?)/git-upload-pack$}, 'upload-pack' ],
[ 'POST', 'service_rpc', qr{(.*?)/git-receive-pack$}, 'receive-pack' ],
[ 'GET', 'get_info_refs', qr{(.*?)/info/refs$} ],
[ 'GET', 'get_text_file', qr{(.*?)/HEAD$} ],
[ 'GET', 'get_text_file', qr{(.*?)/objects/info/alternates$} ],
[ 'GET', 'get_text_file', qr{(.*?)/objects/info/http-alternates$} ],
[ 'GET', 'get_info_packs', qr{(.*?)/objects/info/packs$} ],
[ 'GET', 'get_loose_object', qr{(.*?)/objects/[0-9a-f]{2}/[0-9a-f]{38}$} ],
[
'GET', 'get_pack_file', qr{(.*?)/objects/pack/pack-[0-9a-f]{40}\.pack$}
],
[ 'GET', 'get_idx_file', qr{(.*?)/objects/pack/pack-[0-9a-f]{40}\.idx$} ],
);
sub prepare_app {
my $self = shift;
unless ( $self->git_path ) {
my $git_path = which('git');
unless ($git_path) {
die 'could not find git';
}
$self->git_path($git_path);
}
unless ( -x $self->git_path ) {
die 'git_path is not executable [' . $self->git_path . ']';
}
}
sub call {
my $self = shift;
my $env = shift;
my $req = Plack::Request->new($env);
my ( $cmd, $path, $reqfile, $rpc ) = $self->match_routing($req);
return $self->return_404 unless $cmd;
return $self->return_not_allowed($env) if $cmd eq 'not_allowed';
my $dir = $self->get_git_repo_dir($path);
return $self->return_404 unless $dir;
{
local $CWD = $dir;
$self->$cmd(
{
req => $req,
path => $path,
reqfile => $reqfile,
rpc => $rpc
}
);
}
}
sub get_service {
my $self = shift;
my $req = shift;
my $service = $req->param('service');
return unless $service;
return unless substr( $service, 0, 4 ) eq 'git-';
$service =~ s/git-//g;
return $service;
}
sub match_routing {
my $self = shift;
my $req = shift;
my ( $cmd, $path, $file, $rpc );
for my $s (@SERVICES) {
my $match = $s->[2];
if ( $req->path_info =~ /$match/ ) {
return ('not_allowed') if $s->[0] ne uc( $req->method );
$cmd = $s->[1];
$path = $1;
$file = $req->path_info;
$file =~ s|\Q$path/\E||;
$rpc = $s->[3];
return ( $cmd, $path, $file, $rpc );
}
}
return ();
}
sub get_git_repo_dir {
my $self = shift;
my $path = shift;
my $root = $self->root || `pwd`;
chomp $root;
$path = catdir( $root, $path );
return $path if ( -d $path );
return;
}
sub service_rpc {
my $self = shift;
my $args = shift;
my $req = $args->{req};
my $rpc = $args->{rpc};
return $self->return_403
unless $self->has_access( $req, $rpc, 1 );
my @cmd = $self->git_command( $rpc, '--stateless-rpc', '.' );
my $input = $req->input;
if ( exists $req->env->{HTTP_CONTENT_ENCODING}
&& $req->env->{HTTP_CONTENT_ENCODING} =~ /^(?:x-)?gzip$/ )
{
$input = IO::Uncompress::Gunzip->new($input);
unless ($input) {
$req->env->{'psgi.errors'}->print("gunzip failed: $GunzipError");
return $self->return_400;
}
}
my ( $cout, $cerr ) = ( gensym, gensym );
my $pid = open3( my $cin, $cout, $cerr, @cmd );
my $input_len = 0;
while ( my $len = $input->read( my $buf, BUFFER_SIZE ) > 0 ) {
print $cin $buf;
$input_len += $len;
}
close $cin;
if ( $input_len == 0 ) {
close $cout;
close $cerr;
waitpid( $pid, 0 );
return $self->return_400;
}
return sub {
my $respond = shift;
my $writer = $respond->(
[
200,
[
'Content-Type' =>
sprintf( 'application/x-git-%s-result', $rpc ),
]
]
);
my ( $out, $err, $buf ) = ( '', '', '' );
my $s = IO::Select->new( $cout, $cerr );
while ( my @ready = $s->can_read ) {
for my $handle (@ready) {
while ( sysread( $handle, $buf, BUFFER_SIZE ) ) {
if ( $handle == $cerr ) {
$err .= $buf;
}
else {
$writer->write($buf);
}
}
$s->remove($handle) if eof($handle);
}
}
close $cout;
close $cerr;
waitpid( $pid, 0 );
if ($err) {
$req->env->{'psgi.errors'}->print("git command failed: $err");
}
$writer->close();
}
}
sub get_info_refs {
my $self = shift;
my $args = shift;
my $req = $args->{req};
my $service = $self->get_service($req);
if ( $self->has_access( $args->{req}, $service ) ) {
my @cmd =
$self->git_command( $service, '--stateless-rpc', '--advertise-refs',
'.' );
my ( $cout, $cerr ) = ( gensym, gensym );
my $pid = open3( my $cin, $cout, $cerr, @cmd );
close $cin;
my ( $refs, $err, $buf ) = ( '', '', '' );
my $s = IO::Select->new( $cout, $cerr );
while ( my @ready = $s->can_read ) {
for my $handle (@ready) {
while ( sysread( $handle, $buf, BUFFER_SIZE ) ) {
if ( $handle == $cerr ) {
$err .= $buf;
}
else {
$refs .= $buf;
}
}
$s->remove($handle) if eof($handle);
}
}
close $cout;
close $cerr;
waitpid( $pid, 0 );
if ($err) {
$req->env->{'psgi.errors'}->print("git command failed: $err");
return $self->return_400;
}
my $res = $req->new_response(200);
$res->headers(
[
'Content-Type' =>
sprintf( 'application/x-git-%s-advertisement', $service ),
]
);
my $body =
pkt_write("# service=git-${service}\n") . pkt_flush() . $refs;
$res->body($body);
return $res->finalize;
}
else {
return $self->dumb_info_refs($args);
}
}
sub dumb_info_refs {
my $self = shift;
my $args = shift;
$self->update_server_info;
$self->send_file( $args, "text/plain; charset=utf-8" );
}
sub get_info_packs {
my $self = shift;
my $args = shift;
$self->send_file( $args, "text/plain; charset=utf-8" );
}
sub get_loose_object {
my $self = shift;
my $args = shift;
$self->send_file( $args, "application/x-git-loose-object" );
}
sub get_pack_file {
my $self = shift;
my $args = shift;
$self->send_file( $args, "application/x-git-packed-objects" );
}
sub get_idx_file {
my $self = shift;
my $args = shift;
$self->send_file( $args, "application/x-git-packed-objects-toc" );
}
sub get_text_file {
my $self = shift;
my $args = shift;
$self->send_file( $args, "text/plain" );
}
sub update_server_info {
my $self = shift;
system( $self->git_command('update-server-info') );
}
sub git_command {
my $self = shift;
my @commands = @_;
my $git_bin = $self->git_path;
return ( $git_bin, @commands );
}
sub has_access {
my $self = shift;
my ( $req, $rpc, $check_content_type ) = @_;
if ( $check_content_type
&& $req->content_type ne
sprintf( "application/x-git-%s-request", $rpc ) )
{
return;
}
return if !$rpc;
return $self->received_pack if $rpc eq 'receive-pack';
return $self->upload_pack if $rpc eq 'upload-pack';
return;
}
sub send_file {
my $self = shift;
my ( $args, $content_type ) = @_;
my $file = $args->{reqfile};
return $self->return_404 unless -e $file;
my @stat = stat $file;
my $res = $args->{req}->new_response(200);
$res->headers(
[
'Content-Type' => $content_type,
'Last-Modified' => HTTP::Date::time2str( $stat[9] ),
'Expires' => 'Fri, 01 Jan 1980 00:00:00 GMT',
'Pragma' => 'no-cache',
'Cache-Control' => 'no-cache, max-age=0, must-revalidate',
]
);
if ( $stat[7] ) {
$res->header( 'Content-Length' => $stat[7] );
}
open my $fh, "<:raw", $file
or return $self->return_403;
Plack::Util::set_io_path( $fh, Cwd::realpath($file) );
$res->body($fh);
$res->finalize;
}
sub pkt_flush {
return '0000';
}
sub pkt_write {
my $str = shift;
return sprintf( '%04x', length($str) + 4 ) . $str;
}
sub return_not_allowed {
my $self = shift;
my $env = shift;
if ( $env->{SERVER_PROTOCOL} eq 'HTTP/1.1' ) {
return [
405, [ 'Content-Type' => 'text/plain', 'Content-Length' => 18 ],
['Method Not Allowed']
];
}
else {
return [
400, [ 'Content-Type' => 'text/plain', 'Content-Length' => 11 ],
['Bad Request']
];
}
}
sub return_403 {
my $self = shift;
return [
403, [ 'Content-Type' => 'text/plain', 'Content-Length' => 9 ],
['Forbidden']
];
}
sub return_400 {
my $self = shift;
return [
400, [ 'Content-Type' => 'text/plain', 'Content-Length' => 11 ],
['Bad Request']
];
}
sub return_404 {
my $self = shift;
return [
404, [ 'Content-Type' => 'text/plain', 'Content-Length' => 9 ],
['Not Found']
];
}
1;
__END__
=head1 NAME
Plack::App::GitSmartHttp - Git Smart HTTP Server PSGI(Plack) Implementation
=head1 SYNOPSIS
use Plack::App::GitSmartHttp;
Plack::App::GitSmartHttp->new(
root => '/var/git/repos',
git_path => '/usr/bin/git',
upload_pack => 1,
received_pack => 1
)->to_app;
=head1 DESCRIPTION
Plack::App::GitSmartHttp is Git Smart HTTP Server PSGI(Plack) Implementation.
=head1 AUTHOR
Ryuzo Yamamoto E<lt>ryuzo.yamamoto@gmail.comE<gt>
=head1 SEE ALSO
Smart HTTP Transport : <http://progit.org/2010/03/04/smart-http.html>
Grack : <https://github.com/schacon/grack>
=head1 LICENSE
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
badges = ['travis', 'coveralls']
t/00_compile.t view on Meta::CPAN
use strict;
use Test::More tests => 1;
BEGIN { use_ok 'Plack::App::GitSmartHttp' }
t/01_match_routing.t view on Meta::CPAN
use strict;
use Test::More;
use File::Which qw(which);
plan skip_all => 'could not find git' unless which('git');
use Plack::Request;
use Plack::App::GitSmartHttp;
subtest 'git-upload-pack' => sub {
my $gsh = Plack::App::GitSmartHttp->new;
my $req = Plack::Request->new(
{
REQUEST_METHOD => 'POST',
REQUEST_URI => '/base/foo/git-upload-pack',
PATH_INFO => '/base/foo/git-upload-pack',
}
);
my ( $cmd, $path, $reqfile, $rpc ) = $gsh->match_routing($req);
is( $cmd, 'service_rpc' );
is( $path, '/base/foo' );
is( $reqfile, 'git-upload-pack' );
};
subtest 'git-upload-pack not_allowed' => sub {
my $gsh = Plack::App::GitSmartHttp->new;
my $req = Plack::Request->new(
{
REQUEST_METHOD => 'GET',
REQUEST_URI => '/base/foo/git-upload-pack',
PATH_INFO => '/base/foo/git-upload-pack',
QUERY_STRING => '',
SERVER_NAME => '',
}
);
my ( $cmd, $path, $reqfile, $rpc ) = $gsh->match_routing($req);
is( $cmd, 'not_allowed' );
};
subtest 'get_info_refs' => sub {
my $gsh = Plack::App::GitSmartHttp->new;
my $req = Plack::Request->new(
{
REQUEST_METHOD => 'GET',
REQUEST_URI => '/base/foo/info/refs',
PATH_INFO => '/base/foo/info/refs',
QUERY_STRING => '',
SERVER_NAME => '',
}
);
my ( $cmd, $path, $reqfile, $rpc ) = $gsh->match_routing($req);
is( $cmd, 'get_info_refs' );
is( $path, '/base/foo' );
is( $reqfile, 'info/refs' );
};
subtest 'get_text_file' => sub {
my $gsh = Plack::App::GitSmartHttp->new;
my $req = Plack::Request->new(
{
REQUEST_METHOD => 'GET',
REQUEST_URI => '/base/foo/HEAD',
PATH_INFO => '/base/foo/HEAD',
QUERY_STRING => '',
SERVER_NAME => '',
}
);
my ( $cmd, $path, $reqfile, $rpc ) = $gsh->match_routing($req);
is( $cmd, 'get_text_file' );
is( $path, '/base/foo' );
is( $reqfile, 'HEAD' );
};
subtest 'get_text_file info/alternates' => sub {
my $gsh = Plack::App::GitSmartHttp->new;
my $req = Plack::Request->new(
{
REQUEST_METHOD => 'GET',
REQUEST_URI => '/base/foo/objects/info/alternates',
PATH_INFO => '/base/foo/objects/info/alternates',
QUERY_STRING => '',
SERVER_NAME => '',
}
);
my ( $cmd, $path, $reqfile, $rpc ) = $gsh->match_routing($req);
is( $cmd, 'get_text_file' );
is( $path, '/base/foo' );
is( $reqfile, 'objects/info/alternates' );
};
subtest 'get_text_file info/http-alternates' => sub {
my $gsh = Plack::App::GitSmartHttp->new;
my $req = Plack::Request->new(
{
REQUEST_METHOD => 'GET',
REQUEST_URI => '/base/foo/objects/info/http-alternates',
PATH_INFO => '/base/foo/objects/info/http-alternates',
QUERY_STRING => '',
SERVER_NAME => '',
}
);
my ( $cmd, $path, $reqfile, $rpc ) = $gsh->match_routing($req);
is( $cmd, 'get_text_file' );
is( $path, '/base/foo' );
is( $reqfile, 'objects/info/http-alternates' );
};
subtest 'get_info_packs' => sub {
my $gsh = Plack::App::GitSmartHttp->new;
my $req = Plack::Request->new(
{
REQUEST_METHOD => 'GET',
REQUEST_URI => '/base/foo/objects/info/packs',
PATH_INFO => '/base/foo/objects/info/packs',
QUERY_STRING => '',
SERVER_NAME => '',
}
);
my ( $cmd, $path, $reqfile, $rpc ) = $gsh->match_routing($req);
is( $cmd, 'get_info_packs' );
is( $path, '/base/foo' );
is( $reqfile, 'objects/info/packs' );
};
subtest 'get_loose_object' => sub {
my $gsh = Plack::App::GitSmartHttp->new;
my $req = Plack::Request->new(
{
REQUEST_METHOD => 'GET',
REQUEST_URI =>
'/base/foo/objects/3b/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaacccccc',
PATH_INFO =>
'/base/foo/objects/3b/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaacccccc',
QUERY_STRING => '',
SERVER_NAME => '',
}
);
my ( $cmd, $path, $reqfile, $rpc ) = $gsh->match_routing($req);
is( $cmd, 'get_loose_object' );
is( $path, '/base/foo' );
is( $reqfile, 'objects/3b/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaacccccc' );
};
subtest 'get_pack_file' => sub {
my $gsh = Plack::App::GitSmartHttp->new;
my $req = Plack::Request->new(
{
REQUEST_METHOD => 'GET',
REQUEST_URI =>
'/base/foo/objects/pack/pack-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbb.pack',
PATH_INFO =>
'/base/foo/objects/pack/pack-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbb.pack',
QUERY_STRING => '',
SERVER_NAME => '',
}
);
my ( $cmd, $path, $reqfile, $rpc ) = $gsh->match_routing($req);
is( $cmd, 'get_pack_file' );
is( $path, '/base/foo' );
is( $reqfile,
'objects/pack/pack-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbb.pack' );
};
subtest 'get_idx_file' => sub {
my $gsh = Plack::App::GitSmartHttp->new;
my $req = Plack::Request->new(
{
REQUEST_METHOD => 'GET',
REQUEST_URI =>
'/base/foo/objects/pack/pack-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbb.idx',
PATH_INFO =>
'/base/foo/objects/pack/pack-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbb.idx',
QUERY_STRING => '',
SERVER_NAME => '',
}
);
my ( $cmd, $path, $reqfile, $rpc ) = $gsh->match_routing($req);
is( $cmd, 'get_idx_file' );
is( $path, '/base/foo' );
is( $reqfile,
'objects/pack/pack-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbb.idx' );
};
done_testing;
t/02_get_service.t view on Meta::CPAN
use strict;
use Test::More;
use File::Which qw(which);
plan skip_all => 'could not find git' unless which('git');
use Plack::Request;
use Plack::App::GitSmartHttp;
subtest 'git-upload-pack' => sub {
my $gsh = Plack::App::GitSmartHttp->new;
my $req = Plack::Request->new(
{
REQUEST_METHOD => 'POST',
REQUEST_URI => '/base/foo/git-upload-pack',
PATH_INFO => '/base/foo/git-upload-pack',
QUERY_STRING => 'service=git-upload-pack'
}
);
is( $gsh->get_service($req), 'upload-pack' );
};
subtest 'git-receive-pack' => sub {
my $gsh = Plack::App::GitSmartHttp->new;
my $req = Plack::Request->new(
{
REQUEST_METHOD => 'POST',
REQUEST_URI => '/base/foo/git-receive-pack',
PATH_INFO => '/base/foo/git-receive-pack',
QUERY_STRING => 'service=git-receive-pack'
}
);
is( $gsh->get_service($req), 'receive-pack' );
};
subtest 'git-upload-pack invalid param' => sub {
my $gsh = Plack::App::GitSmartHttp->new;
my $req = Plack::Request->new(
{
REQUEST_METHOD => 'POST',
REQUEST_URI => '/base/foo/git-upload-pack',
PATH_INFO => '/base/foo/git-upload-pack',
QUERY_STRING => 'service=bar-upload-pack'
}
);
is( $gsh->get_service($req), undef );
};
subtest 'git-receive-pack invalid param' => sub {
my $gsh = Plack::App::GitSmartHttp->new;
my $req = Plack::Request->new(
{
REQUEST_METHOD => 'POST',
REQUEST_URI => '/base/foo/git-receive-pack',
PATH_INFO => '/base/foo/git-receive-pack',
QUERY_STRING => 'service=foo-receive-pack'
}
);
is( $gsh->get_service($req), undef );
};
done_testing;
t/03_get_git_repo_dir.t view on Meta::CPAN
use strict;
use Test::More;
use File::Which qw(which);
plan skip_all => 'could not find git' unless which('git');
use File::Spec::Functions qw(:ALL);
use File::Temp qw(tempdir);
use Plack::App::GitSmartHttp;
subtest "has root" => sub {
my $root = tempdir;
my $dir = catdir( $root, 'foo' );
mkdir $dir;
my $gsh = Plack::App::GitSmartHttp->new( root => $root );
is( $gsh->get_git_repo_dir('foo'), $dir );
};
subtest "no root" => sub {
my $dir = catdir( '.', 'foo' );
mkdir $dir;
my $gsh = Plack::App::GitSmartHttp->new();
is( $gsh->get_git_repo_dir('foo'), rel2abs($dir) );
rmdir $dir;
};
subtest "dir not found" => sub {
my $root = tempdir;
my $gsh = Plack::App::GitSmartHttp->new( root => $root );
is( $gsh->get_git_repo_dir('foo'), undef );
};
done_testing;
t/04_upload_pack_advertisement.t view on Meta::CPAN
use strict;
use Test::More;
use File::Which qw(which);
plan skip_all => 'could not find git' unless which('git');
use Plack::Test;
use HTTP::Request::Common;
use Plack::App::GitSmartHttp;
my $app = Plack::App::GitSmartHttp->new(
root => "t/test_repos",
upload_pack => 1,
received_pack => 1,
);
test_psgi $app, sub {
my $cb = shift;
my $res = $cb->( GET "/repo1/info/refs?service=git-upload-pack" );
is $res->code, 200;
is $res->header("Content-Type"),
"application/x-git-upload-pack-advertisement";
my $body = $res->decoded_content;
my $first = ( split /\n/, $body )[0];
is $first, "001e# service=git-upload-pack";
like $body, qr/multi_ack_detailed/;
};
done_testing;
t/05_no_access_wrong_content_type_up.t view on Meta::CPAN
use strict;
use Test::More;
use File::Which qw(which);
plan skip_all => 'could not find git' unless which('git');
use Plack::Test;
use HTTP::Request::Common;
use Plack::App::GitSmartHttp;
my $app = Plack::App::GitSmartHttp->new(
root => "t/test_repos",
upload_pack => 1,
received_pack => 1,
);
test_psgi $app, sub {
my $cb = shift;
my $res = $cb->( POST "/repo1/git-upload-pack" );
is $res->code, 403;
};
done_testing
t/06_no_access_wrong_content_type_rp.t view on Meta::CPAN
use strict;
use Test::More;
use File::Which qw(which);
plan skip_all => 'could not find git' unless which('git');
use Plack::Test;
use HTTP::Request::Common;
use Plack::App::GitSmartHttp;
my $app = Plack::App::GitSmartHttp->new(
root => "t/test_repos",
upload_pack => 1,
received_pack => 1,
);
test_psgi $app, sub {
my $cb = shift;
my $res = $cb->( POST "/repo1/git-receive-pack" );
is $res->code, 403;
};
done_testing
t/07_no_access_wrong_method_rcp.t view on Meta::CPAN
use strict;
use Test::More;
use File::Which qw(which);
plan skip_all => 'could not find git' unless which('git');
use Plack::Test;
use HTTP::Request::Common;
use Plack::App::GitSmartHttp;
my $app = Plack::App::GitSmartHttp->new(
root => "t/test_repos",
upload_pack => 1,
received_pack => 1,
);
test_psgi $app, sub {
my $cb = shift;
my $res = $cb->( GET "/repo1/git-upload-pack" );
is $res->code, 405;
};
test_psgi $app, sub {
my $cb = shift;
my $req = HTTP::Request->new( GET => "/repo1/git-upload-pack" );
$req->protocol("HTTP/1.0");
my $res = $cb->($req);
is $res->code, 400;
};
done_testing
t/08_no_access_wrong_command_rcp.t view on Meta::CPAN
use strict;
use Test::More;
use File::Which qw(which);
plan skip_all => 'could not find git' unless which('git');
use Plack::Test;
use HTTP::Request::Common;
use Plack::App::GitSmartHttp;
my $app = Plack::App::GitSmartHttp->new(
root => "t/test_repos",
upload_pack => 1,
received_pack => 1,
);
test_psgi $app, sub {
my $cb = shift;
my $res = $cb->( POST "/repo1/git-upload-packfile" );
is $res->code, 404;
};
done_testing
t/09_no_access_wrong_path_rcp.t view on Meta::CPAN
use strict;
use Test::More;
use File::Which qw(which);
plan skip_all => 'could not find git' unless which('git');
use Plack::Test;
use HTTP::Request::Common;
use Plack::App::GitSmartHttp;
my $app = Plack::App::GitSmartHttp->new(
root => "t/test_repos",
upload_pack => 1,
received_pack => 1,
);
test_psgi $app, sub {
my $cb = shift;
my $res = $cb->( POST "/repo1-wrong/git-upload-pack" );
is $res->code, 404;
};
done_testing
t/10_upload_pack_rpc.t view on Meta::CPAN
use strict;
use Test::More;
use File::Which qw(which);
plan skip_all => 'could not find git' unless which('git');
use IO::Compress::Gzip qw(gzip);
use Plack::Test;
use HTTP::Request::Common;
use Plack::App::GitSmartHttp;
my $app = Plack::App::GitSmartHttp->new(
root => "t/test_repos",
upload_pack => 1,
received_pack => 1,
);
subtest 'success' => sub {
test_psgi $app, sub {
my $cb = shift;
my $content = <<__CONTENT__;
006fwant 6410316f2ed260666a8a6b9a223ad3c95d7abaed multi_ack_detailed no-done side-band-64k thin-pack ofs-delta
0032want 6410316f2ed260666a8a6b9a223ad3c95d7abaed
00000009done
__CONTENT__
my $res = $cb->(
POST "/repo1/git-upload-pack",
"Content-Type" => "application/x-git-upload-pack-request",
"Content-Length" => 174,
"Content" => $content,
);
is $res->code, 200;
is $res->header("Content-Type"), 'application/x-git-upload-pack-result';
};
};
subtest 'success gzip' => sub {
test_psgi $app, sub {
my $cb = shift;
my $content = <<__CONTENT__;
006fwant 6410316f2ed260666a8a6b9a223ad3c95d7abaed multi_ack_detailed no-done side-band-64k thin-pack ofs-delta
0032want 6410316f2ed260666a8a6b9a223ad3c95d7abaed
00000009done
__CONTENT__
my $content_gzipped;
gzip \$content => \$content_gzipped;
my $res = $cb->(
POST "/repo1/git-upload-pack",
"Content-Type" => "application/x-git-upload-pack-request",
"Content-Length" => 174,
"Content-Encoding" => 'gzip',
"Content" => $content_gzipped,
);
is $res->code, 200;
is $res->header("Content-Type"), 'application/x-git-upload-pack-result';
};
};
subtest 'success x-gzip' => sub {
test_psgi $app, sub {
my $cb = shift;
my $content = <<__CONTENT__;
006fwant 6410316f2ed260666a8a6b9a223ad3c95d7abaed multi_ack_detailed no-done side-band-64k thin-pack ofs-delta
0032want 6410316f2ed260666a8a6b9a223ad3c95d7abaed
00000009done
__CONTENT__
my $content_gzipped;
gzip \$content => \$content_gzipped;
my $res = $cb->(
POST "/repo1/git-upload-pack",
"Content-Type" => "application/x-git-upload-pack-request",
"Content-Length" => 174,
"Content-Encoding" => 'x-gzip',
"Content" => $content_gzipped,
);
is $res->code, 200;
is $res->header("Content-Type"), 'application/x-git-upload-pack-result';
};
};
subtest 'no content' => sub {
test_psgi $app, sub {
my $cb = shift;
my $res = $cb->(
POST "/repo1/git-upload-pack",
"Content-Type" => "application/x-git-upload-pack-request",
);
is $res->code, 400;
};
};
done_testing
t/11_receive_pack_advertisement.t view on Meta::CPAN
use strict;
use Test::More;
use File::Which qw(which);
plan skip_all => 'could not find git' unless which('git');
use Plack::Test;
use HTTP::Request::Common;
use Plack::App::GitSmartHttp;
my $app = Plack::App::GitSmartHttp->new(
root => "t/test_repos",
upload_pack => 1,
received_pack => 1,
);
test_psgi $app, sub {
my $cb = shift;
my $res = $cb->( GET "/repo1/info/refs?service=git-receive-pack" );
is $res->code, 200;
is $res->header("Content-Type"),
"application/x-git-receive-pack-advertisement";
my $body = $res->decoded_content;
my $first = ( split /\n/, $body )[0];
is $first, "001f# service=git-receive-pack";
like $body, qr/report-status/;
like $body, qr/delete-refs/;
like $body, qr/ofs-delta/;
};
done_testing;
t/12_recieve_pack_rpc.t view on Meta::CPAN
use strict;
use Test::More;
use File::Which qw(which);
plan skip_all => 'could not find git' unless which('git');
use File::Path qw(remove_tree);
use File::Copy::Recursive qw(rcopy);
use Plack::Test;
use HTTP::Request::Common;
use Plack::App::GitSmartHttp;
$Plack::Test::Impl = "Server";
my $app = Plack::App::GitSmartHttp->new(
root => "t/test_repos",
upload_pack => 1,
received_pack => 1,
);
rcopy( "t/test_repos/repo1", "t/test_repos/repo2" );
test_psgi $app, sub {
my $cb = shift;
my $res = $cb->(
POST "/repo2/git-receive-pack",
"Content-Type" => "application/x-git-receive-pack-request",
"Content" =>
"00810000000000000000000000000000000000000000 6410316f2ed260666a8a6b9a223ad3c95d7abaed refs/tags/v1.0. report-status side-band-64k0000",
);
is $res->code, 200;
is $res->header("Content-Type"), 'application/x-git-receive-pack-result';
};
remove_tree("t/test_repos/repo2");
done_testing
t/13_info_refs_dumb.t view on Meta::CPAN
use strict;
use Test::More;
use File::Which qw(which);
plan skip_all => 'could not find git' unless which('git');
use Plack::Test;
use HTTP::Request::Common;
use Plack::App::GitSmartHttp;
my $app = Plack::App::GitSmartHttp->new(
root => "t/test_repos",
upload_pack => 1,
received_pack => 1,
);
test_psgi $app, sub {
my $cb = shift;
my $res = $cb->( GET "/repo1/info/refs" );
is $res->code, 200;
is $res->header('Content-Type'), 'text/plain; charset=utf-8';
};
done_testing
t/14_info_packs.t view on Meta::CPAN
use strict;
use Test::More;
use File::Which qw(which);
plan skip_all => 'could not find git' unless which('git');
use Plack::Test;
use HTTP::Request::Common;
use Plack::App::GitSmartHttp;
my $app = Plack::App::GitSmartHttp->new(
root => "t/test_repos",
upload_pack => 1,
received_pack => 1,
);
test_psgi $app, sub {
my $cb = shift;
my $res = $cb->( GET "/repo1/objects/info/packs" );
is $res->code, 200;
is $res->header('Content-Type'), 'text/plain; charset=utf-8';
like $res->decoded_content, qr/P pack-(.*?).pack/;
};
done_testing
t/15_loose_objects.t view on Meta::CPAN
use strict;
use Test::More;
use File::Which qw(which);
plan skip_all => 'could not find git' unless which('git');
use Plack::Test;
use HTTP::Request::Common;
use Plack::App::GitSmartHttp;
my $app = Plack::App::GitSmartHttp->new(
root => "t/test_repos",
upload_pack => 1,
received_pack => 1,
);
test_psgi $app, sub {
my $cb = shift;
my $res =
$cb->( GET "/repo1/objects/80/5c96a6ed4f2b3d61bab765596220f31e80d3ba" );
is $res->code, 200;
is $res->header('Content-Type'), 'application/x-git-loose-object';
};
done_testing
t/16_pack_file.t view on Meta::CPAN
use strict;
use Test::More;
use File::Which qw(which);
plan skip_all => 'could not find git' unless which('git');
use Plack::Test;
use HTTP::Request::Common;
use Plack::App::GitSmartHttp;
my $app = Plack::App::GitSmartHttp->new(
root => "t/test_repos",
upload_pack => 1,
received_pack => 1,
);
test_psgi $app, sub {
my $cb = shift;
my $res =
$cb->( GET
"/repo1/objects/pack/pack-4d80b52a389143ec922a6a3f1437c732eaa6ceea.pack"
);
is $res->code, 200;
is $res->header('Content-Type'), 'application/x-git-packed-objects';
};
done_testing
t/17_index_file.t view on Meta::CPAN
use strict;
use Test::More;
use File::Which qw(which);
plan skip_all => 'could not find git' unless which('git');
use Plack::Test;
use HTTP::Request::Common;
use Plack::App::GitSmartHttp;
my $app = Plack::App::GitSmartHttp->new(
root => "t/test_repos",
upload_pack => 1,
received_pack => 1,
);
test_psgi $app, sub {
my $cb = shift;
my $res =
$cb->( GET
"/repo1/objects/pack/pack-4d80b52a389143ec922a6a3f1437c732eaa6ceea.idx"
);
is $res->code, 200;
is $res->header('Content-Type'), 'application/x-git-packed-objects-toc';
};
done_testing