Commit 8c58e930 authored by Greg Messner's avatar Greg Messner
Browse files

Mods to support merge_method (#174).

parent 80cd6055
...@@ -590,6 +590,7 @@ public class ProjectApi extends AbstractApi implements Constants { ...@@ -590,6 +590,7 @@ public class ProjectApi extends AbstractApi implements Constants {
* visibility (optional) - Limit by visibility public, internal, or private * visibility (optional) - Limit by visibility public, internal, or private
* visibilityLevel (optional) * visibilityLevel (optional)
* issuesEnabled (optional) - Enable issues for this project * issuesEnabled (optional) - Enable issues for this project
* mergeMethod (optional) - Set the merge method used
* mergeRequestsEnabled (optional) - Enable merge requests for this project * mergeRequestsEnabled (optional) - Enable merge requests for this project
* wikiEnabled (optional) - Enable wiki for this project * wikiEnabled (optional) - Enable wiki for this project
* snippetsEnabled (optional) - Enable snippets for this project * snippetsEnabled (optional) - Enable snippets for this project
...@@ -629,6 +630,7 @@ public class ProjectApi extends AbstractApi implements Constants { ...@@ -629,6 +630,7 @@ public class ProjectApi extends AbstractApi implements Constants {
.withParam("default_branch", project.getDefaultBranch()) .withParam("default_branch", project.getDefaultBranch())
.withParam("description", project.getDescription()) .withParam("description", project.getDescription())
.withParam("issues_enabled", project.getIssuesEnabled()) .withParam("issues_enabled", project.getIssuesEnabled())
.withParam("merge_method", project.getMergeMethod())
.withParam("merge_requests_enabled", project.getMergeRequestsEnabled()) .withParam("merge_requests_enabled", project.getMergeRequestsEnabled())
.withParam("jobs_enabled", project.getJobsEnabled()) .withParam("jobs_enabled", project.getJobsEnabled())
.withParam("wiki_enabled", project.getWikiEnabled()) .withParam("wiki_enabled", project.getWikiEnabled())
...@@ -822,6 +824,7 @@ public class ProjectApi extends AbstractApi implements Constants { ...@@ -822,6 +824,7 @@ public class ProjectApi extends AbstractApi implements Constants {
* description (optional) - short project description * description (optional) - short project description
* visibility (optional) - Limit by visibility public, internal, or private * visibility (optional) - Limit by visibility public, internal, or private
* issuesEnabled (optional) - Enable issues for this project * issuesEnabled (optional) - Enable issues for this project
* mergeMethod (optional) - Set the merge method used
* mergeRequestsEnabled (optional) - Enable merge requests for this project * mergeRequestsEnabled (optional) - Enable merge requests for this project
* wikiEnabled (optional) - Enable wiki for this project * wikiEnabled (optional) - Enable wiki for this project
* snippetsEnabled (optional) - Enable snippets for this project * snippetsEnabled (optional) - Enable snippets for this project
...@@ -869,6 +872,7 @@ public class ProjectApi extends AbstractApi implements Constants { ...@@ -869,6 +872,7 @@ public class ProjectApi extends AbstractApi implements Constants {
.withParam("default_branch", project.getDefaultBranch()) .withParam("default_branch", project.getDefaultBranch())
.withParam("description", project.getDescription()) .withParam("description", project.getDescription())
.withParam("issues_enabled", project.getIssuesEnabled()) .withParam("issues_enabled", project.getIssuesEnabled())
.withParam("merge_method", project.getMergeMethod())
.withParam("merge_requests_enabled", project.getMergeRequestsEnabled()) .withParam("merge_requests_enabled", project.getMergeRequestsEnabled())
.withParam("jobs_enabled", project.getJobsEnabled()) .withParam("jobs_enabled", project.getJobsEnabled())
.withParam("wiki_enabled", project.getWikiEnabled()) .withParam("wiki_enabled", project.getWikiEnabled())
......
...@@ -8,10 +8,38 @@ import javax.xml.bind.annotation.XmlAccessType; ...@@ -8,10 +8,38 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import org.gitlab4j.api.utils.JacksonJsonEnumHelper;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
@XmlRootElement @XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class Project { public class Project {
// Enum for the merge_method of the Project instance.
public enum MergeMethod {
MERGE, REBASE_MERGE, FF;
private static JacksonJsonEnumHelper<MergeMethod> enumHelper = new JacksonJsonEnumHelper<>(MergeMethod.class);
@JsonCreator
public static MergeMethod forValue(String value) {
return enumHelper.forValue(value);
}
@JsonValue
public String toValue() {
return (enumHelper.toString(this));
}
@Override
public String toString() {
return (enumHelper.toString(this));
}
}
private Integer approvalsBeforeMerge; private Integer approvalsBeforeMerge;
private Boolean archived; private Boolean archived;
private String avatarUrl; private String avatarUrl;
...@@ -29,6 +57,7 @@ public class Project { ...@@ -29,6 +57,7 @@ public class Project {
private Boolean jobsEnabled; private Boolean jobsEnabled;
private Date lastActivityAt; private Date lastActivityAt;
private Boolean lfsEnabled; private Boolean lfsEnabled;
private MergeMethod mergeMethod;
private Boolean mergeRequestsEnabled; private Boolean mergeRequestsEnabled;
private String name; private String name;
private Namespace namespace; private Namespace namespace;
...@@ -225,6 +254,19 @@ public class Project { ...@@ -225,6 +254,19 @@ public class Project {
return (this); return (this);
} }
public MergeMethod getMergeMethod() {
return mergeMethod;
}
public void setMergeMethod(MergeMethod mergeMethod) {
this.mergeMethod = mergeMethod;
}
public Project withMergeMethod(MergeMethod mergeMethod) {
this.mergeMethod = mergeMethod;
return (this);
}
public Boolean getMergeRequestsEnabled() { public Boolean getMergeRequestsEnabled() {
return mergeRequestsEnabled; return mergeRequestsEnabled;
} }
......
...@@ -58,6 +58,17 @@ public class JacksonJsonEnumHelper<E extends Enum<E>> { ...@@ -58,6 +58,17 @@ public class JacksonJsonEnumHelper<E extends Enum<E>> {
} }
} }
/**
* Add an enum that has a specialized name that does not fit the standard naming conventions.
*
* @param e the enum to add
* @param name the name for the enum
*/
public void addEnum(E e, String name) {
valuesMap.put(name, e);
namesMap.put(e, name);
}
@JsonCreator @JsonCreator
public E forValue(String value) { public E forValue(String value) {
return valuesMap.get(value); return valuesMap.get(value);
......
...@@ -66,5 +66,6 @@ ...@@ -66,5 +66,6 @@
"repository_storage": "default", "repository_storage": "default",
"only_allow_merge_if_pipeline_succeeds": false, "only_allow_merge_if_pipeline_succeeds": false,
"only_allow_merge_if_all_discussions_are_resolved": false, "only_allow_merge_if_all_discussions_are_resolved": false,
"request_access_enabled": false "request_access_enabled": false,
"merge_method": "merge"
} }
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment