Skip to content

Commit b48ee18

Browse files
authored
Merge pull request #83 from picostack/staging
v1.4.5
2 parents 3dee36d + 3747de5 commit b48ee18

File tree

5 files changed

+32
-8
lines changed

5 files changed

+32
-8
lines changed

config/config.go

+2
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ function A(a) {
108108
if(a.pass_key === undefined) { throw "auth pass_key undefined"; }
109109
110110
STATE.auths.push(a);
111+
112+
return a.name;
111113
}
112114
`)
113115

config/config_test.go

+19
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,25 @@ func Test_applyFileTargets(t *testing.T) {
4242
{Name: "2", RepoURL: "https://github.com/Southclaws/project2", Up: []string{"sleep"}, Env: map[string]string{}},
4343
{Name: "3", RepoURL: "https://github.com/Southclaws/project3", Up: []string{"sleep"}, Env: map[string]string{}},
4444
}, false},
45+
{"auth", `
46+
var auther = A({
47+
name: "auth",
48+
path: "path",
49+
user_key: "user_key",
50+
pass_key: "pass_key"
51+
});
52+
53+
T({
54+
name: "name",
55+
url: "../test.local",
56+
up: ["echo", "hello world"],
57+
auth: auther,
58+
});
59+
60+
console.log("done!");
61+
`, task.Targets{
62+
{Name: "name", RepoURL: "../test.local", Up: []string{"echo", "hello world"}, Env: map[string]string{}, Auth: "auth"},
63+
}, false},
4564
{"envmap", `
4665
var url = "https://github.com/Southclaws/";
4766

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/picostack/pico
33
go 1.13
44

55
require (
6-
github.com/Southclaws/gitwatch v1.3.3
6+
github.com/Southclaws/gitwatch v1.4.2
77
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
88
github.com/eapache/go-resiliency v1.2.0
99
github.com/frankban/quicktest v1.4.1 // indirect

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ github.com/Southclaws/gitwatch v1.3.2 h1:zmt571n8ItXgkRJPyCFtFjcymvsFOGcm7JnHNpF
1111
github.com/Southclaws/gitwatch v1.3.2/go.mod h1:xCudUiwWxkDYZ69cEhlTwAKIzbG1OpnA/s/pjPIW6gU=
1212
github.com/Southclaws/gitwatch v1.3.3 h1:w5AI9IcMEVqb6cPyDjM9tvOI4r26m4UHAl5BVEvgKac=
1313
github.com/Southclaws/gitwatch v1.3.3/go.mod h1:xCudUiwWxkDYZ69cEhlTwAKIzbG1OpnA/s/pjPIW6gU=
14+
github.com/Southclaws/gitwatch v1.4.2 h1:7HrA4sGCV+a1LHxiBf5vOO06CMKb6cYiVaATPoz17JU=
15+
github.com/Southclaws/gitwatch v1.4.2/go.mod h1:xCudUiwWxkDYZ69cEhlTwAKIzbG1OpnA/s/pjPIW6gU=
1416
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs=
1517
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs=
1618
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA=

watcher/git.go

+8-7
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ func (w *GitWatcher) __waitpoint__watch_targets(errs chan error) (err error) {
220220
}
221221

222222
func (w *GitWatcher) handle(e gitwatch.Event) (err error) {
223-
target, exists := w.getTarget(e.URL)
223+
target, exists := w.getTarget(e.Path)
224224
if !exists {
225225
return errors.Errorf("attempt to handle event for unknown target %s at %s", e.URL, e.Path)
226226
}
@@ -233,10 +233,10 @@ func (w *GitWatcher) handle(e gitwatch.Event) (err error) {
233233
}
234234

235235
func getTargetPath(t task.Target) string {
236-
if t.Branch != "" {
237-
return fmt.Sprintf("%s_%s", t.Name, t.Branch)
238-
}
239-
return t.Name
236+
if t.Branch != "" {
237+
return fmt.Sprintf("%s_%s", t.Name, t.Branch)
238+
}
239+
return t.Name
240240
}
241241

242242
func (w GitWatcher) getAuthForTarget(t task.Target) (transport.AuthMethod, error) {
@@ -274,9 +274,10 @@ func (w GitWatcher) executeTargets(targets []task.Target, shutdown bool) {
274274
}
275275
}
276276

277-
func (w GitWatcher) getTarget(url string) (target task.Target, exists bool) {
277+
func (w GitWatcher) getTarget(path string) (target task.Target, exists bool) {
278278
for _, t := range w.state.Targets {
279-
if t.RepoURL == url {
279+
targetPath := filepath.Join(w.directory, getTargetPath(t))
280+
if targetPath == path {
280281
return t, true
281282
}
282283
}

0 commit comments

Comments
 (0)