aboutsummaryrefslogtreecommitdiffstats
path: root/submodule.go
blob: ea099f0e908922e19cde1014caa9f7c2ba734a7c (plain) (blame)
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
package git

import (
	"fmt"

	"srcd.works/go-git.v4/plumbing"
)

type Submodule struct {
	Name   string
	Branch string
	URL    string

	r *Repository
}

func (s *Submodule) Init() error {
	return s.r.clone(&CloneOptions{
		URL:           s.URL,
		ReferenceName: plumbing.ReferenceName(s.Branch),
	})
}

type Submodules []*Submodule

func (s Submodules) Init() error {
	for _, sub := range s {
		fmt.Println("clone", sub.URL)
		if err := sub.Init(); err != nil {
			fmt.Println(err)
			return err
		}
	}

	return nil
}