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

av init says unable to fetch repository #494

Open
SinOverCos opened this issue Dec 18, 2024 · 9 comments
Open

av init says unable to fetch repository #494

SinOverCos opened this issue Dec 18, 2024 · 9 comments

Comments

@SinOverCos
Copy link

SinOverCos commented Dec 18, 2024

~> gh auth login
? Where do you use GitHub? GitHub.com
? What is your preferred protocol for Git operations on this host? HTTPS
? Authenticate Git with your GitHub credentials? No
? How would you like to authenticate GitHub CLI? Paste an authentication token
Tip: you can generate a Personal Access Token here https://github.com/settings/tokens
The minimum required scopes are 'repo', 'read:org'.
? Paste your authentication token: ****************************************
- gh config set -h github.com git_protocol https
✓ Configured git protocol
! Authentication credentials saved in plain text
✓ Logged in as tanwang_pins
! You were already logged in to this account
~> av init
error: unable to fetch repository from GitHub: Could not resolve to a Repository with the name '<redacted>'.

Only thing I can think of is that I'm on GH Enterprise

Token has:

  • repo:*
  • read:org
  • user:*
@SinOverCos
Copy link
Author

~> lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.6 LTS
Release:        20.04
Codename:       focal

I installed using the releases page

~> av version
v0.1.2

The command for adding a new apt repo gives me an error about file not found on u20 (even as sudo).

@jainankit
Copy link
Contributor

Hi @SinOverCos , can you give us a couple of things:

  • Did you use a fine-grain token or the classic token?
  • Can you run av init with --debug: av init --debug and give us the output.

@SinOverCos
Copy link
Author

Classic token.

~> av init --debug
DEBU[0000] enabled debug logging                         av_version=v0.1.2
DEBU[0000] git [rev-parse --git-common-dir]              duration=1.122212ms repo=optimus
DEBU[0000] loaded Git repo                               git_common_dir=/home/tanwang/code/optimus/.git
DEBU[0000] git [remote get-url origin]                   repo=optimus
DEBU[0000] executing GitHub API query...                 variables="map[string]interface {}{\"name\":\"optimus\", \"owner\":\"org-<redacted>@github.com:<redacted>\"}"
DEBU[0000] GitHub API query failed                       elapsed=152.497657ms error="Could not resolve to a Repository with the name 'org-<redacted>@github.com:<redacted>/optimus'." result="&struct { Repository gh.Repository \"graphql:\\\"repository(owner: $owner, name: $name)\\\"\" }{Repository:gh.Repository{ID:\"\", Owner:struct { Login string }{Login:\"\"}, Name:\"\"}}" variables="map[string]interface {}{\"name\":\"optimus\", \"owner\":\"org-<redacted>@github.com:<redacted>\"}"
DEBU[0000] aborting db transaction                       error="unable to fetch repository from GitHub: Could not resolve to a Repository with the name 'org-<redacted>@github.com:<redacted>/optimus'."
DEBU[0000] command exited                                duration=209.711152ms
DEBU[0000] fetched latest released version               latest=v0.1.2
error: unable to fetch repository from GitHub: Could not resolve to a Repository with the name 'org-<redacted>@github.com:pinternal/<redacted>'.
        Could not resolve to a Repository with the name 'org-<redacted>@github.com:<redacted>/optimus'.
        unable to fetch repository from GitHub
        github.com/aviator-co/av/internal/gh.(*Client).GetRepositoryBySlug
                /home/runner/work/av/av/internal/gh/repository.go:36
        main.init.func15
                /home/runner/work/av/av/cmd/av/init.go:44
        github.com/spf13/cobra.(*Command).execute
                /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:985
        github.com/spf13/cobra.(*Command).ExecuteC
                /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1117
        github.com/spf13/cobra.(*Command).Execute
                /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1041
        main.main
                /home/runner/work/av/av/cmd/av/main.go:124
        runtime.main
                /opt/hostedtoolcache/go/1.23.3/x64/src/runtime/proc.go:272
        runtime.goexit
                /opt/hostedtoolcache/go/1.23.3/x64/src/runtime/asm_amd64.s:1700

@draftcode
Copy link
Contributor

I think your Git repository's remote address (the SSH address) is a format that av haven't support. It's an scp-style URL (https://git-scm.com/docs/git-fetch#URLS).

If you can change it to ssh:// style syntax (ssh://rg-<redacted>@github.com/<redacted>/optimus), it might work. You can do that by modifying .git/config. We need to teach av to recognize that pattern, but that requires you to wait for another av release.

@SinOverCos
Copy link
Author

Thanks @draftcode , I tried that and got this:

~> git remote remove origin
~> git remote add origin ssh://org-<redacted>@github.com:<redacted>/optimus.git
~> av init
error: unable to fetch repository from GitHub: Could not resolve to a Repository with the name '/org-<redacted>'.

Something weird about my GH Enterprise setup maybe?

I just took the remote URL and added ssh:// to the beginning. I got the remote URL from git remote -v which is the same as what's in this popup menu here.

sc

@SinOverCos
Copy link
Author

SinOverCos commented Dec 19, 2024

Anyway, excited about the tool and I'm fine with waiting for the next release.

@tulioz
Copy link
Contributor

tulioz commented Dec 20, 2024

Hey @SinOverCos, I think it's still just a url issue, can you try removing the ssh:// part of the url specifically?

From local testing:

❯ git remote add origin ssh://[email protected]:aviator-og-testing/zesting.git
❯ av init
error: unable to fetch repository from GitHub: Could not resolve to a Repository with the name '/git'.
❯ git remote remove origin
❯ git remote add origin [email protected]:aviator-og-testing/zesting.git
❯ av init
Successfully initialized repository for use with av!

If that doesn't work, let me know and I can look at fixing this for you soon!

@SinOverCos
Copy link
Author

I've tried both with and without ssh:// already:

~> git remote -v
origin  org-<redacted>@github.com:<redacted>/optimus.git (fetch)
origin  org-<redacted>@github.com:<redacted>/optimus.git (push)

~> av init
error: unable to fetch repository from GitHub: Could not resolve to a Repository with the name 'org-<redacted>@github.com:<redacted>/optimus'.

Maybe the problem is I have to use [email protected] instead of [email protected]?

This is GH Enterprise.

@SinOverCos
Copy link
Author

~> git remote -v
origin  [email protected]:SinOverCos/dotfiles.git (fetch)
origin  [email protected]:SinOverCos/dotfiles.git (push)

~> av init
Successfully initialized repository for use with av!

Works fine with my personal repo (which is not part of my company's GH Enterprise).

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

4 participants