Home page lists repositories with clone form. Repo page shows branch management, file staging, commit, push and pull controls. Table-based layout with no JavaScript or CSS for retro browser compatibility. Includes MockMvc integration tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
34 lines
957 B
Java
34 lines
957 B
Java
package be.seeseepuff.webgit.controller;
|
|
|
|
import be.seeseepuff.webgit.service.GitService;
|
|
import lombok.RequiredArgsConstructor;
|
|
import org.eclipse.jgit.api.errors.GitAPIException;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.ui.Model;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
import java.io.IOException;
|
|
|
|
@Controller
|
|
@RequiredArgsConstructor
|
|
public class HomeController
|
|
{
|
|
private final GitService gitService;
|
|
|
|
@GetMapping("/")
|
|
public String home(Model model) throws IOException
|
|
{
|
|
model.addAttribute("repositories", gitService.listRepositories());
|
|
return "home";
|
|
}
|
|
|
|
@PostMapping("/clone")
|
|
public String cloneRepo(@RequestParam String url, @RequestParam String name) throws GitAPIException, IOException
|
|
{
|
|
gitService.cloneRepository(url, name);
|
|
return "redirect:/";
|
|
}
|
|
}
|