Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ghorg reclone ignores GHORG_ABSOLUTE_PATH_TO_CLONE_TO #473

Open
dvonessen opened this issue Nov 14, 2024 · 3 comments
Open

ghorg reclone ignores GHORG_ABSOLUTE_PATH_TO_CLONE_TO #473

dvonessen opened this issue Nov 14, 2024 · 3 comments

Comments

@dvonessen
Copy link
Contributor

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

  • I use the environment variable because the conf.yaml file doesn’t handle relative paths correctly.
  • My setup runs on multiple machines with different usernames, so I rely on the environment variable to point to a custom directory within each user's home directory.

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
  1. 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
       *************************************
    
  2. 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):

  • OS: MacOS 15.1
  • SHELL: ZSH

Additional context
Add any other context about the problem here.

@gabrie30
Copy link
Owner

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
Copy link
Contributor Author

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.

@gabrie30
Copy link
Owner

gabrie30 commented Nov 15, 2024

If you aren't using a ghorg conf, try using the --env-config-only flag or setting GHORG_RECLONE_ENV_CONFIG_ONLY=true it shouldn't reset your GHORG_ABSOLUTE_PATH_TO_CLONE_TO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants