Skip to content

Commit 69d56d1

Browse files
authored
Merge pull request #101 from mcanoy/commits-limit
filter commits πŸ—„οΈ πŸ—„οΈ πŸ—„οΈ πŸ—„οΈ
2 parents 4842590 + 2451e5d commit 69d56d1

File tree

5 files changed

+15
-6
lines changed

5 files changed

+15
-6
lines changed

β€ŽREADME.mdβ€Ž

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ Deployment template will read from the above secret and inject following env var
6161
| GITLAB_API_URL | https://acmegit.com | True |
6262
| DEPLOY_KEY | 0 | True |
6363

64+
### Commits
65+
66+
| Name | Example Value | Required |
67+
|------|---------------|----------|
68+
| COMMIT_FILTERED_EMAIL_LIST | [email protected],[email protected] | False |
69+
6470
### Config Resource
6571

6672
| Name | Example Value | Required |

β€Žsrc/main/java/com/redhat/labs/lodestar/service/ProjectService.javaβ€Ž

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.util.List;
44
import java.util.Optional;
5+
import java.util.stream.Collectors;
56

67
import javax.enterprise.context.ApplicationScoped;
78
import javax.inject.Inject;
@@ -33,6 +34,9 @@ public class ProjectService {
3334

3435
@ConfigProperty(name = "commit.page.size")
3536
int commitPageSize;
37+
38+
@ConfigProperty(name = "commit.filter.list")
39+
List<String> commitFilteredEmails;
3640

3741
// get a project - this could be a replaced by a direct call to the project via the path
3842
// but must consider changes to the path for special characters
@@ -142,7 +146,7 @@ public List<Commit> getCommitLog(String projectId) {
142146

143147
LOGGER.debug("total commits for project {} {}", projectId, page.size());
144148

145-
return page.getResults();
149+
return page.getResults().stream().filter(e -> !commitFilteredEmails.contains(e.getAuthorEmail())).collect(Collectors.toList());
146150
}
147151

148152
}

β€Žsrc/main/resources/application.propertiesβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ webhook.file=${WEBHOOK_FILE:/runtime/webhooks.yaml}
3131
webhook.default.token=${WEBHOOK_DEFAULT_TOKEN:tolkien}
3232
config.gitlab.ref=${CONFIG_GITLAB_REF:master}
3333
commit.page.size=100
34+
commit.filter.list=${COMMIT_FILTERED_EMAIL_LIST:[email protected]}
3435

3536
# engagements
3637
engagements.repository.id=${ENGAGEMENTS_REPOSITORY_ID:2}

β€Žsrc/test/java/com/redhat/labs/lodestar/resource/EngagementResourceTest.javaβ€Ž

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void testGetAllEngagementsSuccess() {
3737
}
3838

3939
@Test
40-
void tesetGetEngagementByNamespace() {
40+
void testGetEngagementByNamespace() {
4141
given()
4242
.pathParam("namespace", "top/dog/jello/tutti-frutti/iac")
4343
.when()
@@ -164,9 +164,7 @@ void testGetCommitsSuccess() {
164164
.get("/api/v1/engagements/customer/jello/lemon/commits")
165165
.then()
166166
.statusCode(200)
167-
.body(is("[{\"author_email\":\"[email protected]\",\"author_name\":\"bot\",\"authored_date\":\"2020-06-16T00:12:27.000+00:00\",\"committed_date\":\"2020-06-16T00:12:27.000+00:00\",\"id\":\"551eefc6e367aa2ad3c56bdd7229c7bc525d4f0c\","
168-
+ "\"message\":\"Auto-update generated files\",\"short_id\":\"551eefc6\",\"title\":\"Auto-update generated files\",\"web_url\":\"https://gitlab.example.com/store/jello/lemon/iac/-/commit/551eefc6e367aa2ad3c56bdd7229c7bc525d4f0c\"},"
169-
+ "{\"author_email\":\"[email protected]\",\"author_name\":\"Mitch Marner\",\"authored_date\":\"2020-06-16T00:12:18.000+00:00\",\"committed_date\":\"2020-06-16T00:12:18.000+00:00\","
167+
.body(is("[{\"author_email\":\"[email protected]\",\"author_name\":\"Mitch Marner\",\"authored_date\":\"2020-06-16T00:12:18.000+00:00\",\"committed_date\":\"2020-06-16T00:12:18.000+00:00\","
170168
+ "\"id\":\"5178ffab3566ac591af95c3383d1c5916de4a3a9\",\"message\":\"Update engagement.json\",\"short_id\":\"5178ffab\",\"title\":\"Update engagement.json\","
171169
+ "\"web_url\":\"https://gitlab.example.com/store/jello/lemon/iac/-/commit/5178ffab3566ac591af95c3383d1c5916de4a3a9\"},{\"author_email\":\"[email protected]\",\"author_name\":\"John Tavares\","
172170
+ "\"authored_date\":\"2020-06-11T16:46:19.000+00:00\",\"committed_date\":\"2020-06-11T16:46:19.000+00:00\",\"id\":\"7865570dc63b1463d9fb4d02bd09ff46d244e694\",\"message\":\"Update status.json\","

β€Žsrc/test/java/com/redhat/labs/lodestar/service/ProjectServiceTest.javaβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class ProjectServiceTest {
101101
@Test void getCommitsMultiPage() {
102102
List<Commit> commits = projectService.getCommitLog("multi/page/iac");
103103
assertNotNull(commits);
104-
assertEquals(8, commits.size());
104+
assertEquals(6, commits.size());
105105

106106
}
107107
}

0 commit comments

Comments
Β (0)