include git commit hash in metadata
[p5sagit/Distar.git] / helpers / add-git-commit
1 #!/usr/bin/env perl
2 use strict;
3 use warnings FATAL => 'all';
4
5 use CPAN::Meta;
6 use Parse::CPAN::Meta;
7
8 my $file = shift || die "need a file";
9 my $meta = Parse::CPAN::Meta->load_file($file);
10
11 my $commit = `git rev-parse HEAD`;
12 chomp $commit;
13 $meta->{x_vcs_commit} = $commit;
14
15 my $tag = `git describe`;
16 chomp $tag;
17 $meta->{x_vcs_tag} = $tag;
18
19 CPAN::Meta->new($meta)->save($file, { version => ($file =~ /\.yml$/ ? 1 : 2) });