git-repo-manager icon indicating copy to clipboard operation
git-repo-manager copied to clipboard

cannot sync found projects.

Open woutervh opened this issue 2 years ago • 5 comments

what am i doing wrong:

first I created a config-file with:

> grm repos find remote --provider gitlab --token-command "echo ${GITLAB_TOKEN}" --root repo --format yaml --group my-projects  > gitlab-projects.yaml

This finds all my-projects correctly:

trees:
- root: repo
  repos:

  - name: foo
    worktree_setup: false
    remotes:
    - name: origin
      url: [email protected]:my-projects/foo.git
      type: ssh
     ....

manually cloning this repo works ok

> git clone [email protected]:my-projects/foo.git

but syncing via grm fails

>  grm repos sync config --config gitlab-projects.yaml
remote: ========================================================================
remote:
remote: ERROR: The project you were looking for could not be found or you don't have permission to view it.

remote:
remote: ========================================================================
remote:
; class=Ssh (23); code=Eof (-20)

woutervh avatar Nov 19 '23 21:11 woutervh

How did you set up SSH auth? grm only supports ssh-agent-based auth.

hakoerber avatar Nov 28 '23 17:11 hakoerber

A direct git clone via ssh on the same ssh-glone url works. I use an ssh-agent running, and use named ssh-sessions like this:

Host gitlab.com
    AddKeysToAgent yes
    HostName gitlab.com
    IdentityFile ~/.ssh/id_ed25519
    IdentitiesOnly yes
    Port 22
    PreferredAuthentications publickey

Somehow grm manages to fetch the complete list of remote private projects, but cannot check them out.

woutervh avatar Nov 28 '23 18:11 woutervh

@woutervh I have a similar problem.

My ~/.ssh/config file looks like this :

Host myfancy.domain.com
  HostName 159.XXX.XXX.XX
  IdentityFile ~/.ssh/myfancy_key
....

grm wasn't able to resolve the domain to the ip and also didn't picked up the ssh key.

Following script worked for me as a workaround (maybe change the path to your config.yml at the last line):

function sync_repos {
    # Check if the SSH wrapper script exists
    if [ ! -f ~/.ssh/wrapper.sh ]; then
        # If it doesn't exist, create it
        echo '#!/bin/bash' > ~/.ssh/wrapper.sh
        echo 'ssh -F ~/.ssh/config "$@"' >> ~/.ssh/wrapper.sh

        # Make the script executable
        chmod +x ~/.ssh/wrapper.sh
    fi

    # Set the GIT_SSH_COMMAND environment variable
    export GIT_SSH_COMMAND="~/.ssh/wrapper.sh"

    # Run the grm command with the new config file
    grm repos sync config --config ~/repos/config.yml
}

What it does:

It sets the GIT_SSH_COMMAND env variable, which libgit2 picks up, when executing the git commands. And the evn variable tells it, to use the script at ~/.ssh/wrapper.sh (which get's first created, if it is not present). The wrapper.sh tells git, to load the config file (eg. ssh -F ~/.ssh/config "$@").

With that, it now works again. Hope it helps.

rbcb-bedag avatar Mar 04 '24 12:03 rbcb-bedag

I think the issue is that grm does not read any git configurations at all. This should be quite straightfoward to implement using git-rs' Config::open_default.

Maybe you can take a shot at the implemenation? The best place to read the config would be in clone_repo() I guess.

hakoerber avatar Apr 27 '24 09:04 hakoerber

This is very frustating, no verbose mode, nothing works. I can get a list of remote repos, but I cannot do anything with it,
Something is missing in the docs. No idea what.

woutervh avatar May 20 '24 22:05 woutervh