Commit graph

145 commits

Author SHA1 Message Date
Azeem Sajid
a1136bf5cd Add initial test 2025-03-09 12:19:16 +05:00
Azeem Sajid
cc3dd515a6 Show host name in repo creation prompts 2025-02-28 12:25:49 +05:00
Azeem Sajid
33c30d5bd1 Inconsistent format of examples in help text 2025-02-27 16:26:25 +05:00
nobe4
f1c3619003
Update pkg/cmd/repo/create/create.go
Co-authored-by: Kynan Ware <47394200+BagToad@users.noreply.github.com>
2025-01-02 17:11:59 +01:00
nobe4
9558d5b60b
docs(repo): make explicit which branch is used when creating a repo
This adds a line of documentation in the `gh repo create` command's help
specifying which branch for the new repo is selected.
2025-01-02 16:53:44 +01:00
William Martin
72a6fd00a4 Rename backwards compatible credentials pattern 2024-11-27 12:21:55 +01:00
William Martin
7affcadb5e Allow client push to use insecure credential pattern 2024-11-26 22:29:58 +01:00
William Martin
46922694dc Support secure credential pattern 2024-11-26 22:29:38 +01:00
William Martin
7bcb063391 Modify push prompt on repo create when bare 2024-11-11 16:17:06 +01:00
William Martin
8e63268aba Doc push behaviour for bare repo create 2024-11-11 16:10:32 +01:00
William Martin
e3665955a5 Push --mirror on bare repo create 2024-11-11 16:09:03 +01:00
William Martin
2efb9935db Doc isLocalRepo and git.Client IsLocalRepo differences 2024-11-11 14:18:26 +01:00
William Martin
f515e9c1e7 Use errWithExitCode interface in repo create isLocalRepo 2024-11-11 14:17:29 +01:00
William Martin
bc85e11d05 Backfill repo creation failure tests 2024-11-11 14:11:16 +01:00
William Martin
4a7f2e57b0 Support bare repo creation 2024-11-11 13:57:05 +01:00
bagtoad
f07f49810a Update help and fix heredoc indentation 2024-10-09 21:41:54 -06:00
bagtoad
4ecb125c7c Update function names
Licenses are no longer referred to as templates. Prefix the new license and gitignore functions with "Repo" as a more descriptive name.
2024-10-09 21:00:43 -06:00
bagtoad
c2a7756c01 Reverse repo/shared package name change 2024-10-09 20:49:29 -06:00
bagtoad
3be44fb6e2 Move API calls to queries_repo.go 2024-10-06 11:51:16 -06:00
bagtoad
038b57c866 implement gitignore list 2024-09-29 12:29:56 -06:00
bagtoad
21f0d9466e Divide shared repo package and add queries tests 2024-09-29 10:40:22 -06:00
bagtoad
fd8c4633e3 First pass at implementing gh repo license list 2024-09-23 12:30:02 -06:00
Andy Feller
24336f1344 Enhance gh repo create docs, fix random cmd link
Relates #8946

- updates the documentation within `gh repo create` to include links to lookup .gitignore templates and licenses
- fixes link markup within `gh auth setup-git` so link is formatted correctly on https://cli.github.com
2024-09-16 13:42:51 -04:00
Tyler McGoffin
91eb34011c
Remove Internal from gh repo create prompt when owner is not an org (#9465)
* Remove `Internal` from `gh repo create` prompt when owner is not an org

Closes #9464

Internal repos only exist for organizations, so when a user selects their
personal namespace to create a repo using `gh repo create`, `Internal`
should not be an option in the `Visibility` prompt.

This should avoid the additional quirk where if the user selects
`Internal` while creating a personal repo and then proceeds to add any
of the README, .gitignore, or LICENSE files prompted for later, the repo
will not error and instead get created as a `Public` repo. This has the
potential for a user to unknowingly leak sensitive info intended to go
into a non-public repo.

* Refactor prompter with test coverage

By extracting the repo visibility options to its own function,
getRepoVisibilityOptions, we're able to directly test the behavior
introduced with this change. This breaks the testing pattern established
here thus far, but may be a good example of the direction we should
explore for a future refactor.

* Add failing tests to check for error with internal vis in non-org repos

There is a bug in the code, currently, where a user repo can attempt to be
created as with `--internal` visibility flag  when that is not an option
for non-org repos. It fails at the API level if the --gitignore,
--license, or --add-readme flags are not included, but silently falls back
to Public visibility if one of them is included.

Because this bug already existed, this commit adds the tests to ensure
that both scenarios described above are captured accurately by the test
suite. A fix for the latter scenario will be coming in a future commit

* Add Exclude to httpmock registry and implement in Test_repoCreate

Upon attempting to make the previous commit pass, I realized that it was
actually impossible to test what I wanted to. The tests in the previous
commit were behaving as expected given the bug that commit described, but
upon attempting to implement a solution I realized that the tests were
only testing the mocks and not the code functionality itself.

Essentially, when the code to fix the bug was implemented, the tests were
failing because the mocks required to test the buggy behavior were no
longer being called. To make the tests pass, I'd have to rewrite them, but
were I to remove the bug fix, the tests would no longer fail.

This pointed me to a gap in our httpmocks - the ability to intentionally
exclude api calls. The behavior I'm trying to test, here, is that we stop
executing when a certain condition is met, and therefore won't make any
subsequent api calls down the chain.

This implements the Exclude method on the registry such that it will fail
if an excluded api pattern is called. I have refactored the tests in
Test_repoCreate to use the Exclude mock for testing.

* Add error if user attempts to create repo with --internal flag

This was previously failing at either the API if no other flags were
included or falling back to creating a public repo if one of gitignore,
license, or add-readme were included.

* Add testing for error messages in gh repo create

In the previous commits, we've introduced a new error when a user tries to
create an Internal repo not owned by an organization. This adds tests to
verify that the error we are getting is, in fact, the one associated with
this use case and not some random error.
2024-08-22 10:01:16 -07:00
Yukai Chou
d7b8ecf33d Unify use of tab indent in non-test source files
Found with
    rg '(^ | \t|\t )' -g '*.go' -g '!*_test.go'

Mixed indent exceptions:
- wrapped long list items with extra 2-space indent
- code snippets using space indent
- commented code lines having "\t*// \t+" prefix
2024-08-03 00:35:30 +08:00
Jesse Houwing
e0c03fc603
Remove redundant whitespace 2024-07-18 10:20:44 +02:00
Jesse Houwing
3b2ba9e1fa
docs: Update documentation for gh repo create to clarify owner 2024-07-12 13:20:43 +02:00
William Martin
07e0ff7127 Fix repo fork to use remote protocol if none configured 2024-05-10 10:48:36 +02:00
William Martin
1d38230675
Move config interfaces into gh package (#9060) 2024-05-10 10:39:36 +02:00
Victor Lee
b8c4ea1e7c
added URL for newly created repo (#8574) 2024-01-19 12:16:15 +01:00
Sam Coe
7924878315
Fix git protocol and refactor Config interface (#8246) 2023-10-27 15:42:05 +02:00
William Martin
6dc04bb1e2 Remove GetOrDefault uses in favour of GitProtocol 2023-10-19 12:57:19 +02:00
Arun Sathiya
9b037ffac1
update(repo create): Support for --homepage flag for template-based repository creation flow (#8188) 2023-10-17 09:01:32 +02:00
Jun Nishimura
7d6fba0d7d
Create repositories from templates in interactive mode (#7769) 2023-10-12 17:53:05 +02:00
Yuto
885ccd7424
Disable issue with template (#7918)
* allow --disable-issues option with --template

* add a test case for creating repo with --disable-issues --template
2023-10-11 10:35:40 +02:00
Yuto
f8bf602ecd
Allow --disable-wiki flag with --template flag in repo create command (#7886) 2023-08-29 22:52:57 +00:00
Shion Ichikawa
a5400effd8
🐛 (repo create)execute clone when readme option is enabled (#7837)
* 🐛 (repo create)execute clone when readme option is enabled

*  (repo/create)noninteractive clone with readme

* 🔥 (repo/create)remove printing statement
2023-08-28 14:09:02 +00:00
Sam Coe
fac497108b
Set upstream remote to track all branches after initial fetch (#7542) 2023-06-12 09:23:56 +09:00
vwkd
d349ba185a
fix empty default description for local repository (#7383) 2023-05-04 09:21:12 +12:00
Heath Stewart
d104926ce2
Resolve lint error 2023-03-29 08:18:05 -07:00
Heath Stewart
3085c39a73
Specify branch to force exit code 2023-03-29 07:44:17 -07:00
Heath Stewart
36436cb8b8
Retry fetching repo from template
Fixes #7055
2023-03-29 07:44:16 -07:00
Sam Coe
c9a2d85793
Cleanup config.AuthToken and config.DefaultHost methods (#7049) 2023-02-28 00:24:45 +00:00
Skip Baney
06360429de
Prompt for owner when interactively creating repos (#6578) 2022-12-08 08:52:36 +02:00
Sam Coe
98ab1f2587
Authenticate network git commands (#6541) 2022-11-15 13:14:37 +02:00
Sam Coe
f96b2fce57
Refactor git client and add tests (#6525) 2022-11-03 11:58:38 +01:00
Sam Coe
4294ee14a1
revert revert 57fbe4f317 (#6474) 2022-10-20 12:17:20 +00:00
Sam Coe
2cefb9fa59
Fix pr create regression (#6472)
* Revert "Refactor to use new git client (#6447)"

This reverts commit 57fbe4f317.

* Fix pr create regression
2022-10-20 12:46:23 +03:00
Sam Coe
57fbe4f317
Refactor to use new git client (#6447) 2022-10-19 21:11:36 +03:00
Sam Coe
2944f7c3ab
Create git client (#6354) 2022-10-14 07:47:03 +00:00