"Fossies" - the Fresh Open Source Software Archive  

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

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

create.go  (gh-cli-1.12.1):create.go  (gh-cli-1.13.1)
skipping to change at line 224 skipping to change at line 224
httpClient, err := opts.HttpClient() httpClient, err := opts.HttpClient()
if err != nil { if err != nil {
return err return err
} }
host, err := cfg.DefaultHost() host, err := cfg.DefaultHost()
if err != nil { if err != nil {
return err return err
} }
// GitIgnore and License templates not added when a template repo // GitIgnore and License templates not added when a template repo
sitory is passed. sitory
if gitIgnoreTemplate == "" && opts.Template == "" && opts.IO.CanP // is passed, or when the confirm flag is set.
rompt() { if opts.Template == "" && opts.IO.CanPrompt() && !opts.ConfirmSub
gt, err := interactiveGitIgnore(api.NewClientFromHTTP(htt mit {
pClient), host) if gitIgnoreTemplate == "" {
if err != nil { gt, err := interactiveGitIgnore(api.NewClientFrom
return err HTTP(httpClient), host)
if err != nil {
return err
}
gitIgnoreTemplate = gt
} }
gitIgnoreTemplate = gt if repoLicenseTemplate == "" {
} lt, err := interactiveLicense(api.NewClientFromHT
TP(httpClient), host)
if repoLicenseTemplate == "" && opts.Template == "" && opts.IO.Ca if err != nil {
nPrompt() { return err
lt, err := interactiveLicense(api.NewClientFromHTTP(httpC }
lient), host) repoLicenseTemplate = lt
if err != nil {
return err
} }
repoLicenseTemplate = lt
} }
} }
var repoToCreate ghrepo.Interface var repoToCreate ghrepo.Interface
if strings.Contains(opts.Name, "/") { if strings.Contains(opts.Name, "/") {
var err error var err error
repoToCreate, err = ghrepo.FromFullName(opts.Name) repoToCreate, err = ghrepo.FromFullName(opts.Name)
if err != nil { if err != nil {
return fmt.Errorf("argument error: %w", err) return fmt.Errorf("argument error: %w", err)
} }
} else { } else {
host, err := cfg.DefaultHost() host, err := cfg.DefaultHost()
if err != nil { if err != nil {
return err return err
} }
repoToCreate = ghrepo.NewWithHost("", opts.Name, host) repoToCreate = ghrepo.NewWithHost("", opts.Name, host)
} }
input := repoCreateInput{
Name: repoToCreate.RepoName(),
Visibility: visibility,
OwnerLogin: repoToCreate.RepoOwner(),
TeamSlug: opts.Team,
Description: opts.Description,
HomepageURL: opts.Homepage,
HasIssuesEnabled: opts.EnableIssues,
HasWikiEnabled: opts.EnableWiki,
GitIgnoreTemplate: gitIgnoreTemplate,
LicenseTemplate: repoLicenseTemplate,
}
httpClient, err := opts.HttpClient()
if err != nil {
return err
}
var templateRepoMainBranch string var templateRepoMainBranch string
// Find template repo ID
if opts.Template != "" { if opts.Template != "" {
httpClient, err := opts.HttpClient() var templateRepo ghrepo.Interface
if err != nil {
return err
}
var toClone ghrepo.Interface
apiClient := api.NewClientFromHTTP(httpClient) apiClient := api.NewClientFromHTTP(httpClient)
cloneURL := opts.Template templateRepoName := opts.Template
if !strings.Contains(cloneURL, "/") { if !strings.Contains(templateRepoName, "/") {
currentUser, err := api.CurrentLoginName(apiClient, ghins tance.Default()) currentUser, err := api.CurrentLoginName(apiClient, ghins tance.Default())
if err != nil { if err != nil {
return err return err
} }
cloneURL = currentUser + "/" + cloneURL templateRepoName = currentUser + "/" + templateRepoName
} }
toClone, err = ghrepo.FromFullName(cloneURL) templateRepo, err = ghrepo.FromFullName(templateRepoName)
if err != nil { if err != nil {
return fmt.Errorf("argument error: %w", err) return fmt.Errorf("argument error: %w", err)
} }
repo, err := api.GitHubRepo(apiClient, toClone) repo, err := api.GitHubRepo(apiClient, templateRepo)
if err != nil { if err != nil {
return err return err
} }
opts.Template = repo.ID input.TemplateRepositoryID = repo.ID
templateRepoMainBranch = repo.DefaultBranchRef.Name templateRepoMainBranch = repo.DefaultBranchRef.Name
} }
input := repoCreateInput{
Name: repoToCreate.RepoName(),
Visibility: visibility,
OwnerID: repoToCreate.RepoOwner(),
TeamID: opts.Team,
Description: opts.Description,
HomepageURL: opts.Homepage,
HasIssuesEnabled: opts.EnableIssues,
HasWikiEnabled: opts.EnableWiki,
GitIgnoreTemplate: gitIgnoreTemplate,
LicenseTemplate: repoLicenseTemplate,
}
httpClient, err := opts.HttpClient()
if err != nil {
return err
}
createLocalDirectory := opts.ConfirmSubmit createLocalDirectory := opts.ConfirmSubmit
if !opts.ConfirmSubmit { if !opts.ConfirmSubmit {
opts.ConfirmSubmit, err = confirmSubmission(input.Name, input.Own erID, inLocalRepo) opts.ConfirmSubmit, err = confirmSubmission(input.Name, input.Own erLogin, inLocalRepo)
if err != nil { if err != nil {
return err return err
} }
} }
if opts.ConfirmSubmit { if opts.ConfirmSubmit {
repo, err := repoCreate(httpClient, repoToCreate.RepoHost(), inpu t, opts.Template) repo, err := repoCreate(httpClient, repoToCreate.RepoHost(), inpu t)
if err != nil { if err != nil {
return err return err
} }
stderr := opts.IO.ErrOut stderr := opts.IO.ErrOut
stdout := opts.IO.Out stdout := opts.IO.Out
cs := opts.IO.ColorScheme() cs := opts.IO.ColorScheme()
isTTY := opts.IO.IsStdoutTTY() isTTY := opts.IO.IsStdoutTTY()
if isTTY { if isTTY {
fmt.Fprintf(stderr, "%s Created repository %s on GitHub\n ", cs.SuccessIconWithColor(cs.Green), ghrepo.FullName(repo)) fmt.Fprintf(stderr, "%s Created repository %s on GitHub\n ", cs.SuccessIconWithColor(cs.Green), ghrepo.FullName(repo))
 End of changes. 14 change blocks. 
51 lines changed or deleted 46 lines changed or added

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