From c3d5e606f22c4d22996c775619375890caa75538 Mon Sep 17 00:00:00 2001 From: Barnaby Keene Date: Mon, 27 Jul 2020 12:23:23 +0100 Subject: [PATCH] fix #72 (#73) Fixes an issue where initialisation task execution did not use branch suffix paths whereas creation and git events did. --- watcher/git.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/watcher/git.go b/watcher/git.go index 7b0a139..8c5406d 100644 --- a/watcher/git.go +++ b/watcher/git.go @@ -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 @@ -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 { @@ -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) } }