summaryrefslogtreecommitdiff
path: root/make_patchnum.pl
diff options
context:
space:
mode:
authorGraham Knop <haarg@haarg.org>2019-10-20 17:23:09 +0200
committerTodd Rinaldo <toddr@cpan.org>2019-10-23 11:24:03 -0500
commitd42c7c4125ae3252e1acb5b9e3126b57186c8850 (patch)
tree7dd8d6abcf7f1d826093a0fee60d5f4664871233 /make_patchnum.pl
parent2ed3a28816e0987ebe7c78e7a8eba84a0fb9b0e7 (diff)
downloadperl-d42c7c4125ae3252e1acb5b9e3126b57186c8850.tar.gz
add git commit info into archive exports to allow building outside git
Normally, builds require either a .patch file or to be built out of git when not a proper release. We can use git attributes to make a file that will give partial information about the commit when an archive is created. This allows downloads from github to build.
Diffstat (limited to 'make_patchnum.pl')
-rw-r--r--make_patchnum.pl29
1 files changed, 29 insertions, 0 deletions
diff --git a/make_patchnum.pl b/make_patchnum.pl
index fc28d58f20..df352cbf34 100644
--- a/make_patchnum.pl
+++ b/make_patchnum.pl
@@ -126,11 +126,40 @@ my $unpushed_commits = ' ';
my ($read, $branch, $snapshot_created, $commit_id, $describe)= ("") x 5;
my ($changed, $extra_info, $commit_title)= ("") x 3;
+my $git_patch_file;
if (my $patch_file= read_file(".patch")) {
($branch, $snapshot_created, $commit_id, $describe) = split /\s+/, $patch_file;
$extra_info = "git_snapshot_date='$snapshot_created'";
$commit_title = "Snapshot of:";
}
+elsif ($git_patch_file = read_file(".git_patch") and $git_patch_file !~ /\A\$Format:%H/) {
+ chomp $git_patch_file;
+ ($commit_id, my $commit_date, my $names)
+ = split /\|/, $git_patch_file;
+
+ my @names = split /,\s*/, $names;
+
+ ($branch) = map m{^HEAD -> (.*)}, @names;
+ if (!$branch) {
+ ($branch) = map m{^(blead|maint/.*)}, @names;
+ }
+ if (!$branch) {
+ ($branch) = map m{^tag: (.*)}, @names;
+ $describe = $branch;
+ }
+ if (!$branch) {
+ my ($pr) = map m{^refs/pull/([0-9]+)/}, @names;
+ $branch = "pull-request-$pr";
+ }
+ if (!$branch) {
+ $branch = $names[0] || $commit_id;
+ }
+
+ $describe ||= $commit_id;
+ $extra_info = "git_commit_date='$commit_date'\n";
+ $extra_info .= "git_snapshot_date='$commit_date'\n";
+ $commit_title = "Snapshot of:";
+}
elsif (-d "$srcdir/.git") {
# git branch | awk 'BEGIN{ORS=""} /\*/ { print $2 }'
($branch) = map { /\* ([^(]\S*)/ ? $1 : () } backtick("git branch");