Isomorphic-git: tags

Created on 15 Oct 2017  路  7Comments  路  Source: isomorphic-git/isomorphic-git

TODOs:

  • [x] create lightweight tag
  • [x] list lightweight tags
  • [x] delete lightweight tag
  • [x] push lightweight tag
  • [x] fetch lightweight tag
  • [x] checkout lightweight tag
  • [x] create annotated tag
  • [x] read annotated tag
  • [x] ~list annotated tags~ covered by listing lightweight tags
  • [x] delete annotated tag
  • [ ] push annotated tag
  • [ ] fetch annotated tag
  • [ ] checkout annotated tag

Implementation notes:
Writing an annotated tag parser should be trivial. Here's what they look like. The tagger line looks like it is the same format as author and committer in git commits.
```git tag
object af4d84a6a9fa7a74acdad07fddf9f17ff3a974ae
type commit
tag v0.0.9
tagger Will Hilton wmhilton@gmail.com 1507071414 -0400

0.0.9
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAABAgAGBQJZ1BW2AAoJEJYJuKWSi6a5S6EQAJQkK+wIXijDf4ZfVeP1E7Be
aDDdOLga0/gj5p2p081TLLlaKKLcYj2pub8BfFVpEmvT0QRaKaMb+wAtO5PBHTbn
y2s3dCmqqAPQa0AXrChverKomK/gUYZfFzckS8GaJTiw2RyvheXOLOEGSLTHOwy2
wjP8KxGOWfHlXZEhn/Z406OlcYMzMSL70H26pgyggSTe5RNfpXEBAgWmIAA51eEM
9tF9xuijc0mlr6vzxYVmfwat4u38nrwX7JvWp2CvD/qwILMAYGIcZqRXK5jWHemD
/x5RtUGU4cr47++FD3N3zBWx0dBiCMNUwT/v68kmhrBVX20DhcC6UX38yf1sdDfZ
yapht2+TakKQuw/T/K/6bFjoa8MIHdAx7WCnMV84M0qfMr+e9ImeH5Hj592qw4Gh
vSY80gKslkXjRnVes7VHXoL/lVDvCM2VNskWTTLGHqt+rIvSXNFGP05OGtdFYu4d
K9oFVEoRPFTRSeF/9EztyeLb/gtSdBmWP2AhZn9ip0a7rjbyv5yeayZTsedoUfe5
o8cB++UXreD+h3c/F6mTRs8aVELhQTZNZ677PY71HJKsCLbQJAd4n+gS1n8Y/7wv
Zp4YxnShDkMTV3rxZc27vehq2g9gKJzQsueLyZPJTzCHqujumiLbdYV4i4X4CZjy
dBWrLc3kdnemrlhSRzR2
=PrR1
-----END PGP SIGNATURE-----

Note that this is NOT a 'clearsigned' GPG document. 馃檮 But rather a 'detached' signature concatenated on the end of the payload with an extra newline in between.

payload.txt

git tag
object af4d84a6a9fa7a74acdad07fddf9f17ff3a974ae
type commit
tag v0.0.9
tagger Will Hilton wmhilton@gmail.com 1507071414 -0400

0.0.9

signature.txt

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAABAgAGBQJZ1BW2AAoJEJYJuKWSi6a5S6EQAJQkK+wIXijDf4ZfVeP1E7Be
aDDdOLga0/gj5p2p081TLLlaKKLcYj2pub8BfFVpEmvT0QRaKaMb+wAtO5PBHTbn
y2s3dCmqqAPQa0AXrChverKomK/gUYZfFzckS8GaJTiw2RyvheXOLOEGSLTHOwy2
wjP8KxGOWfHlXZEhn/Z406OlcYMzMSL70H26pgyggSTe5RNfpXEBAgWmIAA51eEM
9tF9xuijc0mlr6vzxYVmfwat4u38nrwX7JvWp2CvD/qwILMAYGIcZqRXK5jWHemD
/x5RtUGU4cr47++FD3N3zBWx0dBiCMNUwT/v68kmhrBVX20DhcC6UX38yf1sdDfZ
yapht2+TakKQuw/T/K/6bFjoa8MIHdAx7WCnMV84M0qfMr+e9ImeH5Hj592qw4Gh
vSY80gKslkXjRnVes7VHXoL/lVDvCM2VNskWTTLGHqt+rIvSXNFGP05OGtdFYu4d
K9oFVEoRPFTRSeF/9EztyeLb/gtSdBmWP2AhZn9ip0a7rjbyv5yeayZTsedoUfe5
o8cB++UXreD+h3c/F6mTRs8aVELhQTZNZ677PY71HJKsCLbQJAd4n+gS1n8Y/7wv
Zp4YxnShDkMTV3rxZc27vehq2g9gKJzQsueLyZPJTzCHqujumiLbdYV4i4X4CZjy
dBWrLc3kdnemrlhSRzR2
=PrR1
-----END PGP SIGNATURE-----

To verify: `gpg --verify signature.txt payload.txt`
To create:
```sh
gpg --armor --output signature.txt --detach-sig payload.txt
cat payload.txt signature.txt > newtag
SHA=$(git hash-object -t tag -w newtag)
echo "$SHA" > .git/refs/tags/newtag
git tag -v newtag
enhancement good first issue

Most helpful comment

Status update:

You can fetch tags (git.fetch({..., tags: true})) and list them (git.listTags(...)).
Checking out lightweight tags should work. Resolving and checking out annotated tags, and other tag operations don't yet.

All 7 comments

Status update:

You can fetch tags (git.fetch({..., tags: true})) and list them (git.listTags(...)).
Checking out lightweight tags should work. Resolving and checking out annotated tags, and other tag operations don't yet.

I'm curious why you don't need tags: true for clone. It seems tags are always fetched. Is that just an oversight or is there a reason the tags have to be fetched then?

I do it to be consistent with canonical git, which fetches tags during clone by default, but does not fetch tags during fetch by default.

It appears that canonical git has a --no-tags option. I guess I can add a noTags option to my clone as well. If you'd like that, please make a new issue for it so I don't forget about it 馃憤

Actually, I don't think tags are fetched on clone by default. At least, not with git 2.17.1. correction: false alarm. it does seem to require --no-tags.

I like the tags option on the fetch function and I think isomorphic-git should just be consistent and do the same for clone. I'll file an issue to discuss.

Done. See #307.

I proposed 2 issues related to tags: #519 & #520

Just to confirm, is it still accurate that checking out annotated tags is still not implemented? If so, I might see if I can tackle that

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pickledish picture pickledish  路  3Comments

stefan-guggisberg picture stefan-guggisberg  路  6Comments

chmac picture chmac  路  4Comments

juancampa picture juancampa  路  7Comments

willstott101 picture willstott101  路  4Comments