summaryrefslogtreecommitdiff
path: root/go-git/main.go
blob: 79d1b71984d8e8e502ae2bb845c8a0b980100724 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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)
	*/
}