Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
db7bdaf9
Commit
db7bdaf9
authored
Dec 06, 2018
by
Ash McKenzie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Try to add .netrc credentials if needed
parent
5a610466
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
21 deletions
+19
-21
qa/qa/git/repository.rb
qa/qa/git/repository.rb
+17
-21
qa/qa/resource/repository/push.rb
qa/qa/resource/repository/push.rb
+2
-0
No files found.
qa/qa/git/repository.rb
View file @
db7bdaf9
...
...
@@ -41,12 +41,6 @@ module QA
def
use_default_credentials
self
.
username
,
self
.
password
=
default_credentials
# Write out .netrc as we need it for:
#
# git & git-lfs over HTTP
# git-lfs over SSH
add_credentials_to_netrc
if
add_credentials?
end
def
clone
(
opts
=
''
)
...
...
@@ -146,6 +140,22 @@ module QA
output
[
/git< version (\d+)/
,
1
]
||
'unknown'
end
def
try_add_credentials_to_netrc
return
unless
add_credentials?
return
if
netrc_already_contains_content?
# Despite libcurl supporting a custom .netrc location through the
# CURLOPT_NETRC_FILE environment variable, git does not support it :(
# Info: https://curl.haxx.se/libcurl/c/CURLOPT_NETRC_FILE.html
#
# This will create a .netrc in the correct working directory, which is
# a temporary directory created in .perform()
#
FileUtils
.
mkdir_p
(
tmp_home_dir
)
File
.
open
(
netrc_file_path
,
'a'
)
{
|
file
|
file
.
puts
(
netrc_content
)
}
File
.
chmod
(
0600
,
netrc_file_path
)
end
private
attr_reader
:uri
,
:username
,
:password
,
:known_hosts_file
,
...
...
@@ -159,6 +169,7 @@ module QA
end
def
add_credentials?
return
false
if
!
username
||
!
password
return
true
unless
ssh_key_set?
return
true
if
ssh_key_set?
&&
use_lfs?
...
...
@@ -215,21 +226,6 @@ module QA
File
.
exist?
(
netrc_file_path
)
&&
File
.
readlines
(
netrc_file_path
).
grep
(
/^
#{
netrc_content
}
$/
).
any?
end
def
add_credentials_to_netrc
# Despite libcurl supporting a custom .netrc location through the
# CURLOPT_NETRC_FILE environment variable, git does not support it :(
# Info: https://curl.haxx.se/libcurl/c/CURLOPT_NETRC_FILE.html
#
# This will create a .netrc in the correct working directory, which is
# a temporary directory created in .perform()
#
return
if
netrc_already_contains_content?
FileUtils
.
mkdir_p
(
tmp_home_dir
)
File
.
open
(
netrc_file_path
,
'a'
)
{
|
file
|
file
.
puts
(
netrc_content
)
}
File
.
chmod
(
0600
,
netrc_file_path
)
end
end
end
end
qa/qa/resource/repository/push.rb
View file @
db7bdaf9
...
...
@@ -67,6 +67,8 @@ module QA
email
=
user
.
email
end
repository
.
try_add_credentials_to_netrc
@output
+=
repository
.
clone
repository
.
configure_identity
(
username
,
email
)
...
...
Write
Preview
Markdown
is supported
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