~h3rald/ecosystem

4f9879d1ae1beea8138503b70c7fdce470fc55ef — h3rald 10 months ago e3d5add
Added git mirroring setup script.
1 files changed, 63 insertions(+), 0 deletions(-)

A setup.min
A setup.min => setup.min +63 -0
@@ 0,0 1,63 @@
; Setup guthub/sourcehut push URLs

"origin\tgit@github.com:h3rald/$#.git (fetch)" :gh-fetch
"origin\tgit@github.com:h3rald/$#.git (push)" :gh-push
"origin\tgit@git.sr.ht:~h3rald/$# (push)" :sh-push

; Project list

("min" "mn" "nifty" "h3" "h3rald" "pls" "litestore" "hastyscribe" "hastysite" "hastystyles" "minline" "nimhttpd" "fae") :projects

(
  :proj
  gh-fetch (proj) =% :ghfetch
  gh-push (proj) =% :ghpush
  (ghfetch ghpush) => "\n" join
) ^single-origin

(
  :proj
  gh-fetch (proj) =% :ghfetch
  gh-push (proj) =% :ghpush
  sh-push (proj) =% :shpush
  (ghfetch ghpush shpush) => "\n" join
) ^multi-origin

"git remote set-url --add --push origin git@git.sr.ht:~h3rald/$#" :sh-add-push-cmd
"git remote set-url --add --push origin git@github.com:h3rald/$#.git" :gh-add-push-cmd
"git remote add origin git@github.com:h3rald/$#.git" :gh-add-cmd

; Assuming all projexrs are saved in parent folser
. :pwd
.. cd

projects
(
  :proj
  (proj exists?)
    (
      proj cd
      "Checking '$#'..." (proj) =% notice
      ([git remote -v] proj multi-origin ==)
        ("=> OK - skipping." notice)
        (
          "=> Adding push URL..." notice
          "git  remote remove origin" !
          gh-add-cmd (proj) =% !
          gh-add-push-cmd (proj) =% !
          sh-add-push-cmd (proj) =% !
          ([git remote -v] proj multi-origin ==)
            ("-> OK" notice)
            ("Failed" warn)
          if
        )
      if
      .. cd
    )
  when

) foreach

pwd cd

"Setup completed" notice