mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-12-11 09:20:32 +00:00
bf352eceda
* Makefile: Include default.mk and targets.mk from mk/ where they've been moved to. * README_maintainer: Rename utils to make throughout. * doc/Makefile: Rename utils to make throughout. * doc/org.texi: Remove reference to utils/, x11idle.c is now in contrib/scripts. * mk/make_emacs_changelog: Add mk/ to list of directories not to be reported in Emacs' ChangeLog. Also retain utils/ and re-add UTILITIES; add a comment explaining why these need to stay. * mk/default.mk: Rename utils to make throughout. Include version.mk from mk/ where it's been moved to. * mk/targets.mk: Rename utils to make throughout. * mk/server.mk: Rename utils to make throughout. Only put those files from mk/ into the archives that are needed outside the server: default.mk targets.mk version.mk and org-fixup.el. * lisp/org-compat.el: Rename utils to make throughout. * .gitignore: Rename utils to make throughout.
94 lines
2.5 KiB
Python
Executable File
94 lines
2.5 KiB
Python
Executable File
#!/usr/bin/env python
|
|
|
|
# git-changelog
|
|
#
|
|
# version 2.0, by John Wiegley
|
|
#
|
|
# The purpose of this code is to turn "git log" output into a complete
|
|
# ChangeLog, for projects who wish to begin using a ChangeLog, but haven't
|
|
# been.
|
|
#
|
|
# This version of git-changelog depends on GitPython:
|
|
# git://gitorious.org/git-python/mainline.git
|
|
|
|
import time
|
|
import string
|
|
import sys
|
|
import re
|
|
import os
|
|
|
|
from git import * # GitPython
|
|
from subprocess import *
|
|
|
|
repo = Repo(os.getcwd())
|
|
ref = 'origin/master..'
|
|
path = ''
|
|
|
|
# Usage: git changelog [COMMITISH] [-- [PATH]]
|
|
|
|
saw_dashdash = False
|
|
if len(sys.argv) > 1:
|
|
for arg in sys.argv[1:]:
|
|
if arg == "--":
|
|
saw_dashdash = True
|
|
elif saw_dashdash:
|
|
path = arg
|
|
else:
|
|
ref = arg
|
|
|
|
for commit in repo.iter_commits(ref, paths=path):
|
|
hash_id = commit.sha
|
|
author = commit.author
|
|
date = commit.committed_date
|
|
log_text = commit.message.split('\n')[0]
|
|
|
|
log_text_remainder = commit.message.split('\n\n')[1:]
|
|
while len(log_text_remainder) > 0 and not log_text_remainder[0]:
|
|
log_text_remainder = log_text_remainder[1:]
|
|
log_text_remainder = string.join(log_text_remainder, '\n\t')
|
|
if log_text_remainder:
|
|
log_text_remainder = '\n\t' + log_text_remainder
|
|
|
|
diff = commit.diff(commit.parents[0])
|
|
files = []
|
|
for f in diff:
|
|
if not f.a_blob:
|
|
p = f.b_blob.path
|
|
elif not f.b_blob:
|
|
p = f.a_blob.path
|
|
else:
|
|
continue
|
|
|
|
p2 = re.sub('^' + path + '/', '', p)
|
|
if p != p2:
|
|
files.append(p2)
|
|
|
|
fp = Popen(["fmt", "-72"], shell = True, stdin = PIPE, stdout = PIPE)
|
|
if files:
|
|
fp.stdin.write("\t* %s: %s" % (string.join(files, ",\n\t"), log_text))
|
|
else:
|
|
fp.stdin.write("\t* %s" % log_text)
|
|
fp.stdin.close()
|
|
log_text = fp.stdout.read()
|
|
del fp
|
|
|
|
print "%s %s <%s>\n" % \
|
|
(time.strftime("%Y-%m-%d", time.gmtime(date)),
|
|
author.name, author.email)
|
|
|
|
if path:
|
|
log_text = re.sub(' ' + path + '/', ' ', log_text)
|
|
log_text_remainder = re.sub(' ' + path + '/', ' ', log_text_remainder)
|
|
|
|
# If the log_text_remainder already begins with a *, then use that as the
|
|
# changelog text.
|
|
if re.match('\s+\* ', log_text_remainder):
|
|
if log_text_remainder[0] == '\n':
|
|
print log_text_remainder[1:]
|
|
else:
|
|
print log_text_remainder
|
|
else:
|
|
print "%s%s" % (log_text, log_text_remainder)
|
|
|
|
# git-changelog ends here
|