Skip to content

Commit 262de34

Browse files
committed
fix: handling of git auth without username
1 parent aa57ff2 commit 262de34

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

jupyterlab_git/git.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,19 @@ def communicate(self):
3131
cwd = self.cwd,
3232
env = self.env
3333
)
34-
p.expect('Username for .*: ')
35-
p.sendline(self.username)
36-
p.expect('Password for .*:')
37-
p.sendline(self.password)
34+
35+
# We expect a prompt from git
36+
# In most of cases git will prompt for username and
37+
# then for password
38+
# In some cases (Bitbucket) username is included in
39+
# remote URL, so git will not ask for username
40+
i = p.expect(['Username for .*: ', 'Password for .*:'])
41+
if i==0: #ask for username then password
42+
p.sendline(self.username)
43+
p.expect('Password for .*:')
44+
p.sendline(self.password)
45+
elif i==1: #only ask for password
46+
p.sendline(self.password)
3847

3948
p.expect(pexpect.EOF)
4049
response = p.before

0 commit comments

Comments
 (0)