Git2go fetch deleted tags
I'm trying to fetch tags from remote using git2go ( https://github.com/libgit2/git2go ). When I clone the repository, I can list all the tags with the following code:
iter, err := repository.NewReferenceIterator()
ref, err := iter.Next()
for err == nil {
if ref.IsTag() {
fmt.Println(ref.Name())
}
ref, err = iter.Next()
}
But when I fetch the code from the remote it doesn't update the tags. I'm fetching new code from the repository with:
remote, err := p.repository.LoadRemote("origin")
remote.Fetch([]string{}, nil, "")
This is my config:
[core]
bare = false
repositoryformatversion = 0
filemode = true
logallrefupdates = true
[remote "origin"]
url = file:///home/testrepo
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
I added ( Can I specify in .git / config to fetch multiple refspecs? ):
fetch = refs/tags/*:refs/tags/*
But that doesn't do anything.
I also added tags to the refspec, but that gave an error: ref 'refs / remotes / origin / master' does not match destination
source to share
The Remote.Fetch () doc mentions:
use empty list to use refspecs from config.
default refspec does not import tags .
(Even with regular git, you'll need itgit fetch --tags
).
Default:
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
You can:
-
use a non-empty list of refspecs in the method
Fetch()
,[]string{"+refs/heads/*:refs/remotes/origin/*", "refs/tags/*:refs/tags/*"}
-
or it is possible to add multiple refspecs to the fetch config, though using (with git2go) the method .
(o *Remote) FetchRefspecs() ([]string, error)
gyre reports in the comments since this code works to the point:
to the point where I need the PEEL tag: Peel is where
git2go
it somehow returns errors that it can't clear with a link in the tag.
source to share