Files
DIY_GIT_in_Python/how_to/Change_22.md
2024-04-17 19:33:24 +02:00

875 B
Raw Blame History

  • tag: Create the tag ref

After weve implemented refs in the previous change, its time to create a ref when the user creates a tag.

create_tag now calls update_ref with the tag name to actually create the tag.

For namespacing purposes, well put all tags under refs/tags/. That is, if the user creates my-cool-commit tag, well create refs/tags/my-cool-commit ref to point to the desired OID.

Then well update data.py to handle this “namespaced” ref. Since we cant have a / in the file name, well create directories for it. Now if a ref refs/tags/sometag is created, it will be placed under .ugit/refs/tags in a file named sometag.

To verify that this code works, you can run:

$ ugit tag test

And make sure that the tag points to HEAD:

$ cat .ugit/refs/tags/test
$ cat .ugit/HEAD

The last two commands should give the same output.