當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Hook.Name方法代碼示例

本文整理匯總了Golang中github.com/google/go-github/github.Hook.Name方法的典型用法代碼示例。如果您正苦於以下問題:Golang Hook.Name方法的具體用法?Golang Hook.Name怎麽用?Golang Hook.Name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/google/go-github/github.Hook的用法示例。


在下文中一共展示了Hook.Name方法的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.Name方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。