794 B
794 B
- tag: Resolve name to oid in argparse
It’s nice that we can create tags, but now let’s actually make them usable from the CLI.
In base.py, we’ll create get_oid to resolve a
“name” to an OID. A name can either be a ref (in which case
get_oid will return the OID that the ref points to) or an
OID (in which case get_oid will just return that same
OID).
Next, we’ll modify the argument parser in cli.py to call
get_oid on all arguments which are expected to be an OID.
This way we can pass a ref there instead of an OID.
At this point we can do something like:
$ ugit tag mytag d8d43b0e3a21df0c845e185d08be8e4028787069
$ ugit log refs/tags/mytag
# Will print log of commits starting at d8d43b0e...
$ ugit checkout refs/tags/mytag
# Will checkout commit d8d43b0e...
etc...