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
d03c2d21
Commit
d03c2d21
authored
Jan 05, 2018
by
Greg Messner
Browse files
Added support for printing_merge_request_link_enabled when creating and updating a project (#124).
parent
586cc89e
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/ProjectApi.java
View file @
d03c2d21
...
...
@@ -567,6 +567,7 @@ public class ProjectApi extends AbstractApi implements Constants {
* requestAccessEnabled (optional) - Allow users to request member access
* repositoryStorage (optional) - Which storage shard the repository is on. Available only to admins
* approvalsBeforeMerge (optional) - How many approvers should approve merge request by default
* printingMergeRequestLinkEnabled (optional) - Show link to create/view merge request when pushing from the command line
*
* @param project the Project instance with the configuration for the new project
* @param importUrl the URL to import the repository from
...
...
@@ -606,7 +607,8 @@ public class ProjectApi extends AbstractApi implements Constants {
.
withParam
(
"request_access_enabled"
,
project
.
getRequestAccessEnabled
())
.
withParam
(
"repository_storage"
,
project
.
getRepositoryStorage
())
.
withParam
(
"approvals_before_merge"
,
project
.
getApprovalsBeforeMerge
())
.
withParam
(
"import_url"
,
importUrl
);
.
withParam
(
"import_url"
,
importUrl
)
.
withParam
(
"printing_merge_request_link_enabled"
,
project
.
getPrintingMergeRequestLinkEnabled
());
if
(
isApiVersion
(
ApiVersion
.
V3
))
{
boolean
isPublic
=
(
project
.
getPublic
()
!=
null
?
project
.
getPublic
()
:
project
.
getVisibility
()
==
Visibility
.
PUBLIC
);
...
...
@@ -670,6 +672,54 @@ public class ProjectApi extends AbstractApi implements Constants {
return
(
response
.
readEntity
(
Project
.
class
));
}
/**
* Creates a Project
*
* @param name The name of the project
* @param namespaceId The Namespace for the new project, otherwise null indicates to use the GitLab default (user)
* @param description A description for the project, null otherwise
* @param issuesEnabled Whether Issues should be enabled, otherwise null indicates to use GitLab default
* @param mergeRequestsEnabled Whether Merge Requests should be enabled, otherwise null indicates to use GitLab default
* @param wikiEnabled Whether a Wiki should be enabled, otherwise null indicates to use GitLab default
* @param snippetsEnabled Whether Snippets should be enabled, otherwise null indicates to use GitLab default
* @param visibility The visibility of the project, otherwise null indicates to use GitLab default
* @param visibilityLevel The visibility level of the project, otherwise null indicates to use GitLab default
* @param printingMergeRequestLinkEnabled Show link to create/view merge request when pushing from the command line
* @param importUrl The Import URL for the project, otherwise null
* @return the GitLab Project
* @throws GitLabApiException if any exception occurs
*/
public
Project
createProject
(
String
name
,
Integer
namespaceId
,
String
description
,
Boolean
issuesEnabled
,
Boolean
mergeRequestsEnabled
,
Boolean
wikiEnabled
,
Boolean
snippetsEnabled
,
Visibility
visibility
,
Integer
visibilityLevel
,
Boolean
printingMergeRequestLinkEnabled
,
String
importUrl
)
throws
GitLabApiException
{
if
(
isApiVersion
(
ApiVersion
.
V3
))
{
Boolean
isPublic
=
Visibility
.
PUBLIC
==
visibility
;
return
(
createProject
(
name
,
namespaceId
,
description
,
issuesEnabled
,
mergeRequestsEnabled
,
wikiEnabled
,
snippetsEnabled
,
isPublic
,
visibilityLevel
,
importUrl
));
}
if
(
name
==
null
||
name
.
trim
().
length
()
==
0
)
{
return
(
null
);
}
GitLabApiForm
formData
=
new
GitLabApiForm
()
.
withParam
(
"name"
,
name
,
true
)
.
withParam
(
"namespace_id"
,
namespaceId
)
.
withParam
(
"description"
,
description
)
.
withParam
(
"issues_enabled"
,
issuesEnabled
)
.
withParam
(
"merge_requests_enabled"
,
mergeRequestsEnabled
)
.
withParam
(
"wiki_enabled"
,
wikiEnabled
)
.
withParam
(
"snippets_enabled"
,
snippetsEnabled
)
.
withParam
(
"visibility_level"
,
visibilityLevel
)
.
withParam
(
"visibility"
,
visibility
)
.
withParam
(
"printing_merge_request_link_enabled"
,
printingMergeRequestLinkEnabled
)
.
withParam
(
"import_url"
,
importUrl
);
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"projects"
);
return
(
response
.
readEntity
(
Project
.
class
));
}
/**
* Creates a Project
*
...
...
@@ -741,6 +791,7 @@ public class ProjectApi extends AbstractApi implements Constants {
* requestAccessEnabled (optional) - Allow users to request member access
* repositoryStorage (optional) - Which storage shard the repository is on. Available only to admins
* approvalsBeforeMerge (optional) - How many approvers should approve merge request by default
* printingMergeRequestLinkEnabled (optional) - Show link to create/view merge request when pushing from the command line
*
* NOTE: The following parameters specified by the GitLab API edit project are not supported:
* import_url
...
...
@@ -786,7 +837,8 @@ public class ProjectApi extends AbstractApi implements Constants {
.
withParam
(
"lfs_enabled"
,
project
.
getLfsEnabled
())
.
withParam
(
"request_access_enabled"
,
project
.
getRequestAccessEnabled
())
.
withParam
(
"repository_storage"
,
project
.
getRepositoryStorage
())
.
withParam
(
"approvals_before_merge"
,
project
.
getApprovalsBeforeMerge
());
.
withParam
(
"approvals_before_merge"
,
project
.
getApprovalsBeforeMerge
())
.
withParam
(
"printing_merge_request_link_enabled"
,
project
.
getPrintingMergeRequestLinkEnabled
());
if
(
isApiVersion
(
ApiVersion
.
V3
))
{
formData
.
withParam
(
"visibility_level"
,
project
.
getVisibilityLevel
());
...
...
src/main/java/org/gitlab4j/api/models/Project.java
View file @
d03c2d21
...
...
@@ -55,6 +55,7 @@ public class Project {
private
Boolean
wallEnabled
;
private
String
webUrl
;
private
Boolean
wikiEnabled
;
private
Boolean
printingMergeRequestLinkEnabled
;
public
Integer
getApprovalsBeforeMerge
()
{
return
approvalsBeforeMerge
;
...
...
@@ -466,6 +467,11 @@ public class Project {
this
.
tagList
=
tagList
;
}
public
Project
withTagList
(
List
<
String
>
tagList
)
{
this
.
tagList
=
tagList
;
return
(
this
);
}
public
Visibility
getVisibility
()
{
return
visibility
;
}
...
...
@@ -500,6 +506,11 @@ public class Project {
this
.
wallEnabled
=
wallEnabled
;
}
public
Project
withWallEnabled
(
Boolean
wallEnabled
)
{
this
.
wallEnabled
=
wallEnabled
;
return
(
this
);
}
public
String
getWebUrl
()
{
return
webUrl
;
}
...
...
@@ -508,6 +519,11 @@ public class Project {
this
.
webUrl
=
webUrl
;
}
public
Project
withWebUrl
(
String
webUrl
)
{
this
.
webUrl
=
webUrl
;
return
(
this
);
}
public
Boolean
getWikiEnabled
()
{
return
wikiEnabled
;
}
...
...
@@ -521,6 +537,19 @@ public class Project {
return
(
this
);
}
public
Boolean
getPrintingMergeRequestLinkEnabled
()
{
return
printingMergeRequestLinkEnabled
;
}
public
void
setPrintingMergeRequestLinkEnabled
(
Boolean
printingMergeRequestLinkEnabled
)
{
this
.
printingMergeRequestLinkEnabled
=
printingMergeRequestLinkEnabled
;
}
public
Project
withPrintingMergeRequestLinkEnabled
(
Boolean
printingMergeRequestLinkEnabled
)
{
this
.
printingMergeRequestLinkEnabled
=
printingMergeRequestLinkEnabled
;
return
(
this
);
}
public
static
final
boolean
isValid
(
Project
project
)
{
return
(
project
!=
null
&&
project
.
getId
()
!=
null
);
}
...
...
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