diff --git a/config/config.go b/config/config.go index 30dd0c3..d2c524d 100644 --- a/config/config.go +++ b/config/config.go @@ -108,6 +108,8 @@ function A(a) { if(a.pass_key === undefined) { throw "auth pass_key undefined"; } STATE.auths.push(a); + + return a.name; } `) diff --git a/config/config_test.go b/config/config_test.go index 932d709..343b817 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -42,6 +42,25 @@ func Test_applyFileTargets(t *testing.T) { {Name: "2", RepoURL: "https://github.com/Southclaws/project2", Up: []string{"sleep"}, Env: map[string]string{}}, {Name: "3", RepoURL: "https://github.com/Southclaws/project3", Up: []string{"sleep"}, Env: map[string]string{}}, }, false}, + {"auth", ` + var auther = A({ + name: "auth", + path: "path", + user_key: "user_key", + pass_key: "pass_key" + }); + + T({ + name: "name", + url: "../test.local", + up: ["echo", "hello world"], + auth: auther, + }); + + console.log("done!"); + `, task.Targets{ + {Name: "name", RepoURL: "../test.local", Up: []string{"echo", "hello world"}, Env: map[string]string{}, Auth: "auth"}, + }, false}, {"envmap", ` var url = "https://github.com/Southclaws/"; diff --git a/go.mod b/go.mod index 14e6338..14dcc64 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/picostack/pico go 1.13 require ( - github.com/Southclaws/gitwatch v1.3.3 + github.com/Southclaws/gitwatch v1.4.2 github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect github.com/eapache/go-resiliency v1.2.0 github.com/frankban/quicktest v1.4.1 // indirect diff --git a/go.sum b/go.sum index be5e408..e588f84 100644 --- a/go.sum +++ b/go.sum @@ -11,6 +11,8 @@ github.com/Southclaws/gitwatch v1.3.2 h1:zmt571n8ItXgkRJPyCFtFjcymvsFOGcm7JnHNpF github.com/Southclaws/gitwatch v1.3.2/go.mod h1:xCudUiwWxkDYZ69cEhlTwAKIzbG1OpnA/s/pjPIW6gU= github.com/Southclaws/gitwatch v1.3.3 h1:w5AI9IcMEVqb6cPyDjM9tvOI4r26m4UHAl5BVEvgKac= github.com/Southclaws/gitwatch v1.3.3/go.mod h1:xCudUiwWxkDYZ69cEhlTwAKIzbG1OpnA/s/pjPIW6gU= +github.com/Southclaws/gitwatch v1.4.2 h1:7HrA4sGCV+a1LHxiBf5vOO06CMKb6cYiVaATPoz17JU= +github.com/Southclaws/gitwatch v1.4.2/go.mod h1:xCudUiwWxkDYZ69cEhlTwAKIzbG1OpnA/s/pjPIW6gU= github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs= github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA= diff --git a/watcher/git.go b/watcher/git.go index 8c5406d..e7072bc 100644 --- a/watcher/git.go +++ b/watcher/git.go @@ -220,7 +220,7 @@ func (w *GitWatcher) __waitpoint__watch_targets(errs chan error) (err error) { } func (w *GitWatcher) handle(e gitwatch.Event) (err error) { - target, exists := w.getTarget(e.URL) + target, exists := w.getTarget(e.Path) if !exists { return errors.Errorf("attempt to handle event for unknown target %s at %s", e.URL, e.Path) } @@ -233,10 +233,10 @@ func (w *GitWatcher) handle(e gitwatch.Event) (err error) { } func getTargetPath(t task.Target) string { - if t.Branch != "" { - return fmt.Sprintf("%s_%s", t.Name, t.Branch) - } - return t.Name + 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) { @@ -274,9 +274,10 @@ func (w GitWatcher) executeTargets(targets []task.Target, shutdown bool) { } } -func (w GitWatcher) getTarget(url string) (target task.Target, exists bool) { +func (w GitWatcher) getTarget(path string) (target task.Target, exists bool) { for _, t := range w.state.Targets { - if t.RepoURL == url { + targetPath := filepath.Join(w.directory, getTargetPath(t)) + if targetPath == path { return t, true } }