Avoid changing directory when generating the ChangeLog file.

Instead, pass the repo path to either hg or log2cl.pl
This commit is contained in:
Todd C. Miller
2020-02-10 08:02:47 -07:00
parent 2781ec030b
commit c2f3f60583
2 changed files with 22 additions and 9 deletions

View File

@@ -23,7 +23,7 @@ abs_top_srcdir = @abs_top_srcdir@
top_builddir = @top_builddir@
abs_top_builddir = @abs_top_builddir@
devdir = @devdir@
scriptdir = $(abs_top_srcdir)/scripts
scriptdir = $(top_srcdir)/scripts
# Installation paths for package building
prefix = @prefix@
@@ -222,16 +222,16 @@ depend: siglist.c signame.c
--file $(top_builddir)/src/Makefile
ChangeLog:
if test -d $(srcdir)/.hg && cd $(srcdir); then \
if hg log --style=changelog -r "sort(branch(.) or follow(), -date)" > $@.tmp; then \
mv -f $@.tmp $@; \
if test -d $(srcdir)/.hg; then \
if hg log -R $(srcdir) --style=changelog -r "sort(branch(.) or follow(), -date)" > $@.tmp; then \
mv -f $@.tmp $(srcdir)/$@; \
else \
rm -f $@.tmp; \
fi; \
elif test -d $(srcdir)/.git && cd $(srcdir); then \
$(scriptdir)/log2cl.pl -b master > $@; \
elif test -d $(srcdir)/.git; then \
$(scriptdir)/log2cl.pl -R $(srcdir)/.git > $(srcdir)/$@; \
else \
echo "ChangeLog data not available" > $@; \
echo "ChangeLog data not available" > $(srcdir)/$@; \
fi
config.status:

View File

@@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: ISC
#
# Copyright (c) 2017 Todd C. Miller <Todd.Miller@sudo.ws>
# Copyright (c) 2017, 2020 Todd C. Miller <Todd.Miller@sudo.ws>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
@@ -19,10 +19,23 @@
# Simple script to massage "git log" output into a GNU style ChangeLog.
# The goal is to emulate "hg log --style=changelog" via perl format.
use Getopt::Std;
use strict;
use warnings;
# Git log format: author date, author name, author email
# abbreviated commit hash
# raw commit body
my $format="%ad %aN <%aE>%n%h%n%B%n";
my @cmd = ("git", "log", "--log-size", "--name-only", "--date=short", "--format=$format", @ARGV);
# Parse options and build up "git log" command
my @cmd = ( "git" );
my %opts;
getopts('b:R:', \%opts);
push(@cmd, "-b", $opts{"b"}) if exists $opts{"b"};
push(@cmd, "--git-dir", $opts{"R"}) if exists $opts{"R"};
push(@cmd, "log", "--log-size", "--name-only", "--date=short", "--format=$format", @ARGV);
open(LOG, '-|', @cmd) || die "$0: unable to run git log: $!";
my $hash;