Implement log
This commit is contained in:
20
ugit/cli.py
20
ugit/cli.py
@@ -1,7 +1,8 @@
|
||||
from pathlib import Path
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
import textwrap
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from . import base
|
||||
from . import data
|
||||
@@ -40,6 +41,9 @@ def parse_args():
|
||||
commit_parser.set_defaults(func=commit)
|
||||
commit_parser.add_argument("-m", "--message", required=True)
|
||||
|
||||
log_parser = commands.add_parser("log")
|
||||
log_parser.set_defaults(func=log)
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
@@ -68,3 +72,15 @@ def read_tree(args):
|
||||
|
||||
def commit(args):
|
||||
print(base.commit(args.message))
|
||||
|
||||
|
||||
def log(args):
|
||||
oid = data.get_HEAD()
|
||||
while oid:
|
||||
commit = base.get_commit(oid)
|
||||
|
||||
print(f"commit {oid}\n")
|
||||
print(textwrap.indent(commit.message, " "))
|
||||
print("")
|
||||
|
||||
oid = commit.parent
|
||||
|
||||
Reference in New Issue
Block a user