|
|
@ -1,3 +1,8 @@
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* Copyright (C) 2021 Anton Romanov - All Rights Reserved
|
|
|
|
|
|
|
|
* You may use, distribute and modify this code, please write to: romanov73@gmail.com.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
package ru.ulstu.extractor.controller;
|
|
|
|
package ru.ulstu.extractor.controller;
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
@ -15,6 +20,9 @@ import ru.ulstu.extractor.service.IndexService;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static ru.ulstu.extractor.controller.Route.FILTER_COMMITS;
|
|
|
|
|
|
|
|
import static ru.ulstu.extractor.controller.Route.INDEXING_NEW_REPOSITORY;
|
|
|
|
|
|
|
|
|
|
|
|
@Controller
|
|
|
|
@Controller
|
|
|
|
public class GitIndexingController {
|
|
|
|
public class GitIndexingController {
|
|
|
|
private final GitRepositoryService gitRepositoryService;
|
|
|
|
private final GitRepositoryService gitRepositoryService;
|
|
|
@ -26,40 +34,39 @@ public class GitIndexingController {
|
|
|
|
this.indexService = indexService;
|
|
|
|
this.indexService = indexService;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/newRepo")
|
|
|
|
@GetMapping(INDEXING_NEW_REPOSITORY)
|
|
|
|
public String indexNewRepo(Model model) {
|
|
|
|
public String indexNewRepo(Model model) {
|
|
|
|
model.addAttribute(new RepoForm());
|
|
|
|
model.addAttribute(new RepoForm());
|
|
|
|
return "newRepo";
|
|
|
|
return INDEXING_NEW_REPOSITORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/newRepo", method = RequestMethod.POST, params = "send")
|
|
|
|
@RequestMapping(value = INDEXING_NEW_REPOSITORY, method = RequestMethod.POST, params = "send")
|
|
|
|
public String getBranch(@ModelAttribute RepoForm repoForm, Model model) {
|
|
|
|
public String getBranch(@ModelAttribute RepoForm repoForm, Model model) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
gitRepositoryService.cloneOrUpdateRepo(repoForm.getRepo());
|
|
|
|
gitRepositoryService.cloneOrUpdateRepo(repoForm.getRepo());
|
|
|
|
List<Branch> branches = gitRepositoryService.getBranches(repoForm.getRepo());
|
|
|
|
List<Branch> branches = gitRepositoryService.getBranches(repoForm.getRepo());
|
|
|
|
model.addAttribute("branches", branches);
|
|
|
|
model.addAttribute("branches", branches);
|
|
|
|
return "newRepo";
|
|
|
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
} catch (Exception ex) {
|
|
|
|
model.addAttribute("error", ex.getMessage());
|
|
|
|
model.addAttribute("error", ex.getMessage());
|
|
|
|
return "newRepo";
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return INDEXING_NEW_REPOSITORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/newRepo", method = RequestMethod.POST, params = "next")
|
|
|
|
@RequestMapping(value = INDEXING_NEW_REPOSITORY, method = RequestMethod.POST, params = "next")
|
|
|
|
public String setBranch(@ModelAttribute RepoForm repoForm, Model model, RedirectAttributes redirectAttributes) {
|
|
|
|
public String setBranch(@ModelAttribute RepoForm repoForm, Model model, RedirectAttributes redirectAttributes) {
|
|
|
|
model.addAttribute("filterForm", new FilterForm(repoForm.getRepo()));
|
|
|
|
model.addAttribute("filterForm", new FilterForm(repoForm.getRepo()));
|
|
|
|
if (repoForm.getBranch() == null) {
|
|
|
|
if (repoForm.getBranch() == null) {
|
|
|
|
return "newRepo";
|
|
|
|
return INDEXING_NEW_REPOSITORY;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
indexService.index(repoForm.getRepo(), repoForm.getBranch());
|
|
|
|
indexService.index(repoForm.getRepo(), repoForm.getBranch());
|
|
|
|
} catch (Exception ex) {
|
|
|
|
} catch (Exception ex) {
|
|
|
|
model.addAttribute("error", ex.getMessage());
|
|
|
|
model.addAttribute("error", ex.getMessage());
|
|
|
|
return "newRepo";
|
|
|
|
return INDEXING_NEW_REPOSITORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
redirectAttributes.addAttribute("repositoryUrl", repoForm.getRepo());
|
|
|
|
redirectAttributes.addAttribute("repositoryUrl", repoForm.getRepo());
|
|
|
|
redirectAttributes.addAttribute("branchName", repoForm.getBranch());
|
|
|
|
redirectAttributes.addAttribute("branchName", repoForm.getBranch());
|
|
|
|
return "redirect:/filtering";
|
|
|
|
return "redirect:/" + FILTER_COMMITS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|