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


Golang github.Bool函數代碼示例

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


在下文中一共展示了Bool函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: create

func create(desc string, pub bool, files map[string]string) (*github.Gist, error) {

	ghat := getAccessToken()

	ts := oauth2.StaticTokenSource(
		&oauth2.Token{AccessToken: ghat},
	)
	tc := oauth2.NewClient(oauth2.NoContext, ts)

	client := github.NewClient(tc)

	f := make(map[github.GistFilename]github.GistFile)

	for k := range files {
		_k := github.GistFilename(k)
		f[_k] = github.GistFile{Content: github.String(files[k])}
	}

	gist := &github.Gist{
		Description: github.String(desc),
		Public:      github.Bool(pub),
		Files:       f,
	}

	gist, _, err := client.Gists.Create(gist)

	return gist, err
}
開發者ID:chanux,項目名稱:gogist,代碼行數:28,代碼來源:main.go

示例2: newDraftRepositoryRelease

func newDraftRepositoryRelease(id int, version string) github.RepositoryRelease {
	return github.RepositoryRelease{
		TagName: github.String(version),
		Draft:   github.Bool(true),
		ID:      github.Int(id),
	}
}
開發者ID:zachgersh,項目名稱:github-release-resource,代碼行數:7,代碼來源:resource_suite_test.go

示例3: TestGitHubClient_Upload

func TestGitHubClient_Upload(t *testing.T) {
	client := testGithubClient(t)
	testTag := "github-client-upload-asset"
	req := &github.RepositoryRelease{
		TagName: github.String(testTag),
		Draft:   github.Bool(true),
	}

	release, err := client.CreateRelease(context.TODO(), req)
	if err != nil {
		t.Fatal("CreateRelease failed:", err)
	}

	defer func() {
		if err := client.DeleteRelease(context.TODO(), *release.ID); err != nil {
			t.Fatalf("DeleteRelease failed: %s", err)
		}
	}()

	filename := filepath.Join("./testdata", "darwin_386")
	asset, err := client.UploadAsset(context.TODO(), *release.ID, filename)
	if err != nil {
		t.Fatal("UploadAsset failed:", err)
	}

	githubClient, ok := client.(*GitHubClient)
	if !ok {
		t.Fatal("Faield to asset to GithubClient")
	}

	rc, url, err := githubClient.Repositories.DownloadReleaseAsset(
		githubClient.Owner, githubClient.Repo, *asset.ID)
	if err != nil {
		t.Fatal("DownloadReleaseAsset failed:", err)
	}

	var buf bytes.Buffer
	if len(url) != 0 {
		res, err := http.Get(url)
		if err != nil {
			t.Fatal("http.Get failed:", err)
		}

		if _, err := io.Copy(&buf, res.Body); err != nil {
			t.Fatal("Copy failed:", err)
		}
		res.Body.Close()

	} else {
		if _, err := io.Copy(&buf, rc); err != nil {
			t.Fatal("Copy failed:", err)
		}
		rc.Close()

	}

	if got, want := buf.String(), "darwin_386\n"; got != want {
		t.Fatalf("file body is %q, want %q", got, want)
	}
}
開發者ID:tchssk,項目名稱:ghr,代碼行數:60,代碼來源:github_test.go

示例4: TestGHR_UploadAssets

func TestGHR_UploadAssets(t *testing.T) {
	githubClient := testGithubClient(t)
	GHR := &GHR{
		GitHub:    githubClient,
		outStream: ioutil.Discard,
	}

	testTag := "ghr-upload-assets"
	req := &github.RepositoryRelease{
		TagName: github.String(testTag),
		Draft:   github.Bool(true),
	}

	// Create an existing release before
	release, err := githubClient.CreateRelease(context.TODO(), req)
	if err != nil {
		t.Fatalf("CreateRelease failed: %s", err)
	}

	defer func() {
		if err := githubClient.DeleteRelease(context.TODO(), *release.ID); err != nil {
			t.Fatal("DeleteRelease failed:", err)
		}
	}()

	localTestAssets, err := LocalAssets(TestDir)
	if err != nil {
		t.Fatal("LocalAssets failed:", err)
	}

	if err := GHR.UploadAssets(context.TODO(), *release.ID, localTestAssets, 4); err != nil {
		t.Fatal("GHR.UploadAssets failed:", err)
	}

	assets, err := githubClient.ListAssets(context.TODO(), *release.ID)
	if err != nil {
		t.Fatal("ListAssets failed:", err)
	}

	if got, want := len(assets), 4; got != want {
		t.Fatalf("upload assets number = %d, want %d", got, want)
	}

	// Delete all assets
	parallel := 4
	if err := GHR.DeleteAssets(context.TODO(), *release.ID, localTestAssets, parallel); err != nil {
		t.Fatal("GHR.DeleteAssets failed:", err)
	}

	assets, err = githubClient.ListAssets(context.TODO(), *release.ID)
	if err != nil {
		t.Fatal("ListAssets failed:", err)
	}

	if got, want := len(assets), 0; got != want {
		t.Fatalf("upload assets number = %d, want %d", got, want)
	}
}
開發者ID:tchssk,項目名稱:ghr,代碼行數:58,代碼來源:ghr_test.go

示例5: TestActivity_Watching

func TestActivity_Watching(t *testing.T) {
	watchers, _, err := client.Activity.ListWatchers("google", "go-github", nil)
	if err != nil {
		t.Fatalf("Activity.ListWatchers returned error: %v", err)
	}

	if len(watchers) == 0 {
		t.Errorf("Activity.ListWatchers('google', 'go-github') returned no watchers")
	}

	// the rest of the tests requires auth
	if !checkAuth("TestActivity_Watching") {
		return
	}

	// first, check if already watching google/go-github
	sub, _, err := client.Activity.GetRepositorySubscription("google", "go-github")
	if err != nil {
		t.Fatalf("Activity.GetRepositorySubscription returned error: %v", err)
	}
	if sub != nil {
		t.Fatalf("Already watching google/go-github.  Please manually stop watching it first.")
	}

	// watch google/go-github
	sub = &github.Subscription{Subscribed: github.Bool(true)}
	_, _, err = client.Activity.SetRepositorySubscription("google", "go-github", sub)
	if err != nil {
		t.Fatalf("Activity.SetRepositorySubscription returned error: %v", err)
	}

	// check again and verify watching
	sub, _, err = client.Activity.GetRepositorySubscription("google", "go-github")
	if err != nil {
		t.Fatalf("Activity.GetRepositorySubscription returned error: %v", err)
	}
	if sub == nil || !*sub.Subscribed {
		t.Fatalf("Not watching google/go-github after setting subscription.")
	}

	// delete subscription
	_, err = client.Activity.DeleteRepositorySubscription("google", "go-github")
	if err != nil {
		t.Fatalf("Activity.DeleteRepositorySubscription returned error: %v", err)
	}

	// check again and verify not watching
	sub, _, err = client.Activity.GetRepositorySubscription("google", "go-github")
	if err != nil {
		t.Fatalf("Activity.GetRepositorySubscription returned error: %v", err)
	}
	if sub != nil {
		t.Fatalf("Still watching google/go-github after deleting subscription.")
	}
}
開發者ID:MustWin,項目名稱:go-github,代碼行數:55,代碼來源:activity_test.go

示例6: CreateRepo

// CreateRepo will create a new repository in the organization on github.
//
// TODO: When the hook option is activated, it can only create a push hook.
// Extend this to include a optional event hook.
func (o *Organization) CreateRepo(opt RepositoryOptions) (err error) {
	err = o.connectAdminToGithub()
	if err != nil {
		return
	}

	if opt.Name == "" {
		return errors.New("Missing required name field. ")
	}

	repo := &github.Repository{}
	repo.Name = github.String(opt.Name)
	repo.Private = github.Bool(opt.Private)
	repo.AutoInit = github.Bool(opt.AutoInit)
	repo.HasIssues = github.Bool(opt.Issues)
	if opt.TeamID != 0 {
		repo.TeamID = github.Int(opt.TeamID)
	}

	_, _, err = o.githubadmin.Repositories.Create(o.Name, repo)
	if err != nil {
		return
	}

	if opt.Hook != "" {
		config := make(map[string]interface{})
		config["url"] = global.Hostname + "/event/hook"
		config["content_type"] = "json"

		hook := github.Hook{
			Name:   github.String("web"),
			Config: config,
			Events: []string{
				opt.Hook,
			},
		}

		_, _, err = o.githubadmin.Repositories.CreateHook(o.Name, opt.Name, &hook)
	}
	return
}
開發者ID:tokams,項目名稱:autograder,代碼行數:45,代碼來源:organisation.go

示例7: NewHook

// NewHook returns a new github.Hook instance that represents the appropriate
// configuration for the Conveyor webhook.
func NewHook(url, secret string) *github.Hook {
	return &github.Hook{
		Events: []string{"push"},
		Active: github.Bool(true),
		Name:   github.String("web"),
		Config: map[string]interface{}{
			"url":          url,
			"content_type": "json",
			"secret":       secret,
		},
	}
}
開發者ID:emmetog,項目名稱:conveyor,代碼行數:14,代碼來源:enable.go

示例8: TestRepositories_EditBranches

func TestRepositories_EditBranches(t *testing.T) {
	if !checkAuth("TestRepositories_EditBranches") {
		return
	}

	// get authenticated user
	me, _, err := client.Users.Get("")
	if err != nil {
		t.Fatalf("Users.Get('') returned error: %v", err)
	}

	repo, err := createRandomTestRepository(*me.Login, true)
	if err != nil {
		t.Fatalf("createRandomTestRepository returned error: %v", err)
	}

	branch, _, err := client.Repositories.GetBranch(*repo.Owner.Login, *repo.Name, "master")
	if err != nil {
		t.Fatalf("Repositories.GetBranch() returned error: %v", err)
	}

	if *branch.Protection.Enabled {
		t.Fatalf("Branch %v of repo %v is already protected", "master", *repo.Name)
	}

	branch.Protection.Enabled = github.Bool(true)
	branch.Protection.RequiredStatusChecks = &github.RequiredStatusChecks{
		EnforcementLevel: github.String("everyone"),
		Contexts:         &[]string{"continous-integration"},
	}
	branch, _, err = client.Repositories.EditBranch(*repo.Owner.Login, *repo.Name, "master", branch)
	if err != nil {
		t.Fatalf("Repositories.EditBranch() returned error: %v", err)
	}

	if !*branch.Protection.Enabled {
		t.Fatalf("Branch %v of repo %v should be protected, but is not!", "master", *repo.Name)
	}
	if *branch.Protection.RequiredStatusChecks.EnforcementLevel != "everyone" {
		t.Fatalf("RequiredStatusChecks should be enabled for everyone, set for: %v", *branch.Protection.RequiredStatusChecks.EnforcementLevel)
	}

	wantedContexts := []string{"continous-integration"}
	if !reflect.DeepEqual(*branch.Protection.RequiredStatusChecks.Contexts, wantedContexts) {
		t.Fatalf("RequiredStatusChecks.Contexts should be: %v but is: %v", wantedContexts, *branch.Protection.RequiredStatusChecks.Contexts)
	}

	_, err = client.Repositories.Delete(*repo.Owner.Login, *repo.Name)
	if err != nil {
		t.Fatalf("Repositories.Delete() returned error: %v", err)
	}
}
開發者ID:rawlingsj,項目名稱:gofabric8,代碼行數:52,代碼來源:repos_test.go

示例9: TestGitHubClient_ListAssets

func TestGitHubClient_ListAssets(t *testing.T) {
	client := testGithubClient(t)
	testTag := "github-list-assets"
	req := &github.RepositoryRelease{
		TagName: github.String(testTag),
		Draft:   github.Bool(true),
	}

	release, err := client.CreateRelease(context.TODO(), req)
	if err != nil {
		t.Fatal("CreateRelease failed:", err)
	}

	defer func() {
		if err := client.DeleteRelease(context.TODO(), *release.ID); err != nil {
			t.Fatalf("DeleteRelease failed: %s", err)
		}
	}()

	for _, filename := range []string{"darwin_386", "darwin_amd64"} {
		filename := filepath.Join("./testdata", filename)
		if _, err := client.UploadAsset(context.TODO(), *release.ID, filename); err != nil {
			t.Fatal("UploadAsset failed:", err)
		}
	}

	assets, err := client.ListAssets(context.TODO(), *release.ID)
	if err != nil {
		t.Fatal("ListAssets failed:", err)
	}

	if got, want := len(assets), 2; got != want {
		t.Fatalf("ListAssets number = %d, want %d", got, want)
	}

	if err := client.DeleteAsset(context.TODO(), *assets[0].ID); err != nil {
		t.Fatal("DeleteAsset failed:", err)
	}

	assets, err = client.ListAssets(context.TODO(), *release.ID)
	if err != nil {
		t.Fatal("ListAssets failed:", err)
	}

	if got, want := len(assets), 1; got != want {
		t.Fatalf("ListAssets number = %d, want %d", got, want)
	}
}
開發者ID:tchssk,項目名稱:ghr,代碼行數:48,代碼來源:github_test.go

示例10: createRepo

// create a new private repository named name for the given team
func createRepo(name string, team int) {
	repo := &github.Repository{
		Name:    github.String(name),
		Private: github.Bool(false), // TODO Update once github has given me private repos
	}
	r, _, err := client.Repositories.Create(courseOrg, repo)
	if err != nil {
		fmt.Printf("Failed to create repo: %s: %v\n", name, err)
		return
	}
	fmt.Printf("Created repository: %s for team %d;\n  URL: %s\n", name, team, *r.URL)
	_, err = client.Organizations.AddTeamRepo(team, courseOrg, name)
	if err != nil {
		fmt.Printf("Failed to add team %d to repo: %s: %v\n", team, name, err)
	}
	fmt.Println("Added team to repository:", name)
}
開發者ID:uis-dat320-fall2014,項目名稱:course-info,代碼行數:18,代碼來源:addteams.go

示例11: Create

// Create will create a Gist(https://gist.github.com/)
//
// If gist was created http.Response.StatusCode will be
// http.StatusCreated.(201)
func Create(githubToken string, gistParam CreateParams) (string, *http.Response, error) {

	client := connectGithub(githubToken)

	gf := &github.GistFile{
		Filename: github.String(gistParam.FileName),
		Content:  github.String(gistParam.Content),
	}

	gist := &github.Gist{
		Description: github.String(gistParam.Description),
		Public:      github.Bool(gistParam.Public),
		Files:       map[github.GistFilename]github.GistFile{"": *gf},
	}

	gst, resp, err := client.Gists.Create(gist)

	return *gst.HTMLURL, resp.Response, err
}
開發者ID:0x7cc,項目名稱:x16,代碼行數:23,代碼來源:gist.go

示例12: CreateDeployment

func (b *GithubBackend) CreateDeployment(ref string, env string) error {
	client := b.getClient()
	user, repo := b.parseGithubInfo()

	status_req := github.DeploymentRequest{
		Ref:         &ref,
		Task:        github.String("deploy"),
		AutoMerge:   github.Bool(false),
		Environment: &env,
	}

	_, _, err := client.Repositories.CreateDeployment(user, repo, &status_req)

	if err != nil {
		return err
	}

	return nil
}
開發者ID:ryanlfoster,項目名稱:shipper,代碼行數:19,代碼來源:github.go

示例13: TestGHR_CreateRelease

func TestGHR_CreateRelease(t *testing.T) {
	t.Parallel()

	githubClient := testGithubClient(t)
	GHR := &GHR{
		GitHub:    githubClient,
		outStream: ioutil.Discard,
	}

	testTag := "create-release"
	req := &github.RepositoryRelease{
		TagName: &testTag,
		Draft:   github.Bool(false),
	}

	recreate := false
	release, err := GHR.CreateRelease(context.TODO(), req, recreate)
	if err != nil {
		t.Fatal("CreateRelease failed:", err)
	}

	defer GHR.DeleteRelease(context.TODO(), *release.ID, testTag)
}
開發者ID:tchssk,項目名稱:ghr,代碼行數:23,代碼來源:ghr_test.go

示例14: CreateRepo

// CreateRepo creates a repository in the github user account
func (repo GithubRepository) CreateRepo(username, reponame, org string, private bool) (*domain.Repository, error) {
	rp := &github.Repository{
		Name:    github.String(reponame),
		Private: github.Bool(private),
	}
	rp, _, err := repo.client.Repositories.Create(org, rp)

	if err != nil {
		return nil, err
	}

	r := &domain.Repository{
		Name:        rp.Name,
		FullName:    rp.FullName,
		Description: rp.Description,
		Private:     rp.Private,
		HTMLURL:     rp.HTMLURL,
		CloneURL:    rp.CloneURL,
		SSHURL:      rp.SSHURL,
	}

	return r, nil
}
開發者ID:Tinker-Ware,項目名稱:gh-service,代碼行數:24,代碼來源:github.go

示例15:

						On("Get", repositoryOwner, repositoryName, issueNumber).
						Return(nil, nil, errors.New("an error"))
				})

				It("fails with a gateway error", func() {
					handle()
					Expect(responseRecorder.Code).To(Equal(http.StatusBadGateway))
				})
			})

			Context("with the PR being already merged", func() {
				BeforeEach(func() {
					pullRequests.
						On("Get", repositoryOwner, repositoryName, issueNumber).
						Return(&github.PullRequest{
							Merged: github.Bool(true),
						}, nil, nil)
				})

				It("removes the 'merging' label from the PR", func() {
					issues.
						On("RemoveLabelForIssue", repositoryOwner, repositoryName, issueNumber, grh.MergingLabel).
						Return(nil, nil, nil)

					handle()
					Expect(responseRecorder.Code).To(Equal(http.StatusOK))
				})
			})

			Context("with the PR not being mergeable", func() {
				BeforeEach(func() {
開發者ID:salemove,項目名稱:github-review-helper,代碼行數:31,代碼來源:merge_command_test.go


注:本文中的github.com/google/go-github/github.Bool函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。