]> git.proxmox.com Git - pmg-api.git/blob - repoid.pl
reload postfix instead of restart on config change
[pmg-api.git] / repoid.pl
1 #!/usr/bin/perl -w
2
3 # use use the first 8 characters from the master commit ID
4
5 # git status --porcelain
6
7 use strict;
8 use lib qw(.);
9 use PVE::Tools qw(run_command);
10
11 my $gitdir = shift;
12 die "no repository" if !$gitdir;
13
14 my $path = "$gitdir/refs/heads/master";
15 die "master branch does not exists" if ! -f $path;
16
17 my $arg1 = shift;
18
19 if ($arg1) {
20 die "unknown parameter '$arg1'" if $arg1 ne 'check';
21
22 my $testfunc = sub {
23 my $line = shift;
24 return if $line =~ m/^#/;
25 return if $line =~ m/^\?\?/;
26
27 die "detected modified content: $line\n";
28 };
29
30 my $cmd = ['git', '--git-dir', $gitdir ,'status', '--porcelain'];
31 run_command($cmd, outfunc => $testfunc);
32 }
33
34 my $repoid = `cat $path`;
35 chomp $repoid;
36
37 die "invalid commit format" if $repoid !~ m/^[0-9a-f]{40}$/;
38
39 my $res = substr $repoid, 0, 8;
40 print "$res\n";