本文整理汇总了Golang中github.com/google/go-github/github.Hook类的典型用法代码示例。如果您正苦于以下问题:Golang Hook类的具体用法?Golang Hook怎么用?Golang Hook使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Hook类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: CreateHook
// CreateHook is a helper function that creates a post-commit hook
// for the specified repository.
func CreateHook(client *github.Client, owner, name, url string) (*github.Hook, error) {
var hook = new(github.Hook)
hook.Name = github.String("web")
hook.Events = []string{"issue_comment", "status", "pull_request"}
hook.Config = map[string]interface{}{}
hook.Config["url"] = url
hook.Config["content_type"] = "json"
created, _, err := client.Repositories.CreateHook(owner, name, hook)
return created, err
}
开发者ID:jonbodner,项目名称:lgtm,代码行数:12,代码来源:utils.go
示例2: runCreateCmd
func runCreateCmd(cmd *commander.Command, args []string) error {
if err := validateSubUsage(cmd, args); err != nil {
return err
}
c, err := Client()
if err != nil {
return err
}
hookSchema, _, err := GetHookSchema(c, args[2])
if err != nil {
return err
}
hook := new(github.Hook)
hook.Name = hookSchema.Name
active := true
hook.Active = &active
events := make([]string, 0)
for _, event := range hookSchema.Events {
events = append(events, event)
}
hook.Events = events
hook.Config = make(map[string]interface{})
newHook, err := edit(
hook,
hookSchema,
)
if err != nil {
return err
}
if _, _, err := c.Repositories.CreateHook(args[0], args[1], newHook); err != nil {
return err
}
return nil
}
开发者ID:soh335,项目名称:ghh,代码行数:42,代码来源:command.go
示例3: createHookFromToml
func createHookFromToml(reader io.Reader) (*github.Hook, error) {
tomlHook := new(TomlHook)
if _, err := toml.DecodeReader(reader, tomlHook); err != nil {
return nil, err
}
hook := new(github.Hook)
if tomlHook.Name != nil {
hook.Name = tomlHook.Name
}
if tomlHook.Active != nil {
hook.Active = tomlHook.Active
}
if tomlHook.Events != nil {
hook.Events = tomlHook.Events
}
if tomlHook.Config != nil {
hook.Config = tomlHook.Config
}
return hook, nil
}
开发者ID:soh335,项目名称:ghh,代码行数:22,代码来源:tomlhook.go
注:本文中的github.com/google/go-github/github.Hook类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论