Skip to content

Commit 3d327e3

Browse files
authored
Merge pull request #733 from kvakos/master
added squashOption to Project
2 parents dbee5ba + 82b5695 commit 3d327e3

File tree

4 files changed

+47
-4
lines changed

4 files changed

+47
-4
lines changed

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,29 @@ public String toString() {
850850
}
851851
}
852852

853+
/** Enum for the build_git_strategy of the project instance. */
854+
enum SquashOption {
855+
856+
NEVER, ALWAYS, DEFAULT_ON, DEFAULT_OFF;
857+
858+
private static JacksonJsonEnumHelper<SquashOption> enumHelper = new JacksonJsonEnumHelper<>(SquashOption.class);
859+
860+
@JsonCreator
861+
public static SquashOption forValue(String value) {
862+
return enumHelper.forValue(value);
863+
}
864+
865+
@JsonValue
866+
public String toValue() {
867+
return (enumHelper.toString(this));
868+
}
869+
870+
@Override
871+
public String toString() {
872+
return (enumHelper.toString(this));
873+
}
874+
}
875+
853876
/** Enum for the build_git_strategy of the project instance. */
854877
enum BuildGitStrategy {
855878

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,8 @@ public ImportStatus startImport(Object namespaceIdOrPath, File exportFile, Strin
238238
.withParam("initialize_with_readme", overrideParams.getInitializeWithReadme())
239239
.withParam("packages_enabled", overrideParams.getPackagesEnabled())
240240
.withParam("build_git_strategy", overrideParams.getBuildGitStrategy())
241-
.withParam("build_coverage_regex", overrideParams.getBuildCoverageRegex());
241+
.withParam("build_coverage_regex", overrideParams.getBuildCoverageRegex())
242+
.withParam("squash_option", overrideParams.getSquashOption());
242243
}
243244

244245
Response response = upload(Response.Status.CREATED, "file", exportFile, null, formData, url);

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ public Project createProject(String projectName) throws GitLabApiException {
924924
* @throws GitLabApiException if any exception occurs
925925
*/
926926
public Project createProject(String name, String path) throws GitLabApiException {
927-
927+
928928
if ((name == null || name.trim().isEmpty()) && (path == null || path.trim().isEmpty())) {
929929
throw new RuntimeException("Either name or path must be specified.");
930930
}
@@ -976,6 +976,7 @@ public Project createProject(Project project) throws GitLabApiException {
976976
* packagesEnabled (optional) - Enable or disable mvn packages repository feature
977977
* buildGitStrategy (optional) - set the build git strategy
978978
* buildCoverageRegex (optional) - set build coverage regex
979+
* squashOption (optional) - set squash option for merge requests
979980
*
980981
* @param project the Project instance with the configuration for the new project
981982
* @param importUrl the URL to import the repository from
@@ -1024,7 +1025,8 @@ public Project createProject(Project project, String importUrl) throws GitLabApi
10241025
.withParam("build_git_strategy", project.getBuildGitStrategy())
10251026
.withParam("build_coverage_regex", project.getBuildCoverageRegex())
10261027
.withParam("suggestion_commit_message", project.getSuggestionCommitMessage())
1027-
.withParam("remove_source_branch_after_merge", project.getRemoveSourceBranchAfterMerge());
1028+
.withParam("remove_source_branch_after_merge", project.getRemoveSourceBranchAfterMerge())
1029+
.withParam("squash_option", project.getSquashOption());
10281030

10291031
Namespace namespace = project.getNamespace();
10301032
if (namespace != null && namespace.getId() != null) {
@@ -1222,6 +1224,7 @@ public Project createProject(String name, Integer namespaceId, String descriptio
12221224
* packagesEnabled (optional) - Enable or disable mvn packages repository feature
12231225
* buildGitStrategy (optional) - set the build git strategy
12241226
* buildCoverageRegex (optional) - set build coverage regex
1227+
* squashOption (optional) - set squash option for merge requests
12251228
*
12261229
* NOTE: The following parameters specified by the GitLab API edit project are not supported:
12271230
* import_url
@@ -1270,7 +1273,8 @@ public Project updateProject(Project project) throws GitLabApiException {
12701273
.withParam("build_coverage_regex", project.getBuildCoverageRegex())
12711274
.withParam("merge_method", project.getMergeMethod())
12721275
.withParam("suggestion_commit_message", project.getSuggestionCommitMessage())
1273-
.withParam("remove_source_branch_after_merge", project.getRemoveSourceBranchAfterMerge());
1276+
.withParam("remove_source_branch_after_merge", project.getRemoveSourceBranchAfterMerge())
1277+
.withParam("squash_option", project.getSquashOption());
12741278

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

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import org.gitlab4j.api.Constants.AutoDevopsDeployStrategy;
88
import org.gitlab4j.api.Constants.BuildGitStrategy;
9+
import org.gitlab4j.api.Constants.SquashOption;
910
import org.gitlab4j.api.ProjectLicense;
1011
import org.gitlab4j.api.models.ImportStatus.Status;
1112
import org.gitlab4j.api.utils.JacksonJson;
@@ -105,6 +106,7 @@ public String toString() {
105106
private Boolean autocloseReferencedIssues;
106107
private Boolean emailsDisabled;
107108
private String suggestionCommitMessage;
109+
private SquashOption squashOption;
108110

109111
@JsonSerialize(using = JacksonJson.DateOnlySerializer.class)
110112
private Date markedForDeletionOn;
@@ -842,4 +844,17 @@ public Project withSuggestionCommitMessage(String suggestionCommitMessage) {
842844
public void setSuggestionCommitMessage(String suggestionCommitMessage) {
843845
this.suggestionCommitMessage = suggestionCommitMessage;
844846
}
847+
848+
public SquashOption getSquashOption() {
849+
return squashOption;
850+
}
851+
852+
public void setSquashOption(SquashOption squashOption) {
853+
this.squashOption = squashOption;
854+
}
855+
856+
public Project withSquashOption(SquashOption squashOption) {
857+
this.squashOption = squashOption;
858+
return this;
859+
}
845860
}

0 commit comments

Comments
 (0)