Class GithubGraphQLService
java.lang.Object
edu.ucsb.cs156.frontiers.services.GithubGraphQLService
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionGithubGraphQLService(org.springframework.web.client.RestClient.Builder builder, JwtService jwtService, org.springframework.data.auditing.DateTimeProvider dateTimeProvider, com.fasterxml.jackson.databind.ObjectMapper jacksonObjectMapper, CommitRepository commitRepository, BranchRepository branchRepository) -
Method Summary
Modifier and TypeMethodDescriptionassertBranchesExist(Course course, List<BranchId> branches) getDefaultBranchName(Course course, String owner, String repo) Retrieves the name of the default branch for a given GitHub repository.getMostRecentCommitSha(Course course, BranchId branch) loadCommitHistory(Course course, BranchId branch) Loads the commit history for a specified repository branch.
-
Constructor Details
-
GithubGraphQLService
public GithubGraphQLService(org.springframework.web.client.RestClient.Builder builder, JwtService jwtService, org.springframework.data.auditing.DateTimeProvider dateTimeProvider, com.fasterxml.jackson.databind.ObjectMapper jacksonObjectMapper, CommitRepository commitRepository, BranchRepository branchRepository)
-
-
Method Details
-
getDefaultBranchName
public String getDefaultBranchName(Course course, String owner, String repo) throws com.fasterxml.jackson.core.JsonProcessingException, NoSuchAlgorithmException, InvalidKeySpecException, NoLinkedOrganizationException Retrieves the name of the default branch for a given GitHub repository.- Parameters:
owner- The owner (username or organization) of the repository.repo- The name of the repository.- Returns:
- A Mono emitting the default branch name, or an empty Mono if not found.
- Throws:
com.fasterxml.jackson.core.JsonProcessingExceptionNoSuchAlgorithmExceptionInvalidKeySpecExceptionNoLinkedOrganizationException
-
getCommits
public String getCommits(Course course, String owner, String repo, String branch, int first, String after) throws com.fasterxml.jackson.core.JsonProcessingException, NoSuchAlgorithmException, InvalidKeySpecException, NoLinkedOrganizationException - Throws:
com.fasterxml.jackson.core.JsonProcessingExceptionNoSuchAlgorithmExceptionInvalidKeySpecExceptionNoLinkedOrganizationException
-
loadCommitHistory
@Transactional(propagation=NESTED) public Branch loadCommitHistory(Course course, BranchId branch) throws Exception Loads the commit history for a specified repository branch. The method retrieves information about the branch from the database, determines if the branch information is up to date, and updates the commit history if necessary by fetching data from GitHub. If the branch does not exist in the database, it is created.- Parameters:
course- the course to be authenticated againstbranch- the identifier of the branch to load commit history for- Returns:
- the
Branchobject representing the branch with its latest commit history information - Throws:
Exception- if an error occurs while loading or updating the commit history
-
getMostRecentCommitSha
- Throws:
Exception
-
assertBranchesExist
public Map<BranchId,GithubGraphQLService.ValidationStatus> assertBranchesExist(Course course, List<BranchId> branches) throws Exception - Throws:
Exception
-