fork of go-git with some jj specific features
at main 757 B view raw
1package main 2 3import ( 4 "fmt" 5 "os" 6 7 "github.com/go-git/go-billy/v5/memfs" 8 "github.com/go-git/go-git/v5" 9 . "github.com/go-git/go-git/v5/_examples" 10 "github.com/go-git/go-git/v5/storage/memory" 11) 12 13// Basic example of how to clone a repository using clone options. 14func main() { 15 CheckArgs("<url>") 16 url := os.Args[1] 17 18 // Clone the given repository to the given directory 19 Info("git clone %s", url) 20 21 wt := memfs.New() 22 storer := memory.NewStorage() 23 r, err := git.Clone(storer, wt, &git.CloneOptions{ 24 URL: url, 25 }) 26 27 CheckIfError(err) 28 29 // ... retrieving the branch being pointed by HEAD 30 ref, err := r.Head() 31 CheckIfError(err) 32 // ... retrieving the commit object 33 commit, err := r.CommitObject(ref.Hash()) 34 CheckIfError(err) 35 36 fmt.Println(commit) 37}