Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Integrated code lifecycle: Add auxiliary repository view #9321

Merged
merged 48 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
71a1d1a
add auxiliary repository view
SimonEntholzer Sep 16, 2024
a6d003e
Merge branch 'develop' into feature/add-auxiliary-repository-view
SimonEntholzer Sep 16, 2024
bf991d3
get correct default branch
SimonEntholzer Sep 16, 2024
5b83bec
remove console logs
SimonEntholzer Sep 16, 2024
391b8b6
remove dependency on LocalVcService
SimonEntholzer Sep 16, 2024
63aede9
Merge branch 'develop' into feature/add-auxiliary-repository-view
SimonEntholzer Sep 17, 2024
8b9014d
Merge branch 'develop' into feature/add-auxiliary-repository-view
SimonEntholzer Sep 18, 2024
483153c
Merge branch 'refs/heads/develop' into feature/add-auxiliary-reposito…
SimonEntholzer Sep 21, 2024
6ed98a4
added suggestions
SimonEntholzer Sep 22, 2024
84313a1
added client tests
SimonEntholzer Sep 22, 2024
0280f1f
added initial AuxiliaryRepositoryResourceIntegrationTest
SimonEntholzer Sep 22, 2024
304caa6
added java integration test for AuxiliaryRepositoryResource
SimonEntholzer Sep 22, 2024
f9a3472
adjusted endpoint
SimonEntholzer Sep 22, 2024
fdac5df
added improvements
SimonEntholzer Sep 22, 2024
448a9c4
adjusted mock
SimonEntholzer Sep 22, 2024
ea7763d
Merge branch 'develop' into feature/add-auxiliary-repository-view
SimonEntholzer Sep 22, 2024
0981cc7
renamed and adjusted comment
SimonEntholzer Sep 22, 2024
697b318
fix tests
SimonEntholzer Sep 22, 2024
4acc6a7
simplified endpoint
SimonEntholzer Sep 26, 2024
53480bb
fixed routing
SimonEntholzer Sep 26, 2024
0ef2075
fixed rest call by making repositoryId request param optional
SimonEntholzer Sep 26, 2024
160677c
fix test
SimonEntholzer Sep 26, 2024
bd11490
remove unused attribute
SimonEntholzer Sep 26, 2024
b3b563c
Merge branch 'develop' into feature/add-auxiliary-repository-view
SimonEntholzer Sep 27, 2024
3f74493
Merge branch 'develop' into feature/add-auxiliary-repository-view
SimonEntholzer Sep 28, 2024
74af189
Merge branch 'develop' into feature/add-auxiliary-repository-view
SimonEntholzer Sep 28, 2024
05c04ca
Merge branch 'develop' into feature/add-auxiliary-repository-view
SimonEntholzer Sep 28, 2024
8103d42
Merge branch 'develop' into feature/add-auxiliary-repository-view
SimonEntholzer Sep 29, 2024
f80f2b1
Merge branch 'develop' into feature/add-auxiliary-repository-view
SimonEntholzer Sep 30, 2024
9c22397
fix imports
SimonEntholzer Sep 30, 2024
a99f85b
Merge branch 'develop' into feature/add-auxiliary-repository-view
SimonEntholzer Oct 1, 2024
85a5de3
use testRepository
SimonEntholzer Oct 1, 2024
44909ac
Merge remote-tracking branch 'refs/remotes/origin/feature/add-auxilia…
SimonEntholzer Oct 1, 2024
1b41855
Merge branch 'develop' into feature/add-auxiliary-repository-view
SimonEntholzer Oct 2, 2024
55b5e00
Merge branch 'develop' into feature/add-auxiliary-repository-view
SimonEntholzer Oct 5, 2024
2c0123f
Merge branch 'develop' into feature/add-auxiliary-repository-view
SimonEntholzer Oct 8, 2024
7392e4c
Merge branch 'develop' into feature/add-auxiliary-repository-view
SimonEntholzer Oct 9, 2024
58faf55
Merge branch 'develop' into feature/add-auxiliary-repository-view
SimonEntholzer Oct 11, 2024
a053f1a
Merge branch 'develop' into feature/add-auxiliary-repository-view
SimonEntholzer Oct 12, 2024
d8d5d4a
Merge branch 'develop' into feature/add-auxiliary-repository-view
SimonEntholzer Oct 13, 2024
6e77f54
Merge branch 'develop' into feature/add-auxiliary-repository-view
SimonEntholzer Oct 13, 2024
30e0cf8
Merge branch 'develop' into feature/add-auxiliary-repository-view
SimonEntholzer Oct 14, 2024
31df801
Merge branch 'develop' into feature/add-auxiliary-repository-view
SimonEntholzer Oct 14, 2024
79701dc
Merge branch 'develop' into feature/add-auxiliary-repository-view
SimonEntholzer Oct 16, 2024
e453fe5
Merge branch 'develop' into feature/add-auxiliary-repository-view
krusche Oct 18, 2024
ecd4138
Merge branch 'develop' into feature/add-auxiliary-repository-view
SimonEntholzer Oct 18, 2024
f3aa1b8
improve test coverage
SimonEntholzer Oct 18, 2024
0b8eec9
Merge branch 'develop' into feature/add-auxiliary-repository-view
SimonEntholzer Oct 18, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import de.tum.cit.aet.artemis.exercise.domain.participation.Participation;
import de.tum.cit.aet.artemis.exercise.repository.ParticipationRepository;
import de.tum.cit.aet.artemis.exercise.repository.TeamRepository;
import de.tum.cit.aet.artemis.programming.domain.AuxiliaryRepository;
import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise;
import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseParticipation;
import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation;
Expand Down Expand Up @@ -517,6 +518,22 @@ public List<CommitInfoDTO> getCommitInfos(ProgrammingExerciseParticipation parti
}
}

/**
* Get the commits information for the given auxiliary repository.
*
* @param auxiliaryRepository the auxiliary repository for which to get the commits.
* @return a list of CommitInfo DTOs containing author, timestamp, commit-hash and commit message.
*/
public List<CommitInfoDTO> getAuxiliaryRepositoryCommitInfos(AuxiliaryRepository auxiliaryRepository) {
try {
return gitService.getCommitInfos(auxiliaryRepository.getVcsRepositoryUri());
}
catch (GitAPIException e) {
log.error("Could not get commit infos for auxiliaryRepository {} with repository uri {}", auxiliaryRepository.getId(), auxiliaryRepository.getVcsRepositoryUri());
return List.of();
}
}
SimonEntholzer marked this conversation as resolved.
Show resolved Hide resolved

/**
* Get the commits information for the test repository of the given participation's exercise.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1048,4 +1048,15 @@ public ProgrammingExercise loadProgrammingExercise(long exerciseId, boolean with
programmingExerciseTaskService.replaceTestIdsWithNames(programmingExercise);
return programmingExercise;
}

/**
* Load a programming exercise, only with eager auxiliary repositories
*
* @param exerciseId the ID of the programming exercise to load
* @return the loaded programming exercise entity
*/
public ProgrammingExercise loadProgrammingExerciseWithAuxiliaryRepositories(long exerciseId) {
final Set<ProgrammingExerciseRepository.ProgrammingExerciseFetchOptions> fetchOptions = Set.of(AuxiliaryRepositories);
return programmingExerciseRepository.findByIdWithDynamicFetchElseThrow(exerciseId, fetchOptions);
}
SimonEntholzer marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import de.tum.cit.aet.artemis.programming.domain.VcsRepositoryUri;
import de.tum.cit.aet.artemis.programming.dto.CommitInfoDTO;
import de.tum.cit.aet.artemis.programming.dto.VcsAccessLogDTO;
import de.tum.cit.aet.artemis.programming.repository.AuxiliaryRepositoryRepository;
import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository;
import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseStudentParticipationRepository;
import de.tum.cit.aet.artemis.programming.repository.VcsAccessLogRepository;
Expand Down Expand Up @@ -89,11 +90,13 @@ public class ProgrammingExerciseParticipationResource {

private final Optional<VcsAccessLogRepository> vcsAccessLogRepository;

private final AuxiliaryRepositoryRepository auxiliaryRepositoryRepository;
SimonEntholzer marked this conversation as resolved.
Show resolved Hide resolved

public ProgrammingExerciseParticipationResource(ProgrammingExerciseParticipationService programmingExerciseParticipationService, ResultRepository resultRepository,
ParticipationRepository participationRepository, ProgrammingExerciseStudentParticipationRepository programmingExerciseStudentParticipationRepository,
ProgrammingSubmissionService submissionService, ProgrammingExerciseRepository programmingExerciseRepository, AuthorizationCheckService authCheckService,
ResultService resultService, ParticipationAuthorizationCheckService participationAuthCheckService, RepositoryService repositoryService,
StudentExamRepository studentExamRepository, Optional<VcsAccessLogRepository> vcsAccessLogRepository) {
StudentExamRepository studentExamRepository, Optional<VcsAccessLogRepository> vcsAccessLogRepository, AuxiliaryRepositoryRepository auxiliaryRepositoryRepository) {
this.programmingExerciseParticipationService = programmingExerciseParticipationService;
this.participationRepository = participationRepository;
this.programmingExerciseStudentParticipationRepository = programmingExerciseStudentParticipationRepository;
Expand All @@ -105,6 +108,7 @@ public ProgrammingExerciseParticipationResource(ProgrammingExerciseParticipation
this.participationAuthCheckService = participationAuthCheckService;
this.repositoryService = repositoryService;
this.studentExamRepository = studentExamRepository;
this.auxiliaryRepositoryRepository = auxiliaryRepositoryRepository;
this.vcsAccessLogRepository = vcsAccessLogRepository;
}

Expand Down Expand Up @@ -339,22 +343,25 @@ public ResponseEntity<List<VcsAccessLogDTO>> getVcsAccessLogForParticipationRepo

/**
* GET /programming-exercise/{exerciseID}/commit-history/{repositoryType} : Get the commit history of a programming exercise repository. The repository type can be TEMPLATE or
* SOLUTION or TESTS.
* SOLUTION, TESTS or AUXILIARY.
* Here we check is at least a teaching assistant for the exercise.
*
* @param exerciseID the id of the exercise for which to retrieve the commit history
* @param repositoryType the type of the repository for which to retrieve the commit history
SimonEntholzer marked this conversation as resolved.
Show resolved Hide resolved
* @param repositoryId the id of the repository
* @return the ResponseEntity with status 200 (OK) and with body a list of commitInfo DTOs with the commits information of the repository
*/
@GetMapping("programming-exercise/{exerciseID}/commit-history/{repositoryType}")
@EnforceAtLeastTutor
public ResponseEntity<List<CommitInfoDTO>> getCommitHistoryForTemplateSolutionOrTestRepo(@PathVariable long exerciseID, @PathVariable RepositoryType repositoryType) {
public ResponseEntity<List<CommitInfoDTO>> getCommitHistoryForTemplateSolutionTestOrAuxRepo(@PathVariable long exerciseID, @PathVariable RepositoryType repositoryType,
@RequestParam Optional<Long> repositoryId) {
boolean isTemplateRepository = repositoryType.equals(RepositoryType.TEMPLATE);
boolean isSolutionRepository = repositoryType.equals(RepositoryType.SOLUTION);
boolean isTestRepository = repositoryType.equals(RepositoryType.TESTS);
boolean isAuxiliaryRepository = repositoryType.equals(RepositoryType.AUXILIARY);
ProgrammingExerciseParticipation participation;

if (!isTemplateRepository && !isSolutionRepository && !isTestRepository) {
if (!isTemplateRepository && !isSolutionRepository && !isTestRepository && !isAuxiliaryRepository) {
throw new BadRequestAlertException("Invalid repository type", ENTITY_NAME, "invalidRepositoryType");
}
else if (isTemplateRepository) {
Expand All @@ -364,6 +371,15 @@ else if (isTemplateRepository) {
participation = programmingExerciseParticipationService.findSolutionParticipationByProgrammingExerciseId(exerciseID);
}
participationAuthCheckService.checkCanAccessParticipationElseThrow(participation);

if (isAuxiliaryRepository) {
var auxiliaryRepo = auxiliaryRepositoryRepository.findByIdElseThrow(repositoryId.orElseThrow());
if (!auxiliaryRepo.getExercise().getId().equals(exerciseID)) {
SimonEntholzer marked this conversation as resolved.
Show resolved Hide resolved
throw new BadRequestAlertException("Invalid repository id", ENTITY_NAME, "invalidRepositoryId");
}
return ResponseEntity.ok(programmingExerciseParticipationService.getAuxiliaryRepositoryCommitInfos(auxiliaryRepo));
}

if (isTestRepository) {
return ResponseEntity.ok(programmingExerciseParticipationService.getCommitInfosTestRepo(participation));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,21 @@ public ResponseEntity<ProgrammingExercise> getProgrammingExerciseWithTemplateAnd
return ResponseEntity.ok(programmingExercise);
}

/**
* GET /programming-exercises/:exerciseId/with-auxiliary-repository
*
* @param exerciseId the id of the programmingExercise to retrieve
* @return the ResponseEntity with status 200 (OK) and the programming exercise with template and solution participation, or with status 404 (Not Found)
*/
@GetMapping("programming-exercises/{exerciseId}/with-auxiliary-repository")
@EnforceAtLeastTutorInExercise
public ResponseEntity<ProgrammingExercise> getProgrammingExerciseWithAuxiliaryRepository(@PathVariable long exerciseId) {

log.debug("REST request to get programming exercise with auxiliary repositories: {}", exerciseId);
final var programmingExercise = programmingExerciseService.loadProgrammingExerciseWithAuxiliaryRepositories(exerciseId);
return ResponseEntity.ok(programmingExercise);
}
SimonEntholzer marked this conversation as resolved.
Show resolved Hide resolved

/**
* DELETE /programming-exercises/:id : delete the "id" programmingExercise.
*
Expand Down
Loading
Loading