Skip to content

Commit

Permalink
Raw.xs: Added features()
Browse files Browse the repository at this point in the history
  • Loading branch information
jacquesg committed May 4, 2014
1 parent 3890832 commit 50947d3
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Raw.xs
Original file line number Diff line number Diff line change
Expand Up @@ -1489,6 +1489,25 @@ MODULE = Git::Raw PACKAGE = Git::Raw
BOOT:
git_threads_init();

void
features(class)
SV *class

PREINIT:
int features;

PPCODE:
features = git_libgit2_features();

mXPUSHs(newSVpv("threads", 0));
mXPUSHs(newSViv((features & GIT_FEATURE_THREADS) ? 1 : 0));
mXPUSHs(newSVpv("https", 0));
mXPUSHs(newSViv((features & GIT_FEATURE_HTTPS) ? 1 : 0));
mXPUSHs(newSVpv("ssh", 0));
mXPUSHs(newSViv((features & GIT_FEATURE_SSH) ? 1 : 0));

XSRETURN(6);

INCLUDE: xs/Blame.xs
INCLUDE: xs/Blame/Hunk.xs
INCLUDE: xs/Blob.xs
Expand Down
5 changes: 5 additions & 0 deletions lib/Git/Raw.pm
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ API.
B<WARNING>: The API of this module is unstable and may change without warning
(any change will be appropriately documented in the changelog).
=head2 features( )
List of (optional) compiled in features. Git::Raw may be built with support
for threads, HTTPS and SSH.
=head1 AUTHOR
Alessandro Ghedini <alexbio@cpan.org>
Expand Down
17 changes: 17 additions & 0 deletions t/23-diagnostics.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!perl

use Test::More;

use Git::Raw;

my %features;

ok (eval { %features = Git::Raw -> features });
is scalar(keys %features), 3;

diag("Build info:");
diag("Built with threads support: $features{threads}");
diag("Built with HTTPS support: $features{https}");
diag("Built with SSH support: $features{ssh}");

done_testing;

0 comments on commit 50947d3

Please sign in to comment.