diff --git a/src/main/java/be/seeseepuff/webgit/controller/RepoController.java b/src/main/java/be/seeseepuff/webgit/controller/RepoController.java index dc6977a..649fbf5 100644 --- a/src/main/java/be/seeseepuff/webgit/controller/RepoController.java +++ b/src/main/java/be/seeseepuff/webgit/controller/RepoController.java @@ -193,20 +193,26 @@ public class RepoController } @PostMapping("/repo/{name}/stage") - public String stage(@PathVariable String name, @RequestParam List files, + public String stage(@PathVariable String name, + @RequestParam(required = false) List files, + @RequestParam(required = false) String selectAll, @RequestParam(defaultValue = "Stage Selected") String action) throws IOException, GitAPIException { + List filesToProcess = (selectAll != null) ? gitService.getModifiedFiles(name) : (files != null ? files : List.of()); if ("Rollback Selected".equals(action)) - gitService.rollbackFiles(name, files); + gitService.rollbackFiles(name, filesToProcess); else - gitService.stageFiles(name, files); + gitService.stageFiles(name, filesToProcess); return "redirect:/repo/" + name + "/changes"; } @PostMapping("/repo/{name}/unstage") - public String unstage(@PathVariable String name, @RequestParam List files) throws IOException, GitAPIException + public String unstage(@PathVariable String name, + @RequestParam(required = false) List files, + @RequestParam(required = false) String selectAll) throws IOException, GitAPIException { - gitService.unstageFiles(name, files); + List filesToProcess = (selectAll != null) ? gitService.getStagedFiles(name) : (files != null ? files : List.of()); + gitService.unstageFiles(name, filesToProcess); return "redirect:/repo/" + name + "/changes"; } diff --git a/src/main/resources/templates/changes.html b/src/main/resources/templates/changes.html index 7a056ed..dca1e95 100644 --- a/src/main/resources/templates/changes.html +++ b/src/main/resources/templates/changes.html @@ -11,7 +11,7 @@
- + @@ -29,7 +29,7 @@
File
- +
File