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

grm repos find local - can generate failures to detect valid remotes when using remotes that don't end in .git #74

Open
anthonysomerset opened this issue Sep 2, 2024 · 1 comment

Comments

@anthonysomerset
Copy link

anthonysomerset commented Sep 2, 2024

Hi There

using current install on mac or rather trying to get started!

running grm repos find local ... in my scenario gives me a lot of errors (most commonly when using bitbucket or Azure DevOps based repo's)

[!] /Users/asomerset/Repos/Innovation/repos/repo-name: Could not handle URL [email protected]:orgname/reponame. Reason: The remote URL starts with an unimplemented protocol

upon delving into the source

pub fn detect_remote_type(remote_url: &str) -> Result<RemoteType, String> {
is the likely "failure" point from my reading of the code

    if remote_url.starts_with("ssh://") {
        return Ok(RemoteType::Ssh);
    }
    if git_regex.is_match(remote_url) && remote_url.ends_with(".git") {
        return Ok(RemoteType::Ssh);
    }

doesn't adequately cater for scenarios where there is no .git at the end of the remote_url and using ssh as the protocol without explicitly using ssh:// in the remote_url

If i manually edit a repo's remote_url in its .git/config (and likely also using the regular git remote commands to update to prefix ssh:// and then swap the : to a / after the hostname - so its a klunky workaround at best but it appears to work fine

perhaps some additional checks to look for either

[email protected]

or

<USER>@bitbucket.org

would help cover these edge cases although i wonder if other git repo providers have a similar case of not using .git at the end of remote_urls

maybe the test could be made more generic to cater for

<user>@<hostname>:

i haven't yet mapped out an appropriate regex for this but that might be a more generic fix

@hakoerber
Copy link
Owner

Hey,

that's a good catch.

I guess it would be fine for detect_remote_type() to be a bit more "forgiving" about the URLs. So anything like `{user}@{domain}:{repo} would be fine for SSH.

Something simple like: .+@.+:.+. I'd rather not have provider-specific matching here.

If you want to tackle this, just add a test case with your examples to the unit tests (here) and make them pass.

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