emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/auctex d7f443e 37/69: Add script to update the ChangeLo


From: Tassilo Horn
Subject: [elpa] externals/auctex d7f443e 37/69: Add script to update the ChangeLog
Date: Sat, 26 Mar 2016 21:36:35 +0000

branch: externals/auctex
commit d7f443e5c9237cef9c0392738877cd5d6a093fe0
Author: Mosè Giordano <address@hidden>
Commit: Mosè Giordano <address@hidden>

    Add script to update the ChangeLog
    
    * ChangeLog.1: Add copyright notice and information about included
      commits.
    * Makefile.in: Add ChangeLog-related variables and rules.
    * build-aux/gitlog-to-auctexlog: New script, adapted from GNU Emacs.
---
 ChangeLog.1                   |   21 +++++++
 Makefile.in                   |   54 +++++++++++++++++
 build-aux/gitlog-to-auctexlog |  131 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 206 insertions(+), 0 deletions(-)

diff --git a/ChangeLog.1 b/ChangeLog.1
index 7a80e13c..1b523cd 100644
--- a/ChangeLog.1
+++ b/ChangeLog.1
@@ -18256,6 +18256,27 @@
 
        * Version 9.1 released.
 
+This file records repository revisions from
+commit c865982cacab289f4480f9145b3438ec06824232 (exclusive) to
+commit df7dbbd3a029f02042b4fa01725c4a1f4502ff56 (inclusive).
+
 ;; Local Variables:
 ;; coding: iso-8859-1
 ;; End:
+
+  Copyright (C) 1994-2016 Free Software Foundation, Inc.
+
+  This file is part of GNU AUCTeX.
+
+  GNU AUCTeX is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, either version 3 of the License, or
+  (at your option) any later version.
+
+  GNU AUCTeX is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with GNU AUCTeX.  If not, see <http://www.gnu.org/licenses/>.
diff --git a/Makefile.in b/Makefile.in
index ee9c122..ffe6d76 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -397,6 +397,60 @@ wc:
        wc $(AUCSRC) $(STYLESRC)
 
 # ----------------------------------------------------------------------
+# The targets below update the ChangeLog from git log
+# and are intended to be used only by the maintainers.
+# These rules are adapted from GNU Emacs Makefile.
+
+.PHONY: ChangeLog change-history change-history-commit change-history-nocommit
+.PHONY: preferred-branch-is-current unchanged-history-files
+
+CHANGELOG = ChangeLog
+auctexlog = build-aux/gitlog-to-auctexlog
+# The ChangeLog history files are called ChangeLog.1, ChangeLog.2, ...,
+# ChangeLog.$(CHANGELOG_HISTORY_INDEX_MAX).  $(CHANGELOG_N) stands for
+# the newest (highest-numbered) ChangeLog history file.
+CHANGELOG_HISTORY_INDEX_MAX = 1
+CHANGELOG_N = ChangeLog.$(CHANGELOG_HISTORY_INDEX_MAX)
+
+# Check that we are in a good state for changing history.
+PREFERRED_BRANCH = master
+preferred-branch-is-current:
+       git branch | grep -q '^\* $(PREFERRED_BRANCH)$$'
+unchanged-history-files:
+       x=$$(git diff-files --name-only $(CHANGELOG_N) $(auctexlog)) && \
+         test -z "$$x"
+
+# Convert git commit log to ChangeLog file.  make-dist uses this.
+# I guess this is PHONY so it always updates?
+ChangeLog:
+         ./$(auctexlog) -o $(CHANGELOG) -n $(CHANGELOG_HISTORY_INDEX_MAX)
+
+# Regular expression that matches the newest commit covered by a ChangeLog.
+new_commit_regexp = ^commit [0123456789abcdef]* (inclusive)
+
+# Copy newer commit messages to the start of the ChangeLog history file,
+# and consider them to be older.
+change-history-nocommit: #preferred-branch-is-current unchanged-history-files
+       -rm -f ChangeLog.tmp
+       $(MAKE) ChangeLog CHANGELOG=ChangeLog.tmp
+       sed '/^This file records repository revisions/,$$d' \
+         ChangeLog.tmp > $(CHANGELOG_N).tmp
+       new_commit_line=`grep --text '$(new_commit_regexp)' ChangeLog.tmp` && \
+       sed 's/$(new_commit_regexp).*/'"$$new_commit_line/" \
+         $(CHANGELOG_N) >>$(CHANGELOG_N).tmp
+       rm ChangeLog.tmp
+       mv $(CHANGELOG_N).tmp $(CHANGELOG_N)
+
+change-history: change-history-nocommit
+       $(MAKE) address@hidden
+
+# If 'make change-history' fails because the newest ChangeLog history
+# file contains invalid text, fix the file by hand and then run
+# 'make change-history-commit'.
+change-history-commit:
+       git commit -m'; make $@' $(CHANGELOG_N) $(auctexlog)
+
+# ----------------------------------------------------------------------
 # The targets below are concerned with the release process and
 # intended to be used only by the maintainers.
 
diff --git a/build-aux/gitlog-to-auctexlog b/build-aux/gitlog-to-auctexlog
new file mode 100755
index 0000000..9836713
--- /dev/null
+++ b/build-aux/gitlog-to-auctexlog
@@ -0,0 +1,131 @@
+#!/bin/sh
+
+# Convert git log output to ChangeLog format for GNU AUCTeX.
+# Adapted from build-auc/gitlog-to-emacslog script, part of GNU Emacs.
+
+# Copyright (C) 2014-2016 Free Software Foundation, Inc.
+
+# Original Author: Paul Eggert
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+LC_ALL=C
+export LC_ALL
+
+# The newest revision that should not appear in the generated ChangeLog.
+gen_origin=
+
+force=
+output=ChangeLog
+nmax=1
+
+while [ $# -gt 0 ]; do
+  case "$1" in
+      -g|--gen-origin) gen_origin="$2" ; shift ;;
+      -f|--force) force=1 ;;
+      -n|--nmax) nmax="$2"; shift ;;
+      -o|--output) output="$2" ; shift ;;
+      *) printf '%s\n' "Unrecognized argument: $1" >&2; exit 1 ;;
+  esac
+  shift
+done
+
+if [ ! -f ChangeLog.$nmax ]; then
+    printf '%s\n' "Can't find ChangeLog.$nmax" >&2
+    printf '%s\n' "Must be run from the top source directory" >&2
+    exit 1
+fi
+
+# If not specified in the command line, get gen_origin from the existing
+# ChangeLog file.
+[ "$gen_origin" ] || {
+    gen_origin_line=`
+      grep --text -E '^commit [0-9a-f]+ [(]inclusive[)]' ChangeLog.$nmax
+    ` || {
+       printf '%s\n' "ChangeLog.$nmax lacks a 'commit ... (inclusive)' line" 
>&2
+       exit 1
+    }
+    set $gen_origin_line
+    gen_origin=$2
+}
+
+# Get the new value for gen_origin from the latest version in the repository.
+new_origin=`git log --pretty=format:%H 'HEAD^!'` || exit
+
+if [ -f "$output" ]; then
+    [ ! "$force" ] && printf '%s\n' "$output exists" >&2 && exit 1
+    rm -f "$output" || exit 1
+fi
+
+# If this is not a Git repository, just generate an empty ChangeLog.
+test -d .git || {
+  >"$output"
+  exit
+}
+
+# Use Gnulib's packaged ChangeLog generator.
+# Maybe we should skip all "Merge branch 'master'" messages.
+# NOTE: in AUCTeX the ChangeLog is encoded with ISO-8859-1, use iconv
+# to enforce this encoding in the output file.
+./build-aux/gitlog-to-changelog \
+    --ignore-matching="^; |^Merge branch .*$|^Merge from master\.$|^Merge 
master branch\.$" \
+  --ignore-line='^; ' --format='%B' \
+  "$gen_origin..$new_origin" | iconv -f UTF-8 -t ISO-8859-1 - >"ChangeLog.tmp" 
|| exit
+
+if test -s "ChangeLog.tmp"; then
+
+  # Fix up bug references.
+  # This would be better as eg a --transform option to gitlog-to-changelog,
+  # but... effort.  FIXME does not handle rare cases like:
+  # Fixes: debbugs:19434 debbugs:19519
+  sed 's/      Fixes: \(debbugs:\|bug#\)\([0-9][0-9]*\)/       (Bug#\2)/' \
+      "ChangeLog.tmp" > "ChangeLog.tmp2"
+  mv "ChangeLog.tmp2" "ChangeLog.tmp"
+
+  # Find the years covered by the generated ChangeLog, so that
+  # a proper copyright notice can be output.
+  years=`
+    sed -n 's/^\([0-9][0-9]*\).*/\1/p' "ChangeLog.tmp" |
+    sort -nu
+  `
+  start_year=
+  end_year=
+  for year in $years; do
+    : ${start_year:=$year}
+    end_year=$year
+  done
+
+  if test "$start_year" = "$end_year"; then
+    year_range=$start_year
+  else
+    year_range=$start_year-$end_year
+  fi
+
+  # Update gen_origin and append a proper copyright notice.
+  sed -n '
+    1i\
+
+    /^This file records repository revisions/p
+    s/^commit [0-9a-f]* (exclusive)/commit '"$gen_origin"' (exclusive)/p
+    s/^commit [0-9a-f]* (inclusive)/commit '"$new_origin"' (inclusive)/p
+    /^See ChangeLog.[0-9]* for earlier/,${
+       s/ChangeLog\.[0-9]*/ChangeLog.'$nmax'/
+       s/\(Copyright[ (C)]*\)[0-9]*-[0-9]*/\1'"$year_range"'/
+       p
+    }
+  ' <ChangeLog.$nmax >>"ChangeLog.tmp" || exit
+fi
+
+# Install the generated ChangeLog.
+test "$output" = "ChangeLog.tmp" || mv "ChangeLog.tmp" "$output"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]