def copy_hash(index): commits = adjust.get_commits() if index > len(commits)-1: print yellow("this index is over length limit.") return print commits[index].commithash
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 show_log(): 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) todo_container = core.load_state(open(CACHE_FILE_PATH,"r")) commits = adjust.get_commits() pager = get_pager() isoformat = "%a %b %d %H:%M:%S %Y %z" io = StringIO() sys.stdout = io for commit in commits: print yellow("commit: %s" % commit.commithash) opened_commits = ([blue("'"+t.content+"'") for t in todo_container \ if t.opened_commit == commit.commithash]) closed_commits = ([red("'"+t.content+"'") for t in todo_container \ if t.closed_commit == commit.commithash]) if len(opened_commits) != 0: print "Opened ToDo: %s" % ", ".join(opened_commits) if len(closed_commits) != 0: print "Closed ToDo: %s" % ", ".join(closed_commits) if commit.merge_data != None: print "Merge: %s" % " ".join(commit.merge_data) print "Author: %s <%s>" % ( commit.author.name, commit.author.email) else: print "Author: %s <%s>" % ( commit.author.name, commit.author.email) print "Date: %s" % commit.date.strftime(isoformat) print print commit.comment print 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 show_diff(index): commits = adjust.get_commits() if index > len(commits)-1: print yellow("this index is over length limit.") return lines = git("show","%s" % commits[index]).split("\n") for line in lines: if line.startswith("+"): print red(line) elif line.startswith("-"): print green(line) elif line.startswith("diff") or line.startswith("index"): print yellow(line) else: print line
def latest(): commits = adjust.get_commits() print commits[0].commithash