From cd0a7396e11d39896f6c0eb4a2e9e92f3314461d Mon Sep 17 00:00:00 2001 From: George Andrinopoulos Date: Fri, 8 Nov 2024 09:17:10 +0200 Subject: [PATCH] CID-3144 Persist default branch name --- src/main/kotlin/net/leanix/githubagent/dto/RepositoryDto.kt | 1 + .../net/leanix/githubagent/services/GitHubGraphQLService.kt | 1 + src/main/resources/graphql/GetRepositories.graphql | 3 +++ .../leanix/githubagent/services/GitHubScanningServiceTest.kt | 3 +++ 4 files changed, 8 insertions(+) diff --git a/src/main/kotlin/net/leanix/githubagent/dto/RepositoryDto.kt b/src/main/kotlin/net/leanix/githubagent/dto/RepositoryDto.kt index 7b55086..ebf0ed2 100644 --- a/src/main/kotlin/net/leanix/githubagent/dto/RepositoryDto.kt +++ b/src/main/kotlin/net/leanix/githubagent/dto/RepositoryDto.kt @@ -8,6 +8,7 @@ data class RepositoryDto( val organizationName: String, val description: String?, val url: String, + val defaultBranch: String?, val archived: Boolean, val visibility: RepositoryVisibility, val updatedAt: String, diff --git a/src/main/kotlin/net/leanix/githubagent/services/GitHubGraphQLService.kt b/src/main/kotlin/net/leanix/githubagent/services/GitHubGraphQLService.kt index 4f8a9d0..73823e3 100644 --- a/src/main/kotlin/net/leanix/githubagent/services/GitHubGraphQLService.kt +++ b/src/main/kotlin/net/leanix/githubagent/services/GitHubGraphQLService.kt @@ -51,6 +51,7 @@ class GitHubGraphQLService( organizationName = it.owner.login, description = it.description, url = it.url, + defaultBranch = it.defaultBranchRef?.name, archived = it.isArchived, visibility = it.visibility, updatedAt = it.updatedAt, diff --git a/src/main/resources/graphql/GetRepositories.graphql b/src/main/resources/graphql/GetRepositories.graphql index 01bcbab..d07b223 100644 --- a/src/main/resources/graphql/GetRepositories.graphql +++ b/src/main/resources/graphql/GetRepositories.graphql @@ -10,6 +10,9 @@ query GetRepositories($pageCount: Int!, $cursor: String) { name description url + defaultBranchRef{ + name + } isArchived visibility updatedAt diff --git a/src/test/kotlin/net/leanix/githubagent/services/GitHubScanningServiceTest.kt b/src/test/kotlin/net/leanix/githubagent/services/GitHubScanningServiceTest.kt index befc9c7..c4d93fa 100644 --- a/src/test/kotlin/net/leanix/githubagent/services/GitHubScanningServiceTest.kt +++ b/src/test/kotlin/net/leanix/githubagent/services/GitHubScanningServiceTest.kt @@ -103,6 +103,7 @@ class GitHubScanningServiceTest { organizationName = "testOrg", description = "A test repository", url = "https://github.com/testRepo", + defaultBranch = "main", archived = false, visibility = RepositoryVisibility.PUBLIC, updatedAt = "2024-01-01T00:00:00Z", @@ -130,6 +131,7 @@ class GitHubScanningServiceTest { organizationName = "testOrg", description = "A test repository", url = "https://github.com/testRepo", + defaultBranch = "main", archived = false, visibility = RepositoryVisibility.PUBLIC, updatedAt = "2024-01-01T00:00:00Z", @@ -180,6 +182,7 @@ class GitHubScanningServiceTest { organizationName = "testOrg", description = "A test repository", url = "https://github.com/testRepo", + defaultBranch = "main", archived = false, visibility = RepositoryVisibility.PUBLIC, updatedAt = "2024-01-01T00:00:00Z",