Read tree and move HEAD in checkout

This commit is contained in:
David Doblas Jiménez 2024-03-29 18:27:10 +01:00
parent 817f38f49c
commit b802e1eb9d
2 changed files with 14 additions and 0 deletions

View File

@ -97,6 +97,12 @@ def commit(message):
return oid
def checkout(oid):
commit = get_commit(oid)
read_tree(commit.tree)
data.set_HEAD(oid)
Commit = namedtuple("Commit", ["tree", "parent", "message"])

View File

@ -45,6 +45,10 @@ def parse_args():
log_parser.set_defaults(func=log)
log_parser.add_argument("oid", nargs="?")
checkout_parser = commands.add_parser("checkout")
checkout_parser.set_defaults(func=checkout)
checkout_parser.add_argument("oid")
return parser.parse_args()
@ -85,3 +89,7 @@ def log(args):
print("")
oid = commit.parent
def checkout(args):
base.checkout(args.oid)