53 lines
1.1 KiB
Go
53 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/go-git/go-git"
|
|
)
|
|
|
|
func main() {
|
|
/*
|
|
// Filesystem abstraction based on memory
|
|
fs := memfs.New()
|
|
// Git objects storer based on memory
|
|
storer := memory.NewStorage()
|
|
*/
|
|
|
|
_, err := git.PlainClone("/tmp/foo", false, &git.CloneOptions{
|
|
URL: "https://github.com/go-git/go-git",
|
|
Progress: os.Stdout,
|
|
})
|
|
/*
|
|
// Clones the repository into the worktree (fs) and stores all the .git
|
|
// content into the storer
|
|
_, err := git.Clone(storer, fs, &git.CloneOptions{
|
|
URL: "https://github.com/git-fixtures/basic.git",
|
|
})
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
*/
|
|
|
|
/*
|
|
// Prints the content of the CHANGELOG file from the cloned repository
|
|
changelog, err := fs.Open("CHANGELOG")
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
io.Copy(os.Stdout, changelog)
|
|
*/
|
|
/*
|
|
// Clone the given repository to the given directory
|
|
Info("git clone https://github.com/go-git/go-git")
|
|
|
|
_, err := git.PlainClone("/tmp/foo", false, &git.CloneOptions{
|
|
URL: "https://github.com/go-git/go-git",
|
|
Progress: os.Stdout,
|
|
})
|
|
|
|
CheckIfError(err)
|
|
*/
|
|
}
|