File: make_dot_patch.pl

package info (click to toggle)
perl 5.42.0-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 128,392 kB
  • sloc: perl: 534,963; ansic: 240,563; sh: 72,042; pascal: 6,934; xml: 2,428; yacc: 1,360; makefile: 1,197; cpp: 208; lisp: 1
file content (25 lines) | stat: -rwxr-xr-x 691 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/perl
use strict;
use warnings;
use POSIX qw(strftime);

# Generate .patch for later usage by smokers that are not synching via git

# Format date
sub iso_time_with_dot {
    return strftime "%Y-%m-%d.%H:%M:%S", gmtime(shift || time)
}

# Generate the content of .patch for HEAD
chomp(my ($git_dir, $sha1) = `git rev-parse --git-dir HEAD`);
die "Not in a git repository!" if !$git_dir;

my $branch = `git rev-parse --abbrev-ref HEAD`;
chomp $branch;

my $tstamp = iso_time_with_dot(`git log -1 --pretty="format:%ct" HEAD`);
my $describe= `git describe HEAD`;
chomp $describe;
my $dot_patch = join(" ", $branch, $tstamp, $sha1, $describe);

print $dot_patch, -t STDOUT ? "\n" : "";