-
-
Save roscopecoltran/493138ad2c302087ba2fada56f7f7f2c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
git "gopkg.in/src-d/go-git.v4" | |
"gopkg.in/src-d/go-git.v4/utils/ioutil" | |
) | |
func main() { | |
r, err := git.PlainOpen(".") | |
if err != nil { | |
panic(err) | |
} | |
cfg, err := r.Config() | |
if err != nil { | |
panic(err) | |
} | |
remote := cfg.Remotes["tibor"] | |
s, err := git.NewSendPackSession(remote.URL, nil) | |
if err != nil { | |
panic(err) | |
} | |
defer ioutil.CheckClose(s, &err) | |
ar, err := s.AdvertisedReferences() | |
if err != nil { | |
panic(err) | |
} | |
for name, hash := range ar.References { | |
if name == "refs/heads/master" { | |
fmt.Println(name, hash.String()) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment