mirror of
https://github.com/RGBCube/GitHub2Forgejo
synced 2025-07-26 04:37:43 +00:00
Allow specifiying specific repos
This commit is contained in:
parent
b19f2403d3
commit
b7b60faedb
2 changed files with 22 additions and 9 deletions
|
@ -29,6 +29,14 @@ This works on any Gitea or Forgejo instance.
|
||||||
This is good for when you are migrating off GitHub permanently
|
This is good for when you are migrating off GitHub permanently
|
||||||
and will never come back.
|
and will never come back.
|
||||||
|
|
||||||
|
### Can I migrate specific repositories?
|
||||||
|
|
||||||
|
Sure, just pass the URLs to them as arguments:
|
||||||
|
|
||||||
|
```nu
|
||||||
|
./migrate.nu https://github.com/RGBCube/Foo https://github.com/RGBCube/Bar
|
||||||
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
23
migrate.nu
23
migrate.nu
|
@ -13,9 +13,10 @@ def main [
|
||||||
--github-user: string = "<NONE>" # The user to migrate from.
|
--github-user: string = "<NONE>" # The user to migrate from.
|
||||||
--github-token: string = "<NONE>" # An access token for fetching private repositories. Optional.
|
--github-token: string = "<NONE>" # An access token for fetching private repositories. Optional.
|
||||||
--gitea-url: string = "<NONE>" # The URL to the Gitea or Forgejo instance
|
--gitea-url: string = "<NONE>" # The URL to the Gitea or Forgejo instance
|
||||||
--gitea-user: string = "<NONE>" # The user to mirror or clone the repositories to.
|
--gitea-user: string = "<NONE>" # The user to migrate the repositories to.
|
||||||
--gitea-token: string = "<NONE>" # An access token for the user to actually insert repositories to.
|
--gitea-token: string = "<NONE>" # An access token for the user to actually insert repositories to.
|
||||||
--strategy: string = "<NONE>" # The strategy. Valid options are "Mirrored" or "Cloned" (case sensitive).
|
--strategy: string = "<NONE>" # The strategy. Valid options are "Mirrored" or "Cloned" (case sensitive).
|
||||||
|
...repo_urls: string # The GitHub repo URLs to migrate to Gitea or Forgejo. If not given, all will be fetched.
|
||||||
] {
|
] {
|
||||||
let github_user = $github_user | str-or { input $"(ansi red)GitHub username: (ansi reset)" }
|
let github_user = $github_user | str-or { input $"(ansi red)GitHub username: (ansi reset)" }
|
||||||
let github_token = $github_token | str-or { input $"(ansi red)GitHub access token (ansi yellow)\((ansi blue)optional, only used for private repositories(ansi yellow))(ansi red): (ansi reset)" }
|
let github_token = $github_token | str-or { input $"(ansi red)GitHub access token (ansi yellow)\((ansi blue)optional, only used for private repositories(ansi yellow))(ansi red): (ansi reset)" }
|
||||||
|
@ -46,15 +47,19 @@ def main [
|
||||||
|
|
||||||
let strategy = $strategy | str-or { [ Mirrored Cloned ] | input list $"(ansi cyan)Should the repos be mirrored, or just cloned once? (ansi reset)" }
|
let strategy = $strategy | str-or { [ Mirrored Cloned ] | input list $"(ansi cyan)Should the repos be mirrored, or just cloned once? (ansi reset)" }
|
||||||
|
|
||||||
let repo_urls = if $github_token != "" {
|
let repo_urls = if ($repo_urls | length) != 0 {
|
||||||
(
|
$repo_urls
|
||||||
http get $"https://api.github.com/users/($github_user)/repos?per_page=100"
|
|
||||||
-H [ Authorization $"token ($github_token)" ]
|
|
||||||
)
|
|
||||||
| get html_url
|
|
||||||
} else {
|
} else {
|
||||||
http get $"https://api.github.com/users/($github_user)/repos?per_page=100"
|
if $github_token != "" {
|
||||||
| get html_url
|
(
|
||||||
|
http get $"https://api.github.com/users/($github_user)/repos?per_page=100"
|
||||||
|
-H [ Authorization $"token ($github_token)" ]
|
||||||
|
)
|
||||||
|
| get html_url
|
||||||
|
} else {
|
||||||
|
http get $"https://api.github.com/users/($github_user)/repos?per_page=100"
|
||||||
|
| get html_url
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$repo_urls | each {|url|
|
$repo_urls | each {|url|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue