Permalink
Browse files

Read version from source code; add --version; try protect my email fr…

…om spambot
  • Loading branch information...
1 parent 5d70855 commit 4f63013531e3885d3c7f0afee34f23bb786a8027 @ymattw committed Feb 5, 2013
Showing with 35 additions and 16 deletions.
  1. +5 −0 CHANGES
  2. +1 −1 LICENSE
  3. +1 −0 README.rst
  4. +16 −10 setup.py
  5. +12 −5 src/cdiff.py
View
@@ -2,6 +2,11 @@
Change log
==========
+Version 0.1 (2013-02-05)
+
+ - New --version option
+ - setup.py now read version from source code
+
Version 0.0.4 (2013-02-04)
- Add CHANGES for history track and better versioning
View
@@ -1,6 +1,6 @@
Software License Agreement (BSD-3 License)
-Copyright (c) 2013, Matthew Wang <mattwyl@gmail.com>
+Copyright (c) 2013, Matthew Wang <mattwyl(@)gmail(.)com>
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
View
@@ -87,6 +87,7 @@ Pipe in a diff:
git log -p -2 | cdiff -s
git show 15bfa56 | cdiff -s
svn diff -r PREV | cdiff -s
+ diff -u foo foo.new | cdiff -s
Redirect output to another patch file is safe:
View
@@ -10,23 +10,29 @@
os.unlink(link_name)
os.symlink('src/cdiff.py', link_name)
-with open('CHANGES') as changes:
- for change in changes:
- if change.startswith('Version '):
- version = change.split()[1]
+# This awfulness is all in aid of grabbing the version number out
+# of the source code, rather than having to repeat it here. Basically,
+# we parse out firt line starts with "__version__" and execute it
+#
+with open('cdiff') as script:
+ for line in script:
+ if line.startswith('__version__ = '):
+ exec(line)
break
- changes.seek(0)
- with open('README.rst') as doc:
- long_description = doc.read() + changes.read()
+
+with open('README.rst') as doc:
+ long_description = doc.read()
+with open('CHANGES') as changes:
+ long_description += changes.read()
setup(
name = 'cdiff',
- version = version,
+ version = __version__,
author = 'Matthew Wang',
- author_email = 'mattwyl@gmail.com',
+ author_email = 'mattwyl(@)gmail(.)com',
license = 'BSD-3',
description = ('Term based tool to view colored, incremental diff in '
- 'unified format or side ' 'by side with auto pager'),
+ 'unified format or side by side with auto pager'),
long_description = long_description,
keywords = 'colored incremental side-by-side diff',
url = 'https://github.com/ymattw/cdiff',
View
@@ -2,10 +2,12 @@
# -*- coding: utf-8 -*-
"""
-View colored, incremental diff in unified format or in side by side mode with
-auto pager. Requires Python (>= 2.5.0) and less.
+Term based tool to view colored, incremental diff in unified format or side by
+side with auto pager. Requires Python (>= 2.5.0) and less.
-See demo at homepage: https://github.com/ymattw/cdiff
+AUTHOR : Matthew Wang <mattwyl(@)gmail(.)com>
+LICENSE : BSD-3
+HOMEPAGE: https://github.com/ymattw/cdiff
"""
import sys
@@ -22,6 +24,10 @@
import difflib
+# REMEMBER UPDATE ``CHANGES``
+__version__ = '0.1'
+
+
COLORS = {
'reset' : '\x1b[0m',
'underline' : '\x1b[4m',
@@ -519,14 +525,15 @@ def main():
supported_vcs = [check[0] for check, _ in REVISION_CONTROL]
- usage = '%s [options] [diff]' % os.path.basename(sys.argv[0])
+ usage = '%prog [options] [diff]'
description= ('View colored, incremental diff in unified format or '
'side by side with auto pager. Read diff from diff '
'(patch) file if given, or stdin if redirected, or '
'diff produced by revision tool if in a %s workspace') \
% '/'.join(supported_vcs)
- parser = optparse.OptionParser(usage=usage, description=description)
+ parser = optparse.OptionParser(usage=usage, description=description,
+ version='%%prog %s' % __version__)
parser.add_option('-s', '--side-by-side', action='store_true',
help=('show in side-by-side mode'))
parser.add_option('-w', '--width', type='int', default=80, metavar='N',

0 comments on commit 4f63013

Please sign in to comment.