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

Open
wants to merge 46 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
46 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
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 @@ -1009,4 +1009,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 @@ -44,6 +44,7 @@
import de.tum.cit.aet.artemis.programming.domain.RepositoryType;
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.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.service.ProgrammingExerciseParticipationService;
Expand Down Expand Up @@ -79,11 +80,13 @@ public class ProgrammingExerciseParticipationResource {

private final StudentExamRepository studentExamRepository;

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) {
StudentExamRepository studentExamRepository, AuxiliaryRepositoryRepository auxiliaryRepositoryRepository) {
this.programmingExerciseParticipationService = programmingExerciseParticipationService;
this.participationRepository = participationRepository;
this.programmingExerciseStudentParticipationRepository = programmingExerciseStudentParticipationRepository;
Expand All @@ -95,6 +98,7 @@ public ProgrammingExerciseParticipationResource(ProgrammingExerciseParticipation
this.participationAuthCheckService = participationAuthCheckService;
this.repositoryService = repositoryService;
this.studentExamRepository = studentExamRepository;
this.auxiliaryRepositoryRepository = auxiliaryRepositoryRepository;
}

/**
Expand Down Expand Up @@ -312,17 +316,20 @@ public ResponseEntity<List<CommitInfoDTO>> getCommitHistoryForParticipationRepo(
*
* @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
* @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>> getCommitHistoryForTemplateSolutionOrTestRepo(@PathVariable long exerciseID, @PathVariable RepositoryType repositoryType,
@RequestParam long repositoryId) {
SimonEntholzer marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -332,6 +339,15 @@ else if (isTemplateRepository) {
participation = programmingExerciseParticipationService.findSolutionParticipationByProgrammingExerciseId(exerciseID);
}
participationAuthCheckService.checkCanAccessParticipationElseThrow(participation);

if (isAuxiliaryRepository) {
var auxiliaryRepo = auxiliaryRepositoryRepository.findByIdElseThrow(repositoryId);
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));
}
SimonEntholzer marked this conversation as resolved.
Show resolved Hide resolved

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

/**
* GET /programming-exercises/:exerciseId/with-auxiliary-repository/:auxiliaryRepositoryId
*
* @param exerciseId the id of the programmingExercise to retrieve
* @param auxiliaryRepositoryId the id of the auxiliary repository of the exercise
* @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/{auxiliaryRepositoryId}")
@EnforceAtLeastTutorInExercise
public ResponseEntity<ProgrammingExercise> getProgrammingExerciseWithTemplateAndSolutionParticipation(@PathVariable long exerciseId, @PathVariable long auxiliaryRepositoryId) {

log.debug("REST request to get programming exercise with template and solution participation : {}", exerciseId);
SimonEntholzer marked this conversation as resolved.
Show resolved Hide resolved
final var programmingExercise = programmingExerciseService.loadProgrammingExerciseWithAuxiliaryRepositories(exerciseId);
if (programmingExercise.getAuxiliaryRepositories().stream().noneMatch(id -> id.getId() == auxiliaryRepositoryId)) {
throw new BadRequestAlertException("The auxiliary repository Id does not belong to the exercise.", "Exercise",
ProgrammingExerciseResourceErrorKeys.INVALID_AUXILIARY_REPOSITORY_ID);
}
return ResponseEntity.ok(programmingExercise);
}

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