Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
mercurial
hg-git
Commits
d5ff695d3cd1
Commit
d5ff695d
authored
Oct 20, 2020
by
Pierre Augier
Browse files
Fix https push without username & password
parent
d6ac1ae9027a
Pipeline
#11885
passed with stages
in 3 minutes and 56 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
hggit/git_handler.py
View file @
d5ff695d
...
...
@@ -1199,7 +1199,7 @@
return
new_refs
def
fetch_pack
(
self
,
remote_name
,
heads
=
None
):
localclient
,
path
=
self
.
get_transport_and_path
(
remote_name
)
localclient
,
path
=
self
.
get_transport_and_path
(
remote_name
,
readonly
=
True
)
# The dulwich default walk only checks refs/heads/. We also want to
# consider remotes when doing discovery, so we build our own list. We
...
...
@@ -1665,7 +1665,7 @@
except
UnicodeDecodeError
:
return
string
.
decode
(
'ascii'
,
'replace'
).
encode
(
'utf-8'
)
def
get_transport_and_path
(
self
,
uri
):
def
get_transport_and_path
(
self
,
uri
,
readonly
=
False
):
"""Method that sets up the transport (either ssh or http(s))
Tests:
...
...
@@ -1679,7 +1679,7 @@
>>> mockrepo.path = b''
>>> g = GitHandler(mockrepo, ui())
>>> tp = g.get_transport_and_path
>>> client, url = tp(b'http://
fqdn.com/test.git'
)
>>> client, url = tp(b'http
s
://
github.com/schacon/hg-git.git', readonly=True
)
>>> print(isinstance(client, HttpGitClient))
True
>>> print(url.decode())
...
...
@@ -1683,7 +1683,7 @@
>>> print(isinstance(client, HttpGitClient))
True
>>> print(url.decode())
http://
fqdn.com/tes
t.git
http
s
://
github.com/schacon/hg-gi
t.git
>>> client, url = tp(b'git@fqdn.com:user/repo.git')
>>> print(isinstance(client, SSHGitClient))
True
...
...
@@ -1743,9 +1743,13 @@
username
=
username
.
decode
(
'latin-1'
)
if
password
is
not
None
:
password
=
password
.
decode
(
'latin-1'
)
return
(
client
.
HttpGitClient
(
def
create_client_with_password
(
username
,
password
):
if
username
is
None
or
password
is
None
:
pmgr
=
compat
.
passwordmgr
(
self
.
ui
)
username
,
password
=
pmgr
.
find_user_password
(
None
,
uri
)
return
client
.
HttpGitClient
(
str_uri
,
config
=
config
,
username
=
username
,
password
=
password
,
...
...
@@ -1748,10 +1752,25 @@
str_uri
,
config
=
config
,
username
=
username
,
password
=
password
,
),
uri
,
)
)
if
not
readonly
:
return
create_client_with_password
(
username
,
password
),
uri
else
:
local_client
=
client
.
HttpGitClient
(
str_uri
,
config
=
config
,
username
=
username
,
password
=
password
,
)
try
:
# a public repository?
local_client
.
get_refs
(
""
)
except
GitProtocolError
:
local_client
=
create_client_with_password
(
username
,
password
)
return
local_client
,
uri
# if its not git or git+ssh, try a local url..
return
client
.
SubprocessGitClient
(),
uri
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment