Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Expose repository_object_format via Project API #1125

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/main/java/org/gitlab4j/api/ProjectApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,7 @@ public Project createProject(Project project, String importUrl) throws GitLabApi
.withParam("build_git_strategy", project.getBuildGitStrategy())
.withParam("build_coverage_regex", project.getBuildCoverageRegex())
.withParam("ci_config_path", project.getCiConfigPath())
.withParam("repository_object_format", project.getRepositoryObjectFormat())
.withParam("suggestion_commit_message", project.getSuggestionCommitMessage())
.withParam("remove_source_branch_after_merge", project.getRemoveSourceBranchAfterMerge())
.withParam("squash_option", project.getSquashOption());
Expand Down Expand Up @@ -2254,7 +2255,7 @@ public ProjectHook addHook(Object projectIdOrPath, String url, boolean doPushEve
boolean doIssuesEvents, boolean doMergeRequestsEvents) throws GitLabApiException {
return addHook(projectIdOrPath, url, doPushEvents, doIssuesEvents, doMergeRequestsEvents, null);
}

/**
* Adds a hook to project.
* Convenience method for {@link #addHook(Object, String, ProjectHook, Boolean, String)}
Expand Down Expand Up @@ -4044,7 +4045,7 @@ public ProjectAccessToken createProjectAccessToken(Object projectIdOrPath, Strin
public ProjectAccessToken rotateProjectAccessToken(Object projectIdOrPath, Long tokenId) throws GitLabApiException {
return rotateProjectAccessToken(projectIdOrPath, tokenId, null);
}

/**
* Rotates the given project access token.
* The token is revoked and a new one which will expire in one week is created to replace it.
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/org/gitlab4j/api/models/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public String toString() {
private AutoDevopsDeployStrategy autoDevopsDeployStrategy;
private Boolean autocloseReferencedIssues;
private Boolean emailsDisabled;
private String repositoryObjectFormat;
private String suggestionCommitMessage;
private SquashOption squashOption;
private String mergeCommitTemplate;
Expand Down Expand Up @@ -900,6 +901,19 @@ public Project withEmailsDisabled(Boolean emailsDisabled) {
return this;
}

public String getRepositoryObjectFormat() {
return repositoryObjectFormat;
}

public void setRepositoryObjectFormat(String repositoryObjectFormat) {
this.repositoryObjectFormat = repositoryObjectFormat;
}

public Project withRepositoryObjectFormat(String repositoryObjectFormat) {
this.repositoryObjectFormat = repositoryObjectFormat;
return this;
}

public String getSuggestionCommitMessage() {
return this.suggestionCommitMessage;
}
Expand Down
4 changes: 3 additions & 1 deletion src/test/java/org/gitlab4j/api/TestProjectApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ public void testCreate() throws GitLabApiException {
.withMergeRequestsEnabled(true)
.withWikiEnabled(true)
.withSnippetsEnabled(true)
.withRepositoryObjectFormat("sha1")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I am not mistaken this test is using the GitLab installation started in Docker while the integration tests are running.

This version is very old and this test will fail.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... Is there any reference test that I could use for this new field?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pipeline in GitHub action is failing as expected:

Error:  Failures: 
Error:    TestProjectApi.testCreate:239 expected: <sha1> but was: <null>
[INFO] 
Error:  Tests run: 308, Failures: 1, Errors: 0, Skipped: 14

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some tests are using Mockito but this feels also wrong.
I started to experiment to use testcontainers to run a newer GitLab version (there is some work in a PR).

But I am wondering if we should not just Mock the GitLab server in order to run the unit-test quickly.

I would say that for now TestProjectApi.testCreate() remains unchanged and we merge your change.

.withVisibility(Visibility.PUBLIC)
.withTagList(Arrays.asList("tag1", "tag2"));

Expand All @@ -235,6 +236,7 @@ public void testCreate() throws GitLabApiException {
assertEquals(project.getMergeRequestsEnabled(), newProject.getMergeRequestsEnabled());
assertEquals(project.getWikiEnabled(), newProject.getWikiEnabled());
assertEquals(project.getSnippetsEnabled(), newProject.getSnippetsEnabled());
assertEquals(project.getRepositoryObjectFormat(), newProject.getRepositoryObjectFormat());
assertEquals(project.getTagList(), newProject.getTagList());
assertTrue(Visibility.PUBLIC == newProject.getVisibility() || Boolean.TRUE == newProject.getPublic());
}
Expand Down Expand Up @@ -323,7 +325,7 @@ else if (TEST_PROJECT_NAME_2.equals(project.getName()))
@Test
@Disabled("Required Gitlab version not less then 16.9")
public void testGetAvatar() throws GitLabApiException, IOException {

assumeTrue(testProject != null);

File avatarFile = new File("src/test/resources/org/gitlab4j/api", AVATAR_FILENAME);
Expand Down
Loading