def command(argv): initialized() if len(argv) < 1: help() sys.exit(1) filename = argv[0] index = Index() index.load(os.path.join(MYGIT_ROOTDIR, 'index')) index.add_file(filename) index.save(os.path.join(MYGIT_ROOTDIR, 'index'))
def command(argv): initialized() if len(argv) < 2 or argv[0] != '-m': help() sys.exit(1) message = argv[1] filename = os.path.join(MYGIT_ROOTDIR, 'index') index = Index() index.load(filename) sha1 = index.write_tree() head = HEAD.from_file() if head.ref is None: print >> sys.stderr, "the head is detached!" sys.exit(1) branch = Branch.from_file(head.ref) # parent will be fixed when branch is implemented commit = Commit(sha1, "Oguz", message, branch.sha1text) commitsha1 = commit.save() branch.sha1text = commitsha1 branch.save() index.save(filename) print commitsha1