Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Dockerized Testing Toolkit
DTT Backend
Commits
2a5ad27c
Commit
2a5ad27c
authored
Jul 01, 2020
by
Kammleiter
Browse files
add public clone possibility
parent
cb390af4
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/hftstuttgart/rest/v1/task/TaskUpload.java
View file @
2a5ad27c
...
@@ -118,8 +118,8 @@ public class TaskUpload {
...
@@ -118,8 +118,8 @@ public class TaskUpload {
this
.
jGitUtil
.
cloneRepository
(
"http://"
+
this
.
modocotProperties
.
getDockerHostIp
()
this
.
jGitUtil
.
cloneRepository
(
"http://"
+
this
.
modocotProperties
.
getDockerHostIp
()
+
":3000/"
+
this
.
modocotProperties
.
getGitTeaUsername
()
+
"/"
+
":3000/"
+
this
.
modocotProperties
.
getGitTeaUsername
()
+
"/"
+
assignmentId
+
".git"
,
+
assignmentId
+
".git"
,
unit
,
null
,
false
);
unit
,
null
,
true
,
false
);
this
.
jGitUtil
.
cloneRepository
(
repoUrl
,
task
,
credentials
,
true
);
this
.
jGitUtil
.
cloneRepository
(
repoUrl
,
task
,
credentials
,
credentials
!=
null
,
true
);
}
}
}
}
}
}
src/main/java/de/hftstuttgart/rest/v1/unittest/UnitTestUpload.java
View file @
2a5ad27c
...
@@ -90,7 +90,7 @@ public class UnitTestUpload {
...
@@ -90,7 +90,7 @@ public class UnitTestUpload {
String
credentials
=
((
lines
.
size
()
>
1
)
&&
!
lines
.
get
(
1
).
equals
(
""
))
?
String
credentials
=
((
lines
.
size
()
>
1
)
&&
!
lines
.
get
(
1
).
equals
(
""
))
?
lines
.
get
(
1
)
:
null
;
lines
.
get
(
1
)
:
null
;
// cloning repository repoUrl into work-directory, using credentials from second line in repo.txt
// cloning repository repoUrl into work-directory, using credentials from second line in repo.txt
this
.
jGitUtil
.
cloneRepository
(
repoUrl
,
workDirectory
,
credentials
,
true
);
this
.
jGitUtil
.
cloneRepository
(
repoUrl
,
workDirectory
,
credentials
,
credentials
!=
null
,
true
);
}
}
// creating repository on internal giTea, name = assignmentId
// creating repository on internal giTea, name = assignmentId
...
...
src/main/java/de/hftstuttgart/utils/JGitUtil.java
View file @
2a5ad27c
...
@@ -41,7 +41,7 @@ public class JGitUtil {
...
@@ -41,7 +41,7 @@ public class JGitUtil {
* @param token AuthToken, when cloning Repository. If {@code null} use {@code ModocotProperties}
* @param token AuthToken, when cloning Repository. If {@code null} use {@code ModocotProperties}
* @param proxy boolean if a proxy should be used
* @param proxy boolean if a proxy should be used
*/
*/
public
void
cloneRepository
(
String
uriToClone
,
File
cloneDirectory
,
String
token
,
boolean
proxy
)
{
public
void
cloneRepository
(
String
uriToClone
,
File
cloneDirectory
,
String
token
,
boolean
useToken
,
boolean
proxy
)
{
if
(!
cloneDirectory
.
isDirectory
())
{
if
(!
cloneDirectory
.
isDirectory
())
{
String
error
=
String
.
format
(
"%s is not a directory, cannot clone"
,
cloneDirectory
.
getAbsolutePath
());
String
error
=
String
.
format
(
"%s is not a directory, cannot clone"
,
cloneDirectory
.
getAbsolutePath
());
LOG
.
error
(
error
);
LOG
.
error
(
error
);
...
@@ -50,21 +50,23 @@ public class JGitUtil {
...
@@ -50,21 +50,23 @@ public class JGitUtil {
LOG
.
info
(
String
.
format
(
"Cloning all files from %s into %s"
,
uriToClone
,
cloneDirectory
.
getAbsolutePath
()));
LOG
.
info
(
String
.
format
(
"Cloning all files from %s into %s"
,
uriToClone
,
cloneDirectory
.
getAbsolutePath
()));
try
{
try
{
deleteDotGitFolder
(
cloneDirectory
);
deleteDotGitFolder
(
cloneDirectory
);
UsernamePasswordCredentialsProvider
credProvider
;
UsernamePasswordCredentialsProvider
credProvider
=
null
;
if
(
token
!=
null
)
{
if
(
useToken
)
{
LOG
.
info
(
"Using token: "
+
token
);
if
(
token
!=
null
)
{
String
[]
credentials
=
token
.
split
(
":"
);
LOG
.
info
(
"Using token: "
+
token
);
credProvider
=
new
UsernamePasswordCredentialsProvider
(
credentials
[
0
],
credentials
[
1
]);
String
[]
credentials
=
token
.
split
(
":"
);
}
else
{
credProvider
=
new
UsernamePasswordCredentialsProvider
(
credentials
[
0
],
credentials
[
1
]);
LOG
.
info
(
"Using credentials: "
+
this
.
modocotProperties
.
getGitTeaUsername
()
+
", "
+
this
.
modocotProperties
.
getGitTeaPassword
());
}
else
{
credProvider
=
new
UsernamePasswordCredentialsProvider
(
LOG
.
info
(
"Using credentials: "
+
this
.
modocotProperties
.
getGitTeaUsername
()
+
", "
+
this
.
modocotProperties
.
getGitTeaPassword
());
this
.
modocotProperties
.
getGitTeaUsername
(),
credProvider
=
new
UsernamePasswordCredentialsProvider
(
this
.
modocotProperties
.
getGitTeaPassword
());
this
.
modocotProperties
.
getGitTeaUsername
(),
this
.
modocotProperties
.
getGitTeaPassword
());
}
}
}
LOG
.
info
(
"Starting cloning, url: "
+
uriToClone
);
LOG
.
info
(
"Starting cloning, url: "
+
uriToClone
);
setProxy
(
proxy
);
setProxy
(
proxy
);
Git
.
cloneRepository
()
Git
.
cloneRepository
()
.
setCredentialsProvider
(
credProvider
)
.
setCredentialsProvider
(
useToken
?
credProvider
:
null
)
.
setURI
(
uriToClone
)
.
setURI
(
uriToClone
)
.
setDirectory
(
cloneDirectory
)
.
setDirectory
(
cloneDirectory
)
.
call
()
.
call
()
...
...
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