diff options
author | Eric Wong <e@80x24.org> | 2021-04-01 02:32:37 -0700 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-04-01 18:25:15 +0000 |
commit | 1fae720d364681d7d1367ecce71abd780eecd087 (patch) | |
tree | ec7c24f7e803a2eae4173f2e503630dea257948f | |
parent | c790a75439f3a1dbbaa2162feca2593de5997bd3 (diff) | |
download | public-inbox-1fae720d364681d7d1367ecce71abd780eecd087.tar.gz |
Thanks to git-describe, we can generate and update this file to aid users in bug reporting.
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | MANIFEST | 1 | ||||
-rw-r--r-- | Makefile.PL | 9 | ||||
-rw-r--r-- | t/config.t | 7 | ||||
-rw-r--r-- | version-gen.perl | 29 |
5 files changed, 42 insertions, 5 deletions
@@ -21,3 +21,4 @@ /NEWS.atom /NEWS *.log +/lib/PublicInbox.pm @@ -482,6 +482,7 @@ t/www_listing.t t/www_static.t t/x-unknown-alpine.eml t/xcpdb-reshard.t +version-gen.perl xt/cmp-msgstr.t xt/cmp-msgview.t xt/create-many-inboxes.t diff --git a/Makefile.PL b/Makefile.PL index feb89ec1..129b082d 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -5,6 +5,7 @@ use strict; use ExtUtils::MakeMaker; open my $m, '<', 'MANIFEST' or die "open(MANIFEST): $!\n"; chomp(my @manifest = (<$m>)); +push @manifest, 'lib/PublicInbox.pm'; # generated my @EXE_FILES = grep(m!^script/!, @manifest); my $v = {}; my $t = {}; @@ -139,7 +140,7 @@ WriteMakefile( NAME => 'PublicInbox', # n.b. camel-case is not our choice # XXX drop "PENDING" in .pod before updating this! - VERSION => '1.6.1', + VERSION => '1.7.0.PENDING', AUTHOR => 'Eric Wong <e@80x24.org>', ABSTRACT => 'public-inbox server infrastructure', @@ -242,13 +243,17 @@ Makefile.PL : MANIFEST # prefix + bindir matches git.git Makefile: prefix = \$(HOME) bindir = \$(prefix)/bin -symlink-install : +symlink-install : lib/PublicInbox.pm mkdir -p \$(bindir) lei=\$\$(realpath lei.sh) && cd \$(bindir) && \\ for x in \$(EXE_FILES); do \\ ln -sf "\$\$lei" \$\$(basename "\$\$x"); \\ done +pure_all :: lib/PublicInbox.pm +lib/PublicInbox.pm : FORCE + VERSION=\$(VERSION) \$(PERL) -w ./version-gen.perl + update-copyrights : \@case '\$(GNULIB_PATH)' in '') echo >&2 GNULIB_PATH unset; false;; esac git ls-files | UPDATE_COPYRIGHT_HOLDER='all contributors' \\ @@ -1,11 +1,12 @@ # Copyright (C) 2014-2021 all contributors <meta@public-inbox.org> # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt> use strict; -use warnings; -use Test::More; -use PublicInbox::Config; +use v5.10.1; use PublicInbox::TestCommon; use PublicInbox::Import; +use_ok 'PublicInbox'; +ok(defined(eval('$PublicInbox::VERSION')), 'VERSION defined'); +use_ok 'PublicInbox::Config'; my ($tmpdir, $for_destroy) = tmpdir(); { diff --git a/version-gen.perl b/version-gen.perl new file mode 100644 index 00000000..e9964e30 --- /dev/null +++ b/version-gen.perl @@ -0,0 +1,29 @@ +#!perl -w +use v5.10.1; +my $v = $ENV{VERSION} // die 'VERSION unset'; +my $f = './lib/PublicInbox.pm'; +if (-d ($ENV{GIT_DIR} // '.git') || -f '.git') { + chomp(my $gv = `git describe --match "v[0-9]*" HEAD`); + if ($? == 0) { + substr($gv, 0, 1, ''); # remove "v" + system(qw(git update-index -q --refresh)); + if (my @n = `git diff-index --name-only HEAD --`) { + $gv .= '-dirty'; + } + $v = $gv; + } +} +$v =~ tr/-/./; +if (-f $f && do $f && (eval('$PublicInbox::VERSION') // 'undef') eq $v) { + exit +} +my $tmp = "$f.tmp.$$"; +open my $fh, '>', $tmp or die "open($tmp): $!"; +print $fh <<EOM or die "print($tmp): $!"; +# this file is generated by $0 +package PublicInbox; +our \$VERSION = '$v'; +1; +EOM +close $fh or die "close($tmp): $!"; +rename($tmp, $f) or die "rename($tmp, $f): $!"; |