Skip to content
New issue

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

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

Already on GitHub? # to your account

https://github.com and git@github.com equivalence #65

Closed
dmitris opened this issue Jan 11, 2017 · 4 comments
Closed

Comments

@dmitris
Copy link

dmitris commented Jan 11, 2017

I'm seeing lots of messages like:

skipping "github.com/prometheus/prometheus" because:
remote URL (git@github.com:prometheus/prometheus.git) doesn't match repo URL inferred from import path (https://github.com/prometheus/prometheus)

Would it be possible for the tool to realize that they are equivalent and follow the origin git@github.com:prometheus/prometheus.git? The go tool seems to be able to handle it - I can do:
go get -v -x github.com/prometheus/prometheus/... even though my origin for $GOPATH/src/github.com/prometheus/prometheus is set to git@github.com:prometheus/prometheus.git, not https://github.com/prometheus/prometheus.

@dmitshur
Copy link
Member

dmitshur commented Jan 11, 2017

This issue is subtle. Let me explain what's going on.

The reason GPS currently prints that error is not because of the difference in scheme (git@github.com:... vs https://github.com/...). It correctly compares different schemes and considers them equivalent via status.EqualRepoURLs.

The actual reason it says they're different is because of the ".git" suffix that one URL has but the other doesn't.

Related issue:

shurcooL/gostatus#37

You can read my detailed rationale for the behavior in shurcooL/gostatus#37 (comment). @mafredri came up with a nice way to quickly fix the problem in his GOPATH in shurcooL/gostatus#37 (comment).

Another highly related issue is:

shurcooL/gostatus#39

Which I think definitely played a role here, and I should try to fix it.

However, the fact that go get -u works suggests I may want to consider being less strict and also allow it. I'll look into that. However, I worry that the reason go get -u works might be because it doesn't check the remote URL at all. That would mean you could get arbitrary updates from odd remote URLs. I would feel nervous about allowing that. Anyway, I'll check, it might be that go get -u has code to ignore a ".git" suffix only.

@dmitshur
Copy link
Member

dmitshur commented Jan 11, 2017

However, I worry that the reason go get -u works might be because it doesn't check the remote URL at all. That would mean you could get arbitrary updates from odd remote URLs. I would feel nervous about allowing that.

This is sad, but go get -u will just do git pull --ff-only and it doesn't care what remote URL is. It'll happily pull from something other than what the user would get if they did git get -u import/path in an empty GOPATH.

~ $ export GOPATH=/tmp/trygopathstuffmajing
~ $ go get -u -v github.com/gorilla/mux
github.com/gorilla/mux (download)
created GOPATH=/tmp/trygopathstuffmajing; see 'go help gopath'
github.com/gorilla/mux
~ $ gocd ...mux
mux $ go list
github.com/gorilla/mux
mux $ pwd
/tmp/trygopathstuffmajing/src/github.com/gorilla/mux
mux $ git remote
origin
mux $ git remote -v
origin	https://github.com/gorilla/mux (fetch)
origin	https://github.com/gorilla/mux (push)
mux $ git remote show origin 
* remote origin
  Fetch URL: https://github.com/gorilla/mux
  Push  URL: https://github.com/gorilla/mux
  HEAD branch: master
  Remote branches:
    custom-context   tracked
    master           tracked
    matcher-refactor tracked
    subexp-fix       tracked
  Local branch configured for 'git pull':
    master merges with remote master
  Local ref configured for 'git push':
    master pushes to master (up to date)
mux $ go list 
github.com/gorilla/mux
mux $ go get -u -v
github.com/gorilla/mux (download)
mux $ git remote set-url origin https://github.com/gorilla/mux.git
mux $ go get -u -v
github.com/gorilla/mux (download)
mux $ git remote set-url origin https://github.com/gorilla/mux.gitt
mux $ go get -u -v
github.com/gorilla/mux (download)
# cd /tmp/trygopathstuffmajing/src/github.com/gorilla/mux; git pull --ff-only
remote: Repository not found.
fatal: repository 'https://github.com/gorilla/mux.gitt/' not found
package github.com/gorilla/mux: exit status 1
mux $ git remote set-url origin https://github.com/jorisshh/mux.git
mux $ go get -u -v
github.com/gorilla/mux (download)
package ironMind/logger: unrecognized import path "ironMind/logger" (import path does not begin with hostname)
package ironMind/middleware: unrecognized import path "ironMind/middleware" (import path does not begin with hostname)
mux $ 

Edit: I'm starting to suspect this might be an unintentional bug/regression in go get -u, because it still has the -f flag:

The -f flag, valid only when -u is set, forces get -u not to verify that
each package has been checked out from the source control repository
implied by its import path. This can be useful if the source is a local fork
of the original.

I'll look more into it and see if an issue needs to be filed for Go.

dmitshur added a commit that referenced this issue Jan 11, 2017
Match the current repo URL format when printing the expected URL. This
makes it easier to spot the actual difference in the URL.

Follows shurcooL/gostatus@cf96920.

Helps #65.
@dmitshur
Copy link
Member

I've resolved shurcooL/gostatus#39 and applied the fix to Go Package Store in 12c0a37.

Hopefully that helps.

@dmitshur
Copy link
Member

I consider 12c0a37 to have resolved this issue. I will look into go get -u behavior separately (I think it has room for improvement).

Closing, let me know if you have any further comments.

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

No branches or pull requests

2 participants