Skip to content

Commit

Permalink
Merge pull request #83 from picostack/staging
Browse files Browse the repository at this point in the history
v1.4.5
  • Loading branch information
Southclaws authored Aug 27, 2020
2 parents 3dee36d + 3747de5 commit b48ee18
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 8 deletions.
2 changes: 2 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ function A(a) {
if(a.pass_key === undefined) { throw "auth pass_key undefined"; }
STATE.auths.push(a);
return a.name;
}
`)

Expand Down
19 changes: 19 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/";
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
15 changes: 8 additions & 7 deletions watcher/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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) {
Expand Down Expand Up @@ -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
}
}
Expand Down

0 comments on commit b48ee18

Please sign in to comment.