42 lines
1.3 KiB
Markdown
42 lines
1.3 KiB
Markdown
- tag: Implement CLI command
|
|
|
|
Now that we have branching history we have some OIDs we need to keep track of.
|
|
Assume we have two branches (continuing from the example we had for `checkout`):
|
|
```
|
|
o-----o-----o-----o-----@-----@-----@
|
|
^ \ ^
|
|
first commit ----$-----$ 6c9f80a187ba39b4...
|
|
^
|
|
d8d43b0e3a21df0c...
|
|
```
|
|
|
|
If we want to switch back and forth between the two "branches" with `checkout`,
|
|
we need to remember both OIDs, which are quite long.
|
|
|
|
To make our lives easier, let's implement a command to attach a name to an OID.
|
|
Then we'll be able to refer to the OID by that name.
|
|
|
|
The end result will look like this:
|
|
```
|
|
$ # Make some changes
|
|
...
|
|
$ ugit commit
|
|
d8d43b0e3a21df0c845e185d08be8e4028787069
|
|
$ ugit tag my-cool-commit d8d43b0e3a21df0c845e185d08be8e4028787069
|
|
$ # Make more changes
|
|
...
|
|
$ ugit commit
|
|
e549f09bbd08a8a888110b07982952e17e8c9669
|
|
|
|
$ ugit checkout my-cool-commit
|
|
or
|
|
$ ugit checkout d8d43b0e3a21df0c845e185d08be8e4028787069
|
|
```
|
|
|
|
The last two commands are equivalent, because "my-cool-commit" is a tag that
|
|
points to d8d43b0e3a21df0c845e185d08be8e4028787069.
|
|
|
|
We will implement this in a few steps. The first step is to create a CLI
|
|
commmand that call the relevant command in the base module. The base module does
|
|
nothing at this stage.
|