示例#1
0
文件: validate.go 项目: geisbruch/cmt
func GetCommand(hostURL *url.URL) cmd.Cmd {
	if hostURL.Host != "" {
		rc := cmd.NewSSH(hostURL.User.Username(), hostURL.Host)
		if err := rc.UseAgent(); err != nil {
			log.Fatal("Unable to use SSH agent for host: ", hostURL.String())
		}
		return rc

	}

	return cmd.NewLocal()

}
示例#2
0
func TriggerHook(command string) error {
	if command == "" {
		return nil
	}

	log.Printf("Running hook: %s\n", command)

	args := strings.Fields(command)
	c := cmd.NewLocal()
	stdout, stderr, err := c.Run(args[0], args[1:]...)

	log.Println(stdout, stderr)

	return err
}