-
-
Notifications
You must be signed in to change notification settings - Fork 101
remote: support remotes referred by URL only #793
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
Conversation
6438488 to
84cfe75
Compare
84cfe75 to
f8711c2
Compare
|
I'll move this MR to draft until I get the tests fixed. |
f8711c2 to
5a358ec
Compare
When using git-push the user can set the upstream of a branch to a remote that is not present in the current repository by referring to its URL. In these cases, git checks for the validity of the URL itself instead of checking if a remote with that name exists locally. I.e.: $ git push --set-upstream <URL> This case affects lab mostly when we use the remote URL to lookup for it in GitLab: lab checks for the branch's remote name. `branch.<branch>.remote`, then it gets the remote URL itself; however, in this situation, the `branch.<branch>.remote` will be the URL already and any check for that remote in the local repository fails. The biggest problem is the amount of different URL formats supported by Git [1], which is bigger than the ones supported by the usual url.Parse() (net/url Go module). Because of that, I brought the git-urls module to help. This new module threat anything that isn't an external URL as a possible file URL, meaning that default remote names are also accepted, with that we can pass all our remote names (URL or not) to its Parse() function and just use the "path" component, which is pretty close to what we need for the GitLab lookup. [1] https://git-scm.com/docs/git-push#URLS Signed-off-by: Bruno Meneguele <bmeneg@redhat.com>
5a358ec to
bbd51a7
Compare
Codecov Report
@@ Coverage Diff @@
## master #793 +/- ##
==========================================
- Coverage 55.07% 54.72% -0.36%
==========================================
Files 77 77
Lines 5641 5681 +40
==========================================
+ Hits 3107 3109 +2
- Misses 2255 2289 +34
- Partials 279 283 +4
Continue to review full report at Codecov.
|
|
@bmeneg , it's always easier for me to see a real world example. Can you show me how this would actually work within a git repo? |
|
@prarit yes sure. One practical usage of it is on CI environments where remote names are not really required/used. But something simpler: the user can setup a repository and for whatever reason push things so some repository using the remote URL instead of the same itself. For instance: works just fine. At the same time, the user can set that remote URL as a real tracking remote: Causing the I personally don't use remote URLs directly, but Git does support it and mention it in the first lines of the git-push help: NOTE: I flxed the test code, I'm going to move the PR to ready state. |
|
Ah, one thing that might help a bit to understand is: we need to distinguish between a remote name vs url because today we use it to retrieve GitLab's project: however, in case we don't have a real remote name, but a remote url instead, we have to skip the second step from above, ending up with the following flow: |
|
@prarit did my comments help you understand the situation this PR is trying to solve? |
When using git-push the user can set the upstream of a branch to a
remote that is not present in the current repository by referring to its
URL. In these cases, git checks for the validity of the URL itself
instead of checking if a remote with that name exists locally.
I.e.:
This case affects lab mostly when we use the remote URL to lookup for it
in GitLab: lab checks for the branch's remote name.
branch.<branch>.remote, then it gets the remote URL itself; however,in this situation, the
branch.<branch>.remotewill be the URL alreadyand any check for that remote in the local repository fails.
The biggest problem is the amount of different URL formats supported by
Git [1], which is bigger than the ones supported by the usual
url.Parse() (net/url Go module). Because of that, I brought the git-urls
module to help.
This new module threat anything that isn't an external URL as a possible
file URL, meaning that default remote names are also accepted, with that
we can pass all our remote names (URL or not) to its Parse() function
and just use the "path" component, which is pretty close to what we need
for the GitLab lookup.
[1] https://git-scm.com/docs/git-push#URLS
Signed-off-by: Bruno Meneguele bmeneg@redhat.com
Related: #381