Skip to content

Commit

Permalink
Merge pull request #74 from picostack/staging
Browse files Browse the repository at this point in the history
v1.4.4
  • Loading branch information
Southclaws committed Jul 27, 2020
2 parents 46a02cb + c3d5e60 commit 3dee36d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions watcher/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,7 @@ func (w *GitWatcher) GetState() config.State {
func (w *GitWatcher) watchTargets() (err error) {
targetRepos := make([]gitwatch.Repository, len(w.state.Targets))
for i, t := range w.state.Targets {
dir := t.Name
if t.Branch != "" {
dir = fmt.Sprintf("%s_%s", t.Name, t.Branch)
}
dir := getTargetPath(t)
auth, err := w.getAuthForTarget(t)
if err != nil {
return err
Expand Down Expand Up @@ -235,6 +232,13 @@ func (w *GitWatcher) handle(e gitwatch.Event) (err error) {
return nil
}

func getTargetPath(t task.Target) string {
if t.Branch != "" {
return fmt.Sprintf("%s_%s", t.Name, t.Branch)
}
return t.Name
}

func (w GitWatcher) getAuthForTarget(t task.Target) (transport.AuthMethod, error) {
for _, a := range w.state.AuthMethods {
if a.Name == t.Auth {
Expand Down Expand Up @@ -266,7 +270,7 @@ func (w GitWatcher) executeTargets(targets []task.Target, shutdown bool) {
zap.Int("targets", len(targets)))

for _, t := range targets {
w.__waitpoint__send_target_task(t, filepath.Join(w.directory, t.Name), shutdown)
w.__waitpoint__send_target_task(t, filepath.Join(w.directory, getTargetPath(t)), shutdown)
}
}

Expand Down

0 comments on commit 3dee36d

Please sign in to comment.