gabrie30 / ghorg

Quickly clone an entire org/users repositories into one directory - Supports GitHub, GitLab, Bitbucket, and more 🐇🥚
Apache License 2.0
1.58k stars 167 forks source link

ghorg reclone ignores GHORG_ABSOLUTE_PATH_TO_CLONE_TO #473

Open dvonessen opened 7 hours ago

dvonessen commented 7 hours ago

Describe the bug I'm running into an issue where ghorg reclone does not seem to respect the GHORG_ABSOLUTE_PATH_TO_CLONE_TO environment variable.

Context

Any advice or workaround would be appreciated! 😊

To Reproduce Steps to reproduce the behavior:

  1. Configure reclone.yaml

    github-dvonessen: 
    cmd: ghorg clone NAME --scm=github --clone-type user --preserve-dir --token xxxxxx --output-dir github.com/dvonessen
    description: Clones the dvonessen user repositories
  2. Full command and details of the clone (removing your token) e.g.

      $ export GHORG_ABSOLUTE_PATH_TO_CLONE_TO=/home/username/git
      $ ghorg reclone github-dvonessen
      Running reclone: github-dvonessen
      Description: Clones the dvonessen user repositories
    
      > ghorg clone dvonessen --scm=github --clone-type user --preserve-dir --token XXXXXXX --output-dir github.com/dvonessen
    
       +-+-+-+-+ +-+-+ +-+-+-+-+-+
       |T|I|M|E| |T|O| |G|H|O|R|G|
       +-+-+-+-+ +-+-+ +-+-+-+-+-+
    
       *************************************
       * SCM           : github
       * Type          : user
       * Protocol      : ssh
       * Location      : /Users/dvonessen/ghorg/
       * Concurrency   : 25
       * Skip Archived : true
       * Wikis         : true
       * Submodules    : true
       * Output Dir    : github.com/dvonessen
       * No Clean      : true
       * Prune         : true
       * Fetch All     : true
       * Reclone Conf  : /Users/dvonessen/.config/ghorg/reclone.yaml
       * Preserve Dir  : true
       * Config Used   : /Users/dvonessen/.config/ghorg/conf.yaml
       * Ghorg version : v1.11.0
       *************************************
  3. Details on the user/org you tried to clone e.g. is it your user, a public org, etc.

Environment (please complete the following information):

Additional context Add any other context about the problem here.

gabrie30 commented 6 hours ago

Yea I dont think reclone will only respect certain envs it resets them before a new reclone.

I would recommend try using the --path flag in your clone/reclone commands which will accomplish the same thing as setting the environment variable in combination with $(whoami) something like

ghorg clone NAME --scm=github --clone-type user --token xxxxxx --output-dir github.com/dvonessen --path /home/$(whoami)/git

dvonessen commented 6 hours ago

I added --path /home/$(whoami)/git but that leads into an exception.

panic: mkdir /home/$(whoami): operation not supported

goroutine 1 [running]:
github.com/gabrie30/ghorg/cmd.createDirIfNotExist()
        /home/runner/work/ghorg/ghorg/cmd/clone.go:371 +0x88
github.com/gabrie30/ghorg/cmd.CloneAllRepos({0x10607d860, 0x1067735e0}, {0x140004d9108, 0x8, 0x8})
        /home/runner/work/ghorg/ghorg/cmd/clone.go:649 +0x644
github.com/gabrie30/ghorg/cmd.setupRepoClone()
        /home/runner/work/ghorg/ghorg/cmd/clone.go:335 +0x268
github.com/gabrie30/ghorg/cmd.cloneFunc(0x1066fc540, {0x14000466360, 0x1, 0x9})
        /home/runner/work/ghorg/ghorg/cmd/clone.go:308 +0x12b4
github.com/spf13/cobra.(*Command).execute(0x1066fc540, {0x140004662d0, 0x9, 0x9})
        /home/runner/work/ghorg/ghorg/vendor/github.com/spf13/cobra/command.go:989 +0x828
github.com/spf13/cobra.(*Command).ExecuteC(0x1066fc260)
        /home/runner/work/ghorg/ghorg/vendor/github.com/spf13/cobra/command.go:1117 +0x344
github.com/spf13/cobra.(*Command).Execute(...)
        /home/runner/work/ghorg/ghorg/vendor/github.com/spf13/cobra/command.go:1041
github.com/gabrie30/ghorg/cmd.Execute()
        /home/runner/work/ghorg/ghorg/cmd/root.go:425 +0x24
main.main()
        /home/runner/work/ghorg/ghorg/main.go:8 +0x1c
ERROR: Running ghorg clone cmd: ghorg clone yggdrasil3 --scm=gitlab --preserve-dir --token XXXXXXX --output-dir gitlab.com/yggdrasil3 --path /home/$(whoami)/test, err: exit status 2

I guess the exec.cmd does not allow $() subprocesses.