Skip to content

Commit

Permalink
Programming exercises: Only replace existing files when populating bu…
Browse files Browse the repository at this point in the history
…ild plan repositories (#9968)
  • Loading branch information
SimonEntholzer authored Dec 10, 2024
1 parent 8398a27 commit 3f38127
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -342,16 +342,11 @@ private void createScriptFile(String buildJobContainerId) {
private void addAndPrepareDirectoryAndReplaceContent(String containerId, Path repositoryPath, String newDirectoryName) {
copyToContainer(repositoryPath.toString(), containerId);
addDirectory(containerId, newDirectoryName, true);
removeDirectoryAndFiles(containerId, newDirectoryName);
renameDirectoryOrFile(containerId, LOCALCI_WORKING_DIRECTORY + "/" + repositoryPath.getFileName().toString(), newDirectoryName);
insertRepositoryFiles(containerId, LOCALCI_WORKING_DIRECTORY + "/" + repositoryPath.getFileName().toString(), newDirectoryName);
}

private void removeDirectoryAndFiles(String containerId, String newName) {
executeDockerCommand(containerId, null, false, false, true, "rm", "-rf", newName);
}

private void renameDirectoryOrFile(String containerId, String oldName, String newName) {
executeDockerCommand(containerId, null, false, false, true, "mv", oldName, newName);
private void insertRepositoryFiles(String containerId, String oldName, String newName) {
executeDockerCommand(containerId, null, false, false, true, "cp", "-r", oldName + (oldName.endsWith("/") ? "." : "/."), newName);
}

private void addDirectory(String containerId, String directoryName, boolean createParentsIfNecessary) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/i18n/de/programmingExercise.json
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@
"auxiliaryRepository": {
"error": "Es gibt ein Problem mit den Hilfs-Repositories!",
"addAuxiliaryRepository": "Hilfs-Repository anlegen",
"usageDescription": "Du kannst Hilfsrepositorien verwenden, um zusätzlichen Code bereitzustellen, den die Studierenden nicht sehen oder ändern können. Der zusätzliche Code wird im angegebenen Checkout-Verzeichnis eingefügt, bevor der Build erstellt wird. Der eingefügte Code überschreibt alles, was sich an der durch das Checkout-Verzeichnis angegebenen Stelle befindet. Wenn du die Dateien der Studierenden nur teilweise überschreiben willst, muss das Build-Skript angepasst werden.",
"usageDescription": "Du kannst Hilfsrepositorien verwenden, um zusätzlichen Code bereitzustellen, den die Studierenden nicht sehen oder ändern können. Der zusätzliche Code wird im angegebenen Checkout-Verzeichnis eingefügt, bevor der Build erstellt wird. Die eingefügten Dateien überschreiben alle Dateien im Checkout-Verzeichnis, die den gleichen Namen haben. Dateien, die nicht überschrieben werden, bleiben erhalten.",
"repositoryName": "Name des Repositorys",
"checkoutDirectory": "Checkout-Verzeichnis",
"description": "Beschreibung",
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/i18n/en/programmingExercise.json
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@
"auxiliaryRepository": {
"error": "There is a problem with the auxiliary repository.",
"addAuxiliaryRepository": "Add Auxiliary Repository",
"usageDescription": "You can use auxiliary repositories to provide additional code that students cannot see or modify. The additional code is inserted into the specified checkout directory before the submission is built. The inserted code overwrites everything which lies at the location specified by the checkout directory. If you only need to overwrite student files partially, you need to adapt the build script.",
"usageDescription": "You can use auxiliary repositories to provide additional code that students cannot see or modify. The additional code is inserted into the specified checkout directory before the submission is built. The additional code is inserted in the specified checkout directory before the build is created. The inserted files overwrite all files in the checkout directory which have the same name. Files that are not overwritten are retained.",
"repositoryName": "Repository Name",
"checkoutDirectory": "Checkout Directory",
"description": "Description",
Expand Down

0 comments on commit 3f38127

Please sign in to comment.