Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
佳 邓
Gitlab4j Api
Commits
865a8639
Commit
865a8639
authored
Apr 15, 2018
by
jimrinhealthcare
Committed by
Greg Messner
Apr 14, 2018
Browse files
Implemented being able to set a tag_list when creating and updating a (#172)
parent
a273f674
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/ProjectApi.java
View file @
865a8639
...
...
@@ -646,10 +646,20 @@ public class ProjectApi extends AbstractApi implements Constants {
if
(
isApiVersion
(
ApiVersion
.
V3
))
{
boolean
isPublic
=
(
project
.
getPublic
()
!=
null
?
project
.
getPublic
()
:
project
.
getVisibility
()
==
Visibility
.
PUBLIC
);
formData
.
withParam
(
"public"
,
isPublic
);
if
(
project
.
getTagList
()
!=
null
&&
!
project
.
getTagList
().
isEmpty
())
{
// What would be the preferred way to deal with this, as the V3 API doesn't
// appear to do anything if you send in the tag_list? Could either just ignore,
// or throw an exception.
}
}
else
{
Visibility
visibility
=
(
project
.
getVisibility
()
!=
null
?
project
.
getVisibility
()
:
project
.
getPublic
()
==
Boolean
.
TRUE
?
Visibility
.
PUBLIC
:
null
);
formData
.
withParam
(
"visibility"
,
visibility
);
if
(
project
.
getTagList
()
!=
null
&&
!
project
.
getTagList
().
isEmpty
())
{
formData
.
withParam
(
"tag_list"
,
String
.
join
(
","
,
project
.
getTagList
()));
}
}
if
(
project
.
getNamespace
()
!=
null
)
{
...
...
@@ -877,10 +887,20 @@ public class ProjectApi extends AbstractApi implements Constants {
formData
.
withParam
(
"visibility_level"
,
project
.
getVisibilityLevel
());
boolean
isPublic
=
(
project
.
getPublic
()
!=
null
?
project
.
getPublic
()
:
project
.
getVisibility
()
==
Visibility
.
PUBLIC
);
formData
.
withParam
(
"public"
,
isPublic
);
if
(
project
.
getTagList
()
!=
null
&&
!
project
.
getTagList
().
isEmpty
())
{
// What would be the preferred way to deal with this, as the V3 API doesn't
// appear to do anything if you send in the tag_list? Could either just ignore,
// or throw an exception.
}
}
else
{
Visibility
visibility
=
(
project
.
getVisibility
()
!=
null
?
project
.
getVisibility
()
:
project
.
getPublic
()
==
Boolean
.
TRUE
?
Visibility
.
PUBLIC
:
null
);
formData
.
withParam
(
"visibility"
,
visibility
);
if
(
project
.
getTagList
()
!=
null
&&
!
project
.
getTagList
().
isEmpty
())
{
formData
.
withParam
(
"tag_list"
,
String
.
join
(
","
,
project
.
getTagList
()));
}
}
Response
response
=
putWithFormData
(
Response
.
Status
.
OK
,
formData
,
"projects"
,
id
);
...
...
src/test/java/org/gitlab4j/api/TestProjectApi.java
View file @
865a8639
...
...
@@ -29,6 +29,7 @@ import static org.junit.Assert.assertNotNull;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
junit
.
Assume
.
assumeTrue
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Optional
;
...
...
@@ -169,7 +170,8 @@ public class TestProjectApi {
.
withMergeRequestsEnabled
(
true
)
.
withWikiEnabled
(
true
)
.
withSnippetsEnabled
(
true
)
.
withVisibility
(
Visibility
.
PUBLIC
);
.
withVisibility
(
Visibility
.
PUBLIC
)
.
withTagList
(
Arrays
.
asList
(
"tag1"
,
"tag2"
));
Project
newProject
=
gitLabApi
.
getProjectApi
().
createProject
(
project
);
assertNotNull
(
newProject
);
...
...
@@ -179,6 +181,7 @@ public class TestProjectApi {
assertEquals
(
project
.
getMergeRequestsEnabled
(),
newProject
.
getMergeRequestsEnabled
());
assertEquals
(
project
.
getWikiEnabled
(),
newProject
.
getWikiEnabled
());
assertEquals
(
project
.
getSnippetsEnabled
(),
newProject
.
getSnippetsEnabled
());
assertEquals
(
project
.
getTagList
(),
newProject
.
getTagList
());
assertTrue
(
Visibility
.
PUBLIC
==
newProject
.
getVisibility
()
||
Boolean
.
TRUE
==
newProject
.
getPublic
());
}
...
...
@@ -192,7 +195,8 @@ public class TestProjectApi {
.
withMergeRequestsEnabled
(
true
)
.
withWikiEnabled
(
true
)
.
withSnippetsEnabled
(
true
)
.
withVisibility
(
Visibility
.
PUBLIC
);
.
withVisibility
(
Visibility
.
PUBLIC
)
.
withTagList
(
Arrays
.
asList
(
"tag1"
,
"tag2"
));
Project
newProject
=
gitLabApi
.
getProjectApi
().
createProject
(
project
);
assertNotNull
(
newProject
);
...
...
@@ -202,6 +206,7 @@ public class TestProjectApi {
assertEquals
(
project
.
getMergeRequestsEnabled
(),
newProject
.
getMergeRequestsEnabled
());
assertEquals
(
project
.
getWikiEnabled
(),
newProject
.
getWikiEnabled
());
assertEquals
(
project
.
getSnippetsEnabled
(),
newProject
.
getSnippetsEnabled
());
assertEquals
(
project
.
getTagList
(),
newProject
.
getTagList
());
assertTrue
(
Visibility
.
PUBLIC
==
newProject
.
getVisibility
()
||
Boolean
.
TRUE
==
newProject
.
getPublic
());
project
=
new
Project
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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