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

Remote SSH URL doesn't match HTTP URL for repo #37

Closed
mafredri opened this issue Jun 10, 2016 · 5 comments
Closed

Remote SSH URL doesn't match HTTP URL for repo #37

mafredri opened this issue Jun 10, 2016 · 5 comments
Labels

Comments

@mafredri
Copy link

I just tried out this tool and got to say it's pretty awesome! One thing I noticed though that it doesn't handle any of my git@github.com:name/repo.git URLs. For example:

  #  github.com/mafredri/go-gaussian/...
    # Remote URL (git@github.com:mafredri/go-gaussian.git) doesn't match repo URL inferred from import path (https://github.com/mafredri/go-gaussian)

In my opinion this should be a match since they are essentially the same repo.

@mafredri
Copy link
Author

Hmm, just saw #30 and that this should be fixed in 8100e25, however, could it be that it doesn't consider the .git extension?

@dmitshur
Copy link
Member

dmitshur commented Jun 10, 2016

Hi, thanks for trying it!

Not having special logic to ignore .git suffix is done intentionally. GitHub treats them interchangeably, but not all git/mercurial/etc. hosts do that.

The best way to resolve this problem is to update your repo's remote from:

git@github.com:mafredri/go-gaussian.git

To:

git@github.com:mafredri/go-gaussian

You can cd into the folder and run:

git remote set-url origin git@github.com:mafredri/go-gaussian

When I created this tool, I too had to update a few of my Go package repos that I cloned using git clone rather than go get. However, when you use go get, there is no .git suffix and gostatus helps catch that. And if you use git clone, just omit the .git suffix since it's not neccessary.

@mafredri
Copy link
Author

Thanks for the response. I can appreciate your wish for precise comparison, correctness is usually good.

GitHub treats them interchangeably, but not all git/mercurial/etc. hosts do that.

I do wonder if this is a real problem or not, however. How often would stripping the .git extension during a comparison have any real-world effect? Also, since the extension is likely supported by any host where you might use it, showing an error has no real world benefit (unless there's something I don't know about git paths).

My guess is that quite a few people actually has the .git extension in their paths, and not fixing this in one way or another could lead to more opened issues. I don't really mind updating my remotes, but at the very least, the error message should be made less confusing. Instead of:

# Remote URL (git@github.com:mafredri/go-gaussian.git) doesn't match repo URL inferred from import path (https://github.com/mafredri/go-gaussian)

It would say:

# Remote URL (git@github.com:mafredri/go-gaussian.git) doesn't match repo URL inferred from import path (git@github.com:mafredri/go-gaussian)

By matching the protocol used, the user would not be lead as much astray as to why the error is popping up.

@dmitshur
Copy link
Member

dmitshur commented Jun 11, 2016

Thanks for your thoughtful comment @mafredri.

I do wonder if this is a real problem or not, however. How often would stripping the .git extension during a comparison have any real-world effect? Also, since the extension is likely supported by any host where you might use it, showing an error has no real world benefit (unless there's something I don't know about git paths).

I agree that stripping an optional ".git" suffix when doing comparisons is likely harmless. I can't think of any issues it would cause.

However, the reason I prefer to not do it is because it would add some additional complexity (however small) and imprecision. I see no benefit to supporting both ways, and so I'd rather support only one.

Finally, the go get command always checks out github repos without .git suffix in the remote. gostatus is modeled after go get behavior, and so I don't want to add any additional flexibility on top of that.

In the end, it's to keep it simpler, and allow less variability. Just like gofmt helps with keeping everyone's tabs vs spaces discussions at bay.

My guess is that quite a few people actually has the .git extension in their paths, and not fixing this in one way or another could lead to more opened issues. I don't really mind updating my remotes

Great, please do. I will point any other people to this issue.

but at the very least, the error message should be made less confusing

Got it. I completely agree with that, the error message is not as helpful as it can be, and it can be misleading/confusing. I will improve it. I'll use this issue to track that. Edit: Actually, I've created a new issue #39 to track that, so that I can close this one with "wontfix" and point other people to it, if needed.

Thanks again for contributing. :)

@mafredri
Copy link
Author

All valid points, and I tend to agree with you!

Thanks for considering my proposal for the error message :).

Here's a quick fix for anyone who might run into this:

find $GOPATH/src/github.com -type d -name .git -exec sed -i '' -e 's/url = \(.*\)\(\.git\)$/url = \1/' {}/config \;

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

No branches or pull requests

2 participants