Created
April 27, 2016 03:52
-
-
Save rakkang/a1ea3ed7fe553c8bb8c94736783e7605 to your computer and use it in GitHub Desktop.
过滤 svn 日志
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# coding:utf-8 | |
import sys | |
argv_len = len(sys.argv) | |
def help(): | |
print 'Filter svnlog by user or date! ' | |
print 'USEAGE: svnlog [ARGs] ' | |
print 'ARGs: ' | |
print ' -n[=name]: ' | |
print ' filter by the special [=name]\n' | |
print ' -t[=date]: ' | |
print ' filter by the special [=date] ' | |
print 'EXP: ' | |
print '1. Filter kang\'s commit log \n' | |
print ' svn log -l 50 | svnlog -n=kang\n' | |
if not argv_len - 1: | |
help() | |
quit() | |
author = '' | |
date = '' | |
for index in range(1, argv_len): | |
argv = sys.argv[index] | |
if argv.startswith('-n='): | |
author = argv.replace('-n=', '') | |
elif argv.startswith('-t='): | |
date = argv.replace('-t=', '') | |
else: | |
help() | |
quit() | |
if author == '' and date == '': | |
help() | |
quit() | |
# svn log 输出的分割线 | |
SPLIT_LINE = '------------------------------------------------------------------------' | |
src = ''.join(sys.stdin.readlines()) | |
lines = src.split(SPLIT_LINE) | |
for line in lines: | |
if author in line and date in line: | |
print SPLIT_LINE, line, | |
if len(lines): | |
print SPLIT_LINE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment