def show_all(): commits = adjust.get_commits() pager = get_pager() io = StringIO() width = core.terminal_width() author_length = list(sorted([len(i.author.name) for i in commits]))[-1] number_length = len(str(len(commits)))+1 # コミットの長さの桁数 header = "#".ljust(number_length)+" "+"Date".ljust(19)+" "+\ "Author".ljust(author_length)+" "+"Hash".ljust(10)+" Comment" timeformat = core.isoformat.replace("-"," ") sys.stdout = io print header print "-"*(width-1) for index, commit_obj in enumerate(commits): print "%(index)s %(date)s %(author)s %(hash)s %(comment)s" % { "index" : yellow(index)+" "*(number_length-len(str(index))), "date" : commit_obj.date.strftime(timeformat), "author" : commit_obj.author.name.ljust(author_length), "hash" : commit_obj.commithash[:10], "comment": commit_obj.comment, } sys.stdout = sys.__stdout__ if pager == None: print io.getvalue()[:-1] else: proc = Popen(pager.split(" "), stdin=PIPE, stderr=PIPE) proc.communicate(io.getvalue()[:-1])
def todo_information(index): if os.access(CACHE_FILE_PATH, os.F_OK) != True: print "The repository does not todo initialized yet." print "Please do 'git todo init'" kill(1) # get todo container todo_container = core.load_state(open(CACHE_FILE_PATH,"r")) if len(todo_container) == 0: print "There is not ToDo." kill(1) if index > len(todo_container)-1: print "The Index value is over the number of todo." kill(1) todo = todo_container[index] timeformat = core.isoformat.replace("-"," ") print "%s" % yellow("#%d"%index) print "[%s]" % (blue(todo.status) if todo.status == "OPEN" else red(todo.status)), print todo.content print "-"*core.terminal_width() print "Author".ljust(13),":",magenta(todo.author) print "Primary Id".ljust(13),":",todo.hashid print "Created at".ljust(13), ":", todo.created_at.strftime( timeformat) if todo.status == "CLOSED": print "Closed at".ljust(13), ":", todo.closed_at.strftime( timeformat) print "Opened commit", ":", blue(todo.opened_commit) if todo.status == "CLOSED": print "Closed commit", ":", red(todo.closed_commit) print "-"*core.terminal_width()