|
|
Generate changelog out of GIT repositoryThis is a very evident mere task. But after half an hour of googling I did not find any appropriate code that could implement it. Actualy the task is to create changelog xml file out of git repository getting GIT tags as releases versions and certain changesets as key changesets. Finally I create the python module named git2changelog.py. You can use one freely with no warranty. Here it is.
import sys, subprocess, xml.etree.ElementTree as ET
def git2changelog(filter_prefix, shell, callback):
lines = lambda cmd: [ line.strip() for line in subprocess.Popen(cmd, shell = shell, stdout = subprocess.PIPE).stdout ]
commits = [ line.split('\t') for line in lines('git log --pretty=format:"%H\t%ci\t%s"') ]
tags = filter(lambda x: x.find(filter_prefix) == 0, lines('git tag'))
tags_commits = dict([ (lines('git show %s --pretty=format:%%H --shortstat' % tag)[0], tag) for tag in tags ])
commit_prefix = filter_prefix + ':'
for i, commit in enumerate(commits):
(sha1, date, subj) = commit
if sha1 in tags_commits:
callback('tag', date, 'Version ' + tags_commits[sha1][len(filter_prefix):])
elif i == 0:
callback('tag', date, 'Development head')
if subj[:len(commit_prefix)] == commit_prefix:
callback('commit', date, subj[len(commit_prefix):])
return callback.result
class Callback_text:
def __init__(self):
self.result = ''
def __call__(self, typee, date, text):
if typee == 'tag':
self.result += text + '\n'
elif typee == 'commit':
self.result += '\t%s\n' % date
self.result += '\t\t%s\n\n' % text
class Callback_textOut:
def __init__(self):
self.result = None
def __call__(self, typee, date, text):
if typee == 'tag':
print text
elif typee == 'commit':
print '\t%s' % date
print '\t\t%s\n' % text
class XmlBuilder:
def __init__(self):
self.result = ET.Element('div')
def __call__(self, typee, date, text):
date_element = ET.Element('div',{'class':'changelog_date'})
date_element.text = date
text_element = ET.Element('div',{'class':'changelog_text'})
text_element.text = text
if typee == 'tag':
element = ET.Element('div',{'class':'changelog_tag'})
element.append(text_element)
element.append(date_element)
elif typee == 'commit':
element = ET.Element('div',{'class':'changelog_commit'})
element.append(date_element)
element.append(text_element)
self.result.append(element)
git2changelog function takes filter_prefix parameter that is usually
a product name. Key changesets should start with filter_prefix: string and tags
should be filter_prefixVERSION string. This is useful when you have several
projects within the single repository and want to have different changelogs for them.
For example for fastmake to print out a changelog I use the following
git2changelog('fastmake', True, callback_textOut)
to build XML tree
xmlBuilder = XmlBuilder()
git2changelog('fastmake', True, xmlBuilder)
# xmlBuilder.result is the result
Then you can use built XML tree at your discretion.
Building llvm + clang in MSVC 9.0 SP1LLVM is well-known multiplatform open source and free software library that can provide low level machine code in runtime. Clang is a great frontend for LLVM that implements C/C++ language parser. It can provide semantic tree and LLVM representation of parsed C/C++ code. The fact is that official LLVM as well as CLANG do not compile under MSVC 9.0 SP1. Googling over Internet was not of use. Most of links point to official site or compiling some other bugs. So I had to plunge into sources and finally won it. The following link points to an archive of llvm+clang package that do compile under MSVC. You need 7-zip program to extract an archive llvm+clang-2.7-msvc.7z The key change in clang distribution is to uncomment the following macro in Ownership.h file#define DISABLE_SMART_POINTERSThis will change implementation in some ownership classes that cause multiple compile errors in Parse module. However this package contains many other compile bugs.
The website was built by Fastmake and Genshi template engine.
Authorship and copyright (C) Vitaly Grechko vitaly@grechko.ru 2008-2010
|