Class RepositoryService
java.lang.Object
edu.ucsb.cs156.frontiers.services.RepositoryService
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionRepositoryService(JwtService jwtService, GithubTeamService githubTeamService, TeamRepository teamRepository, org.springframework.boot.web.client.RestTemplateBuilder restTemplateBuilder, com.fasterxml.jackson.databind.ObjectMapper mapper) -
Method Summary
Modifier and TypeMethodDescriptionvoidcreateStaffRepository(Course course, CourseStaff staff, String repoPrefix, Boolean isPrivate, RepositoryPermissions permissions) Creates a single staff repository if it doesn't already exist, and provisions access to the repository by that staff membervoidcreateStudentRepository(Course course, RosterStudent student, String repoPrefix, Boolean isPrivate, RepositoryPermissions permissions) Creates a single student repository if it doesn't already exist, and provisions access to the repository by that studentvoidcreateTeamRepository(Course course, Team team, String repoPrefix, Boolean isPrivate, RepositoryPermissions permissions, Integer orgId) Creates a GitHub repository for a team (student or staff), given only their team name.booleandeleteRepositoryIfEmpty(Course course, String repositoryName) Deletes a repository only when it is empty.getRepositoriesMatchingPrefix(Course course, String prefix) Lists repositories in the course GitHub organization whose names start with the provided prefix.booleanisRepositoryEmpty(Course course, String repositoryName) Returns true when the repository has no commits.
-
Constructor Details
-
RepositoryService
public RepositoryService(JwtService jwtService, GithubTeamService githubTeamService, TeamRepository teamRepository, org.springframework.boot.web.client.RestTemplateBuilder restTemplateBuilder, com.fasterxml.jackson.databind.ObjectMapper mapper)
-
-
Method Details
-
createStudentRepository
public void createStudentRepository(Course course, RosterStudent student, String repoPrefix, Boolean isPrivate, RepositoryPermissions permissions) throws NoSuchAlgorithmException, InvalidKeySpecException, com.fasterxml.jackson.core.JsonProcessingException Creates a single student repository if it doesn't already exist, and provisions access to the repository by that student- Parameters:
course- The Course in questionstudent- RosterStudent of the student the repository should be created forrepoPrefix- Name of the project or assignment. Used to title the repository, in the format repoPrefix-githubLoginisPrivate- Whether the repository is private or not- Throws:
NoSuchAlgorithmExceptionInvalidKeySpecExceptioncom.fasterxml.jackson.core.JsonProcessingException
-
createStaffRepository
public void createStaffRepository(Course course, CourseStaff staff, String repoPrefix, Boolean isPrivate, RepositoryPermissions permissions) throws NoSuchAlgorithmException, InvalidKeySpecException, com.fasterxml.jackson.core.JsonProcessingException Creates a single staff repository if it doesn't already exist, and provisions access to the repository by that staff member- Parameters:
course- The Course in questionstaff- CourseStaff of the staff the repository should be created forrepoPrefix- Name of the project or assignment. Used to title the repository, in the format repoPrefix-githubLoginisPrivate- Whether the repository is private or not- Throws:
NoSuchAlgorithmExceptionInvalidKeySpecExceptioncom.fasterxml.jackson.core.JsonProcessingException
-
getRepositoriesMatchingPrefix
public List<RepositoryService.GithubRepository> getRepositoriesMatchingPrefix(Course course, String prefix) throws NoSuchAlgorithmException, InvalidKeySpecException, com.fasterxml.jackson.core.JsonProcessingException Lists repositories in the course GitHub organization whose names start with the provided prefix.- Throws:
NoSuchAlgorithmExceptionInvalidKeySpecExceptioncom.fasterxml.jackson.core.JsonProcessingException
-
isRepositoryEmpty
public boolean isRepositoryEmpty(Course course, String repositoryName) throws NoSuchAlgorithmException, InvalidKeySpecException, com.fasterxml.jackson.core.JsonProcessingException Returns true when the repository has no commits.- Throws:
NoSuchAlgorithmExceptionInvalidKeySpecExceptioncom.fasterxml.jackson.core.JsonProcessingException
-
deleteRepositoryIfEmpty
public boolean deleteRepositoryIfEmpty(Course course, String repositoryName) throws NoSuchAlgorithmException, InvalidKeySpecException, com.fasterxml.jackson.core.JsonProcessingException Deletes a repository only when it is empty. Returns true when a delete request was sent.- Throws:
NoSuchAlgorithmExceptionInvalidKeySpecExceptioncom.fasterxml.jackson.core.JsonProcessingException
-
createTeamRepository
public void createTeamRepository(Course course, Team team, String repoPrefix, Boolean isPrivate, RepositoryPermissions permissions, Integer orgId) throws NoSuchAlgorithmException, InvalidKeySpecException, com.fasterxml.jackson.core.JsonProcessingException Creates a GitHub repository for a team (student or staff), given only their team name.- Checks whether the repository already exists.
- If not, creates a new repository under the course's organization.
- Adds all team members as collaborators with the given permission level.
- Parameters:
course- the course whose organization the repo belongs toteam- the team for which the repo is being createdrepoPrefix- prefix for the repository name (repoPrefix-teamSlug)isPrivate- whether the created repository should be privatepermissions- collaborator permissions to grant the userorgId- GitHub organization ID used for team-based repo provisioning- Throws:
NoSuchAlgorithmException- if signing failsInvalidKeySpecException- if signing failscom.fasterxml.jackson.core.JsonProcessingException- if JSON serialization fails
-