aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/gen-version.sh
blob: 3a080157cf4e871d8e4f63d01855d8eeaf36f943 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/sh

# Get version-info specified in Makefile
V=$1

# Use `git describe` to get current version if we're inside a git repo
if test -d .git
then
	V=$(git describe --abbrev=4 HEAD 2>/dev/null)
fi

new="CGIT_VERSION = $V"
old=$(cat VERSION 2>/dev/null)

# Exit if VERSION is uptodate
test "$old" = "$new" && exit 0

# Update VERSION with new version-info
echo "$new" > VERSION
cat VERSION
etting ) # CGIT_REPO_DEFBRANCH ( = repo.defbranch setting ) # CGIT_REPO_SECTION ( = section setting ) # CGIT_REPO_CLONE_URL ( = repo.clone-url setting ) import sys from pygments import highlight from pygments.util import ClassNotFound from pygments.lexers import TextLexer from pygments.lexers import guess_lexer from pygments.lexers import guess_lexer_for_filename from pygments.formatters import HtmlFormatter # read stdin and decode to utf-8. ignore any unkown signs. data = sys.stdin.read().decode(encoding='utf-8', errors='ignore') filename = sys.argv[1] formatter = HtmlFormatter(encoding='utf-8', style='pastie') try: lexer = guess_lexer_for_filename(filename, data, encoding='utf-8') except ClassNotFound: # check if there is any shebang if data[0:2] == '#!': lexer = guess_lexer(data, encoding='utf-8') else: lexer = TextLexer(encoding='utf-8') except TypeError: lexer = TextLexer(encoding='utf-8') # highlight! :-) # printout pygments' css definitions as well sys.stdout.write('<style>') sys.stdout.write(formatter.get_style_defs('.highlight')) sys.stdout.write('</style>') highlight(data, lexer, formatter, outfile=sys.stdout)