Last active
November 16, 2018 00:17
-
-
Save tiborvass/bf14c3fcf090e9d2e9a7ff5d3330021a to your computer and use it in GitHub Desktop.
This file contains 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