Add change 23 instructions
This commit is contained in:
parent
edae32dc86
commit
63dcbeb9e7
22
how_to/Change_23.md
Normal file
22
how_to/Change_23.md
Normal file
@ -0,0 +1,22 @@
|
||||
- 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...
|
||||
```
|
Loading…
x
Reference in New Issue
Block a user