Commit graph

93 commits

Author SHA1 Message Date
majiayu000
3f0044fd94 fix: error when --remote flag used with repo argument
When a repository argument is provided to `gh repo fork`, the command
operates independently of the current local repository. Using --remote
in this context is incompatible because there's no local repository to
add the remote to.

This change returns an explicit error when these flags are combined,
providing clear feedback instead of silently ignoring the --remote flag.

Fixes #2722

Signed-off-by: majiayu000 <1835304752@qq.com>
2025-12-26 14:43:52 +08:00
Babak K. Shandiz
d002d30327
fix: resolve nilerr issues
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-11-03 20:05:26 +00:00
Tyler McGoffin
efec5d9250 Fixed test for stdout in non-tty use case of repo fork 2025-01-03 15:54:07 -08:00
Aryan Bhosale
8dbbceaaaf
print repo url to stdout 2025-01-03 10:54:30 +05:30
Aryan Bhosale
8560c24f3f
fix(repo fork): add non-TTY output when fork is newly created 2025-01-01 11:56:18 +05:30
Tim Rogers
c719d920c3
When renaming an existing remote in gh repo fork, log the change
When running `gh repo fork` in the context of an existing repo, the CLI offers to create a remote for the fork:

```
? Would you like to add a remote for the fork? Yes
```

If you accept, it prints a log stating that the `origin` remote has been created:

```
✓ Added remote origin
```

Where there is an existing `origin` remote, this is renamed to `upstream`, but this is done silently without any notification to the user.

```bash
$ git remote -v
origin	https://github.com/timrogers/badger.github.io.git (fetch)
origin	https://github.com/timrogers/badger.github.io.git (push)
upstream	https://github.com/badger/badger.github.io.git (fetch)
upstream	https://github.com/badger/badger.github.io.git (push)
```

It seems kinda fine to rename the remote without explicitly confirming since this is not a truly destructive action, but it should make it clear what it is doing.

This updates the logging to explicitly log about the renaming of
the existing remote:

```
✓ Renamed remote origin to upstream
```

Fixes #9982.
2024-11-30 21:19:55 +00: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
William Martin
15ba536317 Ensure subtests use the right t during setup 2023-12-06 14:06:28 +01:00
William Martin
dc0f6d55e2 Use real config in fork cmd tests 2023-12-06 14:06:28 +01:00
Yukai Chou
ba585149c3 Leftovers 2023-11-23 07:12:47 +08:00
Yukai Chou
07a87ca8a4 Wrap special values and placeholders like - and $1 2023-11-23 07:09:29 +08:00
Sam Coe
7924878315
Fix git protocol and refactor Config interface (#8246) 2023-10-27 15:42:05 +02:00
Keith Bailey
363dacbbed
Set default repository for repo clone and repo fork (#7768) 2023-10-11 13:41:00 +00:00
Nate Smith
2ddfc3827d use new prompter in repo fork 2023-08-16 16:02:14 -05:00
Sam Coe
35a24caed2
Standardize retry mechanism (#7027) 2023-03-02 23:06:30 +00:00
Hamish 'James' Coates
394b23aa9b
Include new line after existing fork error log (#7030) 2023-02-28 00:53:25 +00:00
Josh Soref
7541ee6aec
Retry git clone on git clone failure in gh repo fork --clone (#6962) 2023-02-21 04:10:50 +00:00
Mislav Marohnić
14eb873b9e
Avoid implicitly fetching when adding a new git remote (#6990) 2023-02-07 21:22:02 +00:00
Josh Soref
e6d6427704 Support Fork with Default Branch Only 2023-02-07 10:00:39 -05:00
Sam Coe
98ab1f2587
Authenticate network git commands (#6541) 2022-11-15 13:14:37 +02: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
Sam Coe
e7102f9d84
Migrate to go-gh text package (#6236) 2022-09-14 09:23:55 +04:00
vilmibm
41385477c3 fix linting 2022-07-27 14:15:27 -05:00
vilmibm
d5334f4115 Revert "update linter checks"
This reverts commit 40ecb8c188.
2022-07-27 13:30:41 -05:00
vilmibm
40ecb8c188 update linter checks 2022-07-26 16:06:52 -05:00
Mislav Marohnić
5656296ade repo fork: directly fork under the desired name
A new GitHub feature landed where the API client can specify the desired
name of the new fork. This avoids the necessity of subsequently having
to rename the forked repo after the fork operation has created one.

For backwards compatibility, the renaming logic is still here, but
activates only if the resulting repo name is not the desired name.
2022-07-11 13:54:58 +02:00
Sam Coe
cacff4ad6d
Use go-gh config package (#5771) 2022-06-23 11:50:04 +00:00
Jonathan Fenwick
ddb408e67b
Add check to see if current owner is attempting to fork the repo (#5794)
Co-authored-by: Mislav Marohnić <mislav@github.com>
2022-06-14 13:13:24 +00:00
Ahmed Adan
31bee2e639
Add --upstream-remote-name flag to gh replo clone (#5619) 2022-05-24 13:12:01 +02:00
Håvard Anda Estensen
58cb773e09
Replace ioutil with io and os (#5498) 2022-04-26 13:07:44 +02:00
Mislav Marohnić
512208ca96 repo fork: tweak docs 2022-02-18 18:38:34 +01:00
Nate Smith
e17964cf03
Merge pull request #5092 from cli/repo-fork-proto
prefer configured git protocol when forking
2022-01-26 11:33:47 -06:00
nate smith
667671f048 fix race condition, increase clarity 2022-01-25 15:36:41 -06:00
nate smith
bd6e50a08a Merge remote-tracking branch 'origin/trunk' into feature/target-repo-fork-name 2022-01-25 14:08:27 -06:00
nate smith
0d214864d9 linter appeasement 2022-01-24 17:01:19 -06:00
nate smith
170a50fcc8 prefer configured git protocol when forking 2022-01-24 16:54:01 -06:00
Nate Smith
4b415f80d7
Merge pull request #5022 from cli/config-defaults
add GetOrDefault and related methods to Config
2022-01-17 10:44:28 -06:00
Mislav Marohnić
44775f87c8 Add nolint directives to allow-list current lint violations 2022-01-14 19:52:52 +01:00
nate smith
562f1b3d0d add GetOrDefault functionality to config 2022-01-11 14:56:58 -06:00
Gowtham Munukutla
3fb4c481dc modify tests 2021-12-11 10:17:04 +05:30
Gowtham Munukutla
54d92facbf add flag to set fork-name during repo fork. Tests WIP 2021-12-10 22:59:35 +05:30
Alan Donovan
f4491c7a80 Add FlagErrorf; encapsulate FlagError.error 2021-10-21 11:40:20 -04:00
Alan Donovan
7215522123 use FlagError 2021-10-21 10:06:11 -04:00
Mislav Marohnić
11fbb60ae7 Rename the module to "github.com/cli/cli/v2" 2021-08-25 12:41:30 +02:00
camille folch
568f4e4ee0
Minor refactoring for readability in NewCmdFork's runE 2021-06-11 23:28:41 -03:00
camille folch
54b86c7093
repo fork: check that --org is not the empty string
As it is already being done for --remote-name, except in this case
the default is the empty string.
2021-06-11 23:28:41 -03:00