aboutsummaryrefslogtreecommitdiffstats
path: root/repository.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-02-14 19:26:32 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2017-02-15 09:30:05 +0100
commitd6a6decd1be0515faf36256ce06c58c7d662bbd0 (patch)
treeb91c4f618470c7cf1ef9547b9146d08e30df6204 /repository.go
parent09110d8e6d1ddb6f6a22867dcedeebd8f2262780 (diff)
downloadgo-git-d6a6decd1be0515faf36256ce06c58c7d662bbd0.tar.gz
submodule update implementation
Diffstat (limited to 'repository.go')
-rw-r--r--repository.go23
1 files changed, 18 insertions, 5 deletions
diff --git a/repository.go b/repository.go
index 4c184ab..9969b86 100644
--- a/repository.go
+++ b/repository.go
@@ -350,8 +350,8 @@ func (r *Repository) clone(o *CloneOptions) error {
return err
}
- if o.RecursiveSubmodules && r.wt != nil {
- if err := r.initSubmodules(); err != nil {
+ if o.RecurseSubmodules != NoRecursivity && r.wt != nil {
+ if err := r.updateSubmodules(o.RecurseSubmodules); err != nil {
return err
}
}
@@ -359,7 +359,7 @@ func (r *Repository) clone(o *CloneOptions) error {
return r.updateRemoteConfig(remote, o, c, head)
}
-func (r *Repository) initSubmodules() error {
+func (r *Repository) updateSubmodules(recursion SubmoduleRescursivity) error {
w, err := r.Worktree()
if err != nil {
return err
@@ -370,7 +370,10 @@ func (r *Repository) initSubmodules() error {
return err
}
- return s.Init()
+ return s.Update(&SubmoduleUpdateOptions{
+ Init: true,
+ RecurseSubmodules: recursion,
+ })
}
func (r *Repository) cloneRefSpec(o *CloneOptions,
@@ -546,7 +549,17 @@ func (r *Repository) Pull(o *PullOptions) error {
return NoErrAlreadyUpToDate
}
- return r.updateWorktree()
+ if err := r.updateWorktree(); err != nil {
+ return err
+ }
+
+ if o.RecurseSubmodules != NoRecursivity && r.wt != nil {
+ if err := r.updateSubmodules(o.RecurseSubmodules); err != nil {
+ return err
+ }
+ }
+
+ return nil
}
func (r *Repository) updateWorktree() error {