"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "pkg/cmd/repo/create/http.go" between
gh-cli-1.11.0.tar.gz and gh-cli-1.12.0.tar.gz

About: GitHub CLI is GitHub’s official command line tool.

http.go  (gh-cli-1.11.0):http.go  (gh-cli-1.12.0)
package create package create
import ( import (
"bytes"
"encoding/json"
"fmt" "fmt"
"net/http" "net/http"
"github.com/cli/cli/api" "github.com/cli/cli/api"
) )
// repoCreateInput represents input parameters for repoCreate // repoCreateInput represents input parameters for repoCreate
type repoCreateInput struct { type repoCreateInput struct {
Name string `json:"name"` Name string `json:"name"`
Visibility string `json:"visibility"` Visibility string `json:"visibility"`
HomepageURL string `json:"homepageUrl,omitempty"` HomepageURL string `json:"homepageUrl,omitempty"`
Description string `json:"description,omitempty"` Description string `json:"description,omitempty"`
OwnerID string `json:"ownerId,omitempty"` OwnerID string `json:"ownerId,omitempty"`
TeamID string `json:"teamId,omitempty"` TeamID string `json:"teamId,omitempty"`
HasIssuesEnabled bool `json:"hasIssuesEnabled"` HasIssuesEnabled bool `json:"hasIssuesEnabled"`
HasWikiEnabled bool `json:"hasWikiEnabled"` HasWikiEnabled bool `json:"hasWikiEnabled"`
GitIgnoreTemplate string `json:"gitignore_template,omitempty"`
LicenseTemplate string `json:"license_template,omitempty"`
} }
type repoTemplateInput struct { type repoTemplateInput struct {
Name string `json:"name"` Name string `json:"name"`
Visibility string `json:"visibility"` Visibility string `json:"visibility"`
OwnerID string `json:"ownerId,omitempty"` OwnerID string `json:"ownerId,omitempty"`
RepositoryID string `json:"repositoryId,omitempty"` RepositoryID string `json:"repositoryId,omitempty"`
Description string `json:"description,omitempty"` Description string `json:"description,omitempty"`
} }
skipping to change at line 107 skipping to change at line 111
var response struct { var response struct {
CreateRepository struct { CreateRepository struct {
Repository api.Repository Repository api.Repository
} }
} }
variables := map[string]interface{}{ variables := map[string]interface{}{
"input": input, "input": input,
} }
if input.GitIgnoreTemplate != "" || input.LicenseTemplate != "" {
body := &bytes.Buffer{}
enc := json.NewEncoder(body)
if err := enc.Encode(input); err != nil {
return nil, err
}
repo, err := api.CreateRepoTransformToV4(apiClient, hostname, "PO
ST", "user/repos", body)
if err != nil {
return nil, err
}
return api.InitRepoHostname(repo, hostname), nil
}
err := apiClient.GraphQL(hostname, ` err := apiClient.GraphQL(hostname, `
mutation RepositoryCreate($input: CreateRepositoryInput!) { mutation RepositoryCreate($input: CreateRepositoryInput!) {
createRepository(input: $input) { createRepository(input: $input) {
repository { repository {
id id
name name
owner { login } owner { login }
url url
} }
} }
skipping to change at line 146 skipping to change at line 163
func resolveOrganizationTeam(client *api.Client, hostname, orgName, teamSlug str ing) (string, string, error) { func resolveOrganizationTeam(client *api.Client, hostname, orgName, teamSlug str ing) (string, string, error) {
var response struct { var response struct {
NodeID string `json:"node_id"` NodeID string `json:"node_id"`
Organization struct { Organization struct {
NodeID string `json:"node_id"` NodeID string `json:"node_id"`
} }
} }
err := client.REST(hostname, "GET", fmt.Sprintf("orgs/%s/teams/%s", orgNa me, teamSlug), nil, &response) err := client.REST(hostname, "GET", fmt.Sprintf("orgs/%s/teams/%s", orgNa me, teamSlug), nil, &response)
return response.Organization.NodeID, response.NodeID, err return response.Organization.NodeID, response.NodeID, err
} }
// ListGitIgnoreTemplates uses API v3 here because gitignore template isn't supp
orted by GraphQL yet.
func ListGitIgnoreTemplates(client *api.Client, hostname string) ([]string, erro
r) {
var gitIgnoreTemplates []string
err := client.REST(hostname, "GET", "gitignore/templates", nil, &gitIgnor
eTemplates)
if err != nil {
return []string{}, err
}
return gitIgnoreTemplates, nil
}
// ListLicenseTemplates uses API v3 here because license template isn't supporte
d by GraphQL yet.
func ListLicenseTemplates(client *api.Client, hostname string) ([]api.License, e
rror) {
var licenseTemplates []api.License
err := client.REST(hostname, "GET", "licenses", nil, &licenseTemplates)
if err != nil {
return nil, err
}
return licenseTemplates, nil
}
 End of changes. 4 change blocks. 
2 lines changed or deleted 20 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)