-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6042de9
commit 4354879
Showing
3 changed files
with
48 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package hooks | ||
|
||
import ( | ||
"os" | ||
"os/exec" | ||
"strings" | ||
|
||
"github.com/dropseed/deps/internal/output" | ||
"github.com/dropseed/deps/internal/pullrequest" | ||
) | ||
|
||
func RunPullrequestHook(pr pullrequest.PullrequestAdapter, hookName string) error { | ||
hookCmd := pr.GetSetting(hookName) | ||
|
||
if hookCmd == nil { | ||
return nil | ||
} | ||
|
||
output.Event("Executing %s hook", hookName) | ||
|
||
hookCmdLines := strings.Split(hookCmd.(string), "\n") | ||
|
||
for _, line := range hookCmdLines { | ||
cmd := exec.Command("sh", "-c", line) | ||
// specific env too? would be pr.Config.Env? | ||
cmd.Env = os.Environ() | ||
cmd.Stdout = os.Stdout | ||
cmd.Stderr = os.Stderr | ||
err := cmd.Run() | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters