|
1 | 1 | package pipeline
|
2 | 2 |
|
3 | 3 | import (
|
| 4 | + "path/filepath" |
4 | 5 | "strings"
|
5 | 6 | "sync"
|
6 | 7 |
|
@@ -113,39 +114,40 @@ func updateAllCurrentPipelines() {
|
113 | 114 | var allPipelines []gaia.Pipeline
|
114 | 115 | var wg sync.WaitGroup
|
115 | 116 | sem := make(chan int, 4)
|
116 |
| - |
117 | 117 | for pipeline := range GlobalActivePipelines.Iter() {
|
118 | 118 | allPipelines = append(allPipelines, pipeline)
|
119 | 119 | }
|
120 |
| - |
| 120 | + goPath := filepath.Join(gaia.Cfg.HomePath, tmpFolder, golangFolder) |
121 | 121 | for _, p := range allPipelines {
|
122 | 122 | wg.Add(1)
|
123 | 123 | go func(pipe gaia.Pipeline) {
|
124 | 124 | defer wg.Done()
|
125 | 125 | sem <- 1
|
126 |
| - r, err := git.PlainOpen(pipe.Repo.LocalDest) |
| 126 | + cloneFolder := filepath.Join(goPath, srcFolder, pipe.UUID) |
| 127 | + r, err := git.PlainOpen(cloneFolder) |
127 | 128 | if err != nil {
|
128 | 129 | // ignore for now
|
129 | 130 | return
|
130 | 131 | }
|
131 | 132 | beforPull, _ := r.Head()
|
| 133 | + gaia.Cfg.Logger.Debug("selected branch : ", pipe.Repo.SelectedBranch) |
132 | 134 | tree, _ := r.Worktree()
|
133 | 135 | err = tree.Pull(&git.PullOptions{
|
134 | 136 | RemoteName: "origin",
|
135 | 137 | })
|
136 | 138 | if err != nil {
|
137 |
| - gaia.Cfg.Logger.Error("error2 : ", err.Error()) |
138 |
| - err = nil |
| 139 | + gaia.Cfg.Logger.Error("error while doing a pull request : ", err.Error()) |
| 140 | + <-sem |
| 141 | + return |
139 | 142 | }
|
140 | 143 | afterPull, _ := r.Head()
|
141 | 144 | gaia.Cfg.Logger.Debug("no need to update pipeline: ", pipe.Name)
|
142 |
| - // if there are no changes... |
143 | 145 | if beforPull.Hash() == afterPull.Hash() {
|
144 | 146 | <-sem
|
145 | 147 | return
|
146 | 148 | }
|
| 149 | + |
147 | 150 | gaia.Cfg.Logger.Debug("updating pipeline: ", pipe.Name)
|
148 |
| - // otherwise build the pipeline |
149 | 151 | b := newBuildPipeline(pipe.Type)
|
150 | 152 | createPipeline := &gaia.CreatePipeline{}
|
151 | 153 | createPipeline.Pipeline = pipe
|
|
0 commit comments