Unverified Commit b60c045d authored by Jérémie Bresson's avatar Jérémie Bresson Committed by GitHub
Browse files

Update project model (#1088)

Fixes #1080
parent d321fe52
...@@ -1333,6 +1333,9 @@ public class ProjectApi extends AbstractApi implements Constants { ...@@ -1333,6 +1333,9 @@ public class ProjectApi extends AbstractApi implements Constants {
Visibility visibility = (project.getVisibility() != null ? project.getVisibility() : Visibility visibility = (project.getVisibility() != null ? project.getVisibility() :
project.getPublic() == Boolean.TRUE ? Visibility.PUBLIC : null); project.getPublic() == Boolean.TRUE ? Visibility.PUBLIC : null);
formData.withParam("visibility", visibility); formData.withParam("visibility", visibility);
formData.withParam("issue_branch_template", project.getIssueBranchTemplate());
formData.withParam("merge_commit_template", project.getMergeCommitTemplate());
formData.withParam("squash_commit_template", project.getSquashCommitTemplate());
if (project.getTagList() != null && !project.getTagList().isEmpty()) { if (project.getTagList() != null && !project.getTagList().isEmpty()) {
formData.withParam("tag_list", String.join(",", project.getTagList())); formData.withParam("tag_list", String.join(",", project.getTagList()));
......
...@@ -12,6 +12,7 @@ public class Namespace implements Serializable { ...@@ -12,6 +12,7 @@ public class Namespace implements Serializable {
private String path; private String path;
private String kind; private String kind;
private String fullPath; private String fullPath;
private Long parentId;
private String avatarUrl; private String avatarUrl;
private String webUrl; private String webUrl;
...@@ -55,6 +56,14 @@ public class Namespace implements Serializable { ...@@ -55,6 +56,14 @@ public class Namespace implements Serializable {
this.fullPath = fullPath; this.fullPath = fullPath;
} }
public Long getParentId() {
return parentId;
}
public void setParentId(Long parentId) {
this.parentId = parentId;
}
public Namespace withId(Long id) { public Namespace withId(Long id) {
this.id = id; this.id = id;
return this; return this;
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
package org.gitlab4j.api.models; package org.gitlab4j.api.models;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.annotation.JsonValue;
import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.gitlab4j.api.Constants.AutoDevopsDeployStrategy; import org.gitlab4j.api.Constants.AutoDevopsDeployStrategy;
...@@ -15,6 +17,7 @@ import org.gitlab4j.api.utils.JacksonJsonEnumHelper; ...@@ -15,6 +17,7 @@ import org.gitlab4j.api.utils.JacksonJsonEnumHelper;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
public class Project implements Serializable { public class Project implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -113,6 +116,11 @@ public class Project implements Serializable { ...@@ -113,6 +116,11 @@ public class Project implements Serializable {
private Boolean emailsDisabled; private Boolean emailsDisabled;
private String suggestionCommitMessage; private String suggestionCommitMessage;
private SquashOption squashOption; private SquashOption squashOption;
private String mergeCommitTemplate;
private String squashCommitTemplate;
private String issueBranchTemplate;
@JsonProperty("_links")
private Map<String, String> links;
@JsonSerialize(using = JacksonJson.DateOnlySerializer.class) @JsonSerialize(using = JacksonJson.DateOnlySerializer.class)
private Date markedForDeletionOn; private Date markedForDeletionOn;
...@@ -917,4 +925,45 @@ public class Project implements Serializable { ...@@ -917,4 +925,45 @@ public class Project implements Serializable {
this.squashOption = squashOption; this.squashOption = squashOption;
return this; return this;
} }
public String getMergeCommitTemplate() {
return mergeCommitTemplate;
}
public void setMergeCommitTemplate(String mergeCommitTemplate) {
this.mergeCommitTemplate = mergeCommitTemplate;
}
public String getSquashCommitTemplate() {
return squashCommitTemplate;
}
public void setSquashCommitTemplate(String squashCommitTemplate) {
this.squashCommitTemplate = squashCommitTemplate;
}
public String getIssueBranchTemplate() {
return issueBranchTemplate;
}
public void setIssueBranchTemplate(String issueBranchTemplate) {
this.issueBranchTemplate = issueBranchTemplate;
}
public Map<String, String> getLinks() {
return links;
}
public void setLinks(Map<String, String> links) {
this.links = links;
}
@JsonIgnore
public String getLinkByName(String name) {
if (links == null || links.isEmpty()) {
return (null);
}
return (links.get(name));
}
} }
{ {
"id": 3, "id" : 3,
"default_branch": "master", "description" : "Some description",
"public": false, "name" : "Diaspora Project Site",
"visibility": "private", "name_with_namespace" : "Diaspora / Diaspora Project Site",
"ssh_url_to_repo": "git@example.com:diaspora/diaspora-project-site.git", "path" : "diaspora-project-site",
"http_url_to_repo": "http://example.com/diaspora/diaspora-project-site.git", "path_with_namespace" : "diaspora/diaspora-project-site",
"web_url": "http://example.com/diaspora/diaspora-project-site", "created_at" : "2013-09-30T13:46:02Z",
"readme_url": "http://example.com/diaspora/diaspora-project-site/blob/master/README.md", "default_branch" : "master",
"tag_list": [ "tag_list" : [ "example", "disapora project" ],
"example", "topics" : [ ],
"disapora project" "ssh_url_to_repo" : "git@example.com:diaspora/diaspora-project-site.git",
], "http_url_to_repo" : "http://example.com/diaspora/diaspora-project-site.git",
"owner": { "web_url" : "http://example.com/diaspora/diaspora-project-site",
"id": 3, "readme_url" : "http://example.com/diaspora/diaspora-project-site/blob/master/README.md",
"name": "Diaspora", "forks_count" : 0,
"created_at": "2013-09-30T13:46:02Z" "avatar_url" : "http://example.com/uploads/project/avatar/3/uploads/avatar.png",
"star_count" : 0,
"last_activity_at" : "2013-09-30T13:46:02Z",
"namespace" : {
"id" : 3,
"name" : "Diaspora",
"path" : "diaspora",
"kind" : "group",
"full_path" : "diaspora",
"parent_id" : 4,
"avatar_url" : "http://localhost:3000/uploads/group/avatar/3/foo.jpg",
"web_url" : "http://localhost:3000/groups/diaspora"
}, },
"name": "Diaspora Project Site", "_links" : {
"name_with_namespace": "Diaspora / Diaspora Project Site", "self" : "https://example.com/api/v4/projects/3",
"path": "diaspora-project-site", "issues" : "https://example.com/api/v4/projects/3/issues",
"path_with_namespace": "diaspora/diaspora-project-site", "merge_requests" : "https://example.com/api/v4/projects/3/merge_requests",
"issues_enabled": true, "repo_branches" : "https://example.com/api/v4/projects/3/repository/branches",
"open_issues_count": 1, "labels" : "https://example.com/api/v4/projects/3/labels",
"merge_requests_enabled": true, "events" : "https://example.com/api/v4/projects/3/events",
"jobs_enabled": true, "members" : "https://example.com/api/v4/projects/3/members",
"wiki_enabled": true, "cluster_agents" : "https://example.com/api/v4/projects/3/cluster_agents"
"snippets_enabled": false,
"can_create_merge_request_in": true,
"resolve_outdated_diff_discussions": false,
"container_registry_enabled": false,
"created_at": "2013-09-30T13:46:02Z",
"last_activity_at": "2013-09-30T13:46:02Z",
"creator_id": 3,
"namespace": {
"id": 3,
"name": "Diaspora",
"path": "diaspora",
"kind": "group",
"full_path": "diaspora",
"avatar_url": "http://localhost:3000/uploads/group/avatar/3/foo.jpg",
"web_url": "http://localhost:3000/groups/diaspora"
}, },
"import_status": "none", "packages_enabled" : true,
"permissions": { "empty_repo" : false,
"project_access": { "archived" : false,
"access_level": 10, "visibility" : "private",
"notification_level": 3 "owner" : {
}, "id" : 3,
"group_access": { "username" : "user1234",
"access_level": 50, "name" : "Diaspora",
"notification_level": 3 "state" : "active",
"avatar_url" : "https://secure.gravatar.com/avatar/9b7126c28ab977c4c4a351df3a1d1d24?s=80&d=identicon",
"web_url" : "https://example.com/user1234",
"created_at" : "2013-09-30T13:46:02Z"
},
"resolve_outdated_diff_discussions" : false,
"issues_enabled" : true,
"merge_requests_enabled" : true,
"wiki_enabled" : true,
"jobs_enabled" : true,
"snippets_enabled" : false,
"container_registry_enabled" : false,
"can_create_merge_request_in" : true,
"emails_disabled" : false,
"shared_runners_enabled" : true,
"lfs_enabled" : true,
"creator_id" : 3,
"open_issues_count" : 1,
"ci_default_git_depth" : 50,
"ci_forward_deployment_enabled" : true,
"build_git_strategy" : "fetch",
"runners_token" : "b8bc4a7a29eb76ea83cf79e4908c2b",
"auto_devops_enabled" : true,
"auto_devops_deploy_strategy" : "continuous",
"ci_config_path" : "",
"public_jobs" : true,
"shared_with_groups" : [ {
"group_id" : 4,
"group_name" : "Twitter",
"group_full_path" : "twitter",
"group_access_level" : 30,
"expires_at" : "2023-11-19"
}, {
"group_id" : 3,
"group_name" : "Gitlab Org",
"group_full_path" : "gitlab-org",
"group_access_level" : 10,
"expires_at" : "2023-11-19"
} ],
"only_allow_merge_if_pipeline_succeeds" : false,
"allow_merge_on_skipped_pipeline" : true,
"request_access_enabled" : false,
"only_allow_merge_if_all_discussions_are_resolved" : false,
"remove_source_branch_after_merge" : false,
"printing_merge_request_link_enabled" : true,
"merge_method" : "merge",
"squash_option" : "default_off",
"suggestion_commit_message": "Apply suggestions",
"merge_commit_template": "Merge branch '%{source_branch}' into '%{target_branch}'",
"squash_commit_template": "Commit %{title}",
"issue_branch_template" : "issue-%{id}",
"autoclose_referenced_issues" : true,
"permissions" : {
"project_access" : {
"access_level" : 10,
"notification_level" : 3
} }
}, },
"archived": false, "public" : false,
"avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png", "license_url" : "http://example.com/diaspora/diaspora-client/blob/master/LICENSE",
"license_url": "http://example.com/diaspora/diaspora-client/blob/master/LICENSE", "license" : {
"license": { "key" : "lgpl-3.0",
"key": "lgpl-3.0", "name" : "GNU Lesser General Public License v3.0",
"name": "GNU Lesser General Public License v3.0", "nickname" : "GNU LGPLv3",
"nickname": "GNU LGPLv3", "html_url" : "http://choosealicense.com/licenses/lgpl-3.0/",
"html_url": "http://choosealicense.com/licenses/lgpl-3.0/", "source_url" : "http://www.gnu.org/licenses/lgpl-3.0.txt"
"source_url": "http://www.gnu.org/licenses/lgpl-3.0.txt"
}, },
"shared_runners_enabled": true, "repository_storage" : "default",
"forks_count": 0, "approvals_before_merge" : 0,
"star_count": 0, "marked_for_deletion_on" : "2020-04-03",
"runners_token": "b8bc4a7a29eb76ea83cf79e4908c2b", "statistics" : {
"ci_default_git_depth": 50, "commit_count" : 37,
"public_jobs": true, "storage_size" : 1038090,
"shared_with_groups": [ "repository_size" : 1038090,
{ "wiki_size" : 0,
"group_id": 4, "lfs_objects_size" : 0,
"group_name": "Twitter", "job_artifacts_size" : 0,
"group_full_path": "twitter", "packages_size" : 0
"group_access_level": 30,
"expires_at": "2023-11-19"
},
{
"group_id": 3,
"group_name": "Gitlab Org",
"group_full_path": "gitlab-org",
"group_access_level": 10,
"expires_at": "2023-11-19"
}
],
"repository_storage": "default",
"only_allow_merge_if_pipeline_succeeds": false,
"only_allow_merge_if_all_discussions_are_resolved": false,
"remove_source_branch_after_merge": false,
"request_access_enabled": false,
"merge_method": "merge",
"auto_devops_enabled": true,
"auto_devops_deploy_strategy": "continuous",
"approvals_before_merge": 0,
"packages_enabled": true,
"autoclose_referenced_issues": true,
"marked_for_deletion_on": "2020-04-03",
"statistics": {
"commit_count": 37,
"storage_size": 1038090,
"repository_size": 1038090,
"wiki_size": 0,
"lfs_objects_size": 0,
"job_artifacts_size": 0,
"packages_size": 0
}, },
"custom_attributes": [] "custom_attributes" : [ ]
} }
\ 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