1
Fork 0
mirror of https://github.com/RGBCube/github2forgejo synced 2026-01-13 08:41:03 +00:00

feat: check if strategy is valid

This commit is contained in:
RGBCube 2025-10-24 19:23:49 +03:00
parent a0ba2fe860
commit 0222427589
Signed by: RGBCube
SSH key fingerprint: SHA256:CzqbPcfwt+GxFYNnFVCqoN5Itn4YFrshg1TrnACpA5M

View file

@ -39,6 +39,10 @@ def main [] {
let strategy = $env | get --optional STRATEGY | or-default { [ Mirrored Cloned ] | input list $"(ansi cyan)Should the repos be mirrored, or just cloned once?(ansi reset)" } | str downcase
let force_sync = $env | get --optional FORCE_SYNC | try { into bool } | or-default { [ "Yup, delete them" Nope ] | input list $"(ansi yellow)Should mirrored repos that don't have a GitHub source anymore be deleted?(ansi reset)" | $in != "Nope" }
if $strategy not-in [ "mirrored", "cloned" ] {
print --stderr $"(ansi red)Invalid strategy! Must be either: (ansi green)mirrored(ansi red) or (ansi cyan)cloned(ansi red).(ansi reset)"
}
let github_repos = do {
def get-repos-at [page_nr: number] {
if $github_token == "" {
@ -110,7 +114,7 @@ def main [] {
-H [ Authorization $"token ($forgejo_token)" ]
({
clone_addr: $github_repo.html_url
mirror: ($strategy != "cloned")
mirror: ($strategy == "mirrored")
private: $github_repo.private
repo_owner: $forgejo_user
repo_name: $github_repo.name