Question

I'm trying to create a tag in my git repository via Grit, but I'm not sure that the library supports referenced tags. It's easy to create a tag like this:

Grit::Tag.create_tag_object(repo, params, actor)

But that will only create a lightweight tag. To have a referenced tag I need to create a ref to the tag also, but the implementation of update_ref looks like this:

def update_ref(head, commit_sha)
  return nil if !commit_sha || (commit_sha.size != 40)
  self.git.fs_write("refs/heads/#{head}", commit_sha)
  commit_sha
end

... which means that I can only create head refs, not a tag ref. There is nothing in the Ref or Tag classes that does anything.

Does anyone have an idea on how to create a reference to a commit via Grit?

Was it helpful?

Solution

I've created a new Tag linking to a commit as follows:

log = @repo.git.tag( { 'f' => true }, tag_name, commit_sha )

And got:

Updated tag 'new_tag' (was 0000000)
$ git tag
...
new_tag
...
$ git show new_tag
commit e74b99a0ff706993e200939ee00079182f75ec29
...

OTHER TIPS

I don't know much about grit (actually nothing). I would make a tag in regular git. Then find where it lives in the .git folder. Now search the grit source code for uses of that path. It should lead you to what you can use in grit.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top