Skip to content

Commit d03c2d2

Browse files
committed
Added support for printing_merge_request_link_enabled when creating and updating a project (#124).
1 parent 586cc89 commit d03c2d2

File tree

2 files changed

+83
-2
lines changed

2 files changed

+83
-2
lines changed

src/main/java/org/gitlab4j/api/ProjectApi.java

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,7 @@ public Project createProject(Project project) throws GitLabApiException {
567567
* requestAccessEnabled (optional) - Allow users to request member access
568568
* repositoryStorage (optional) - Which storage shard the repository is on. Available only to admins
569569
* approvalsBeforeMerge (optional) - How many approvers should approve merge request by default
570+
* printingMergeRequestLinkEnabled (optional) - Show link to create/view merge request when pushing from the command line
570571
*
571572
* @param project the Project instance with the configuration for the new project
572573
* @param importUrl the URL to import the repository from
@@ -606,7 +607,8 @@ public Project createProject(Project project, String importUrl) throws GitLabApi
606607
.withParam("request_access_enabled", project.getRequestAccessEnabled())
607608
.withParam("repository_storage", project.getRepositoryStorage())
608609
.withParam("approvals_before_merge", project.getApprovalsBeforeMerge())
609-
.withParam("import_url", importUrl);
610+
.withParam("import_url", importUrl)
611+
.withParam("printing_merge_request_link_enabled", project.getPrintingMergeRequestLinkEnabled());
610612

611613
if (isApiVersion(ApiVersion.V3)) {
612614
boolean isPublic = (project.getPublic() != null ? project.getPublic() : project.getVisibility() == Visibility.PUBLIC);
@@ -670,6 +672,54 @@ public Project createProject(String name, Integer namespaceId, String descriptio
670672
return (response.readEntity(Project.class));
671673
}
672674

675+
/**
676+
* Creates a Project
677+
*
678+
* @param name The name of the project
679+
* @param namespaceId The Namespace for the new project, otherwise null indicates to use the GitLab default (user)
680+
* @param description A description for the project, null otherwise
681+
* @param issuesEnabled Whether Issues should be enabled, otherwise null indicates to use GitLab default
682+
* @param mergeRequestsEnabled Whether Merge Requests should be enabled, otherwise null indicates to use GitLab default
683+
* @param wikiEnabled Whether a Uncyclo should be enabled, otherwise null indicates to use GitLab default
684+
* @param snippetsEnabled Whether Snippets should be enabled, otherwise null indicates to use GitLab default
685+
* @param visibility The visibility of the project, otherwise null indicates to use GitLab default
686+
* @param visibilityLevel The visibility level of the project, otherwise null indicates to use GitLab default
687+
* @param printingMergeRequestLinkEnabled Show link to create/view merge request when pushing from the command line
688+
* @param importUrl The Import URL for the project, otherwise null
689+
* @return the GitLab Project
690+
* @throws GitLabApiException if any exception occurs
691+
*/
692+
public Project createProject(String name, Integer namespaceId, String description, Boolean issuesEnabled, Boolean mergeRequestsEnabled,
693+
Boolean wikiEnabled, Boolean snippetsEnabled, Visibility visibility, Integer visibilityLevel,
694+
Boolean printingMergeRequestLinkEnabled, String importUrl) throws GitLabApiException {
695+
696+
if (isApiVersion(ApiVersion.V3)) {
697+
Boolean isPublic = Visibility.PUBLIC == visibility;
698+
return (createProject(name, namespaceId, description, issuesEnabled, mergeRequestsEnabled,
699+
wikiEnabled, snippetsEnabled, isPublic, visibilityLevel, importUrl));
700+
}
701+
702+
if (name == null || name.trim().length() == 0) {
703+
return (null);
704+
}
705+
706+
GitLabApiForm formData = new GitLabApiForm()
707+
.withParam("name", name, true)
708+
.withParam("namespace_id", namespaceId)
709+
.withParam("description", description)
710+
.withParam("issues_enabled", issuesEnabled)
711+
.withParam("merge_requests_enabled", mergeRequestsEnabled)
712+
.withParam("wiki_enabled", wikiEnabled)
713+
.withParam("snippets_enabled", snippetsEnabled)
714+
.withParam("visibility_level", visibilityLevel)
715+
.withParam("visibility", visibility)
716+
.withParam("printing_merge_request_link_enabled", printingMergeRequestLinkEnabled)
717+
.withParam("import_url", importUrl);
718+
719+
Response response = post(Response.Status.CREATED, formData, "projects");
720+
return (response.readEntity(Project.class));
721+
}
722+
673723
/**
674724
* Creates a Project
675725
*
@@ -741,6 +791,7 @@ public Project createProject(String name, Integer namespaceId, String descriptio
741791
* requestAccessEnabled (optional) - Allow users to request member access
742792
* repositoryStorage (optional) - Which storage shard the repository is on. Available only to admins
743793
* approvalsBeforeMerge (optional) - How many approvers should approve merge request by default
794+
* printingMergeRequestLinkEnabled (optional) - Show link to create/view merge request when pushing from the command line
744795
*
745796
* NOTE: The following parameters specified by the GitLab API edit project are not supported:
746797
* import_url
@@ -786,7 +837,8 @@ public Project updateProject(Project project) throws GitLabApiException {
786837
.withParam("lfs_enabled", project.getLfsEnabled())
787838
.withParam("request_access_enabled", project.getRequestAccessEnabled())
788839
.withParam("repository_storage", project.getRepositoryStorage())
789-
.withParam("approvals_before_merge", project.getApprovalsBeforeMerge());
840+
.withParam("approvals_before_merge", project.getApprovalsBeforeMerge())
841+
.withParam("printing_merge_request_link_enabled", project.getPrintingMergeRequestLinkEnabled());
790842

791843
if (isApiVersion(ApiVersion.V3)) {
792844
formData.withParam("visibility_level", project.getVisibilityLevel());

src/main/java/org/gitlab4j/api/models/Project.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public class Project {
5555
private Boolean wallEnabled;
5656
private String webUrl;
5757
private Boolean wikiEnabled;
58+
private Boolean printingMergeRequestLinkEnabled;
5859

5960
public Integer getApprovalsBeforeMerge() {
6061
return approvalsBeforeMerge;
@@ -466,6 +467,11 @@ public void setTagList(List<String> tagList) {
466467
this.tagList = tagList;
467468
}
468469

470+
public Project withTagList(List<String> tagList) {
471+
this.tagList = tagList;
472+
return (this);
473+
}
474+
469475
public Visibility getVisibility() {
470476
return visibility;
471477
}
@@ -500,6 +506,11 @@ public void setWallEnabled(Boolean wallEnabled) {
500506
this.wallEnabled = wallEnabled;
501507
}
502508

509+
public Project withWallEnabled(Boolean wallEnabled) {
510+
this.wallEnabled = wallEnabled;
511+
return (this);
512+
}
513+
503514
public String getWebUrl() {
504515
return webUrl;
505516
}
@@ -508,6 +519,11 @@ public void setWebUrl(String webUrl) {
508519
this.webUrl = webUrl;
509520
}
510521

522+
public Project withWebUrl(String webUrl) {
523+
this.webUrl = webUrl;
524+
return (this);
525+
}
526+
511527
public Boolean getUncycloEnabled() {
512528
return wikiEnabled;
513529
}
@@ -521,6 +537,19 @@ public Project withUncycloEnabled(boolean wikiEnabled) {
521537
return (this);
522538
}
523539

540+
public Boolean getPrintingMergeRequestLinkEnabled() {
541+
return printingMergeRequestLinkEnabled;
542+
}
543+
544+
public void setPrintingMergeRequestLinkEnabled(Boolean printingMergeRequestLinkEnabled) {
545+
this.printingMergeRequestLinkEnabled = printingMergeRequestLinkEnabled;
546+
}
547+
548+
public Project withPrintingMergeRequestLinkEnabled(Boolean printingMergeRequestLinkEnabled) {
549+
this.printingMergeRequestLinkEnabled = printingMergeRequestLinkEnabled;
550+
return (this);
551+
}
552+
524553
public static final boolean isValid(Project project) {
525554
return (project != null && project.getId() != null);
526555
}

0 commit comments

Comments
 (0)