Merge branch 'master' into 12-heuristic
# Conflicts: # build.gradle
This commit is contained in:
commit
117315024e
@ -1,6 +1,6 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
ext {
|
ext {
|
||||||
versionSpringBoot = '2.3.8.RELEASE'
|
versionSpringBoot = '2.3.9.RELEASE'
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
@ -47,12 +47,13 @@ dependencies {
|
|||||||
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web'
|
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web'
|
||||||
compile group: 'org.springframework.boot', name: 'spring-boot-starter-jetty'
|
compile group: 'org.springframework.boot', name: 'spring-boot-starter-jetty'
|
||||||
compile group: 'org.springframework.boot', name: 'spring-boot-starter-thymeleaf'
|
compile group: 'org.springframework.boot', name: 'spring-boot-starter-thymeleaf'
|
||||||
|
compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa'
|
||||||
compile group: 'nz.net.ultraq.thymeleaf', name: 'thymeleaf-layout-dialect'
|
compile group: 'nz.net.ultraq.thymeleaf', name: 'thymeleaf-layout-dialect'
|
||||||
compile group: 'com.fasterxml.jackson.module', name: 'jackson-module-afterburner'
|
compile group: 'com.fasterxml.jackson.module', name: 'jackson-module-afterburner'
|
||||||
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-hibernate5'
|
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-hibernate5'
|
||||||
compile group: 'org.springframework.boot', name: 'spring-boot-starter-jdbc'
|
|
||||||
compile group: 'org.postgresql', name: 'postgresql', version: '9.4.1212'
|
compile group: 'org.postgresql', name: 'postgresql', version: '9.4.1212'
|
||||||
compile group: 'org.liquibase', name: 'liquibase-core', version: '4.3.1'
|
compile group: 'org.liquibase', name: 'liquibase-core', version: '4.3.1'
|
||||||
|
implementation group: 'commons-io', name: 'commons-io', version: '2.6'
|
||||||
compile group: 'net.sourceforge.htmlunit', name: 'htmlunit', version: '2.35.0'
|
compile group: 'net.sourceforge.htmlunit', name: 'htmlunit', version: '2.35.0'
|
||||||
|
|
||||||
compile group: 'io.springfox', name: 'springfox-boot-starter', version: '3.0.0'
|
compile group: 'io.springfox', name: 'springfox-boot-starter', version: '3.0.0'
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.extractor.mvc;
|
package ru.ulstu.extractor.config;
|
||||||
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.extractor.mvc;
|
package ru.ulstu.extractor.config;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.extractor.mvc;
|
package ru.ulstu.extractor.config;
|
||||||
|
|
||||||
import nz.net.ultraq.thymeleaf.LayoutDialect;
|
import nz.net.ultraq.thymeleaf.LayoutDialect;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
@ -0,0 +1,69 @@
|
|||||||
|
package ru.ulstu.extractor.controller;
|
||||||
|
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import ru.ulstu.extractor.model.Commit;
|
||||||
|
import ru.ulstu.extractor.model.OffsetablePageRequest;
|
||||||
|
import ru.ulstu.extractor.model.mvc.FilterForm;
|
||||||
|
import ru.ulstu.extractor.service.FilteringService;
|
||||||
|
import ru.ulstu.extractor.service.IndexService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class GitFilteringController {
|
||||||
|
private final FilteringService filteringService;
|
||||||
|
private final IndexService indexService;
|
||||||
|
|
||||||
|
public GitFilteringController(FilteringService filteringService,
|
||||||
|
IndexService indexService) {
|
||||||
|
this.filteringService = filteringService;
|
||||||
|
this.indexService = indexService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* @PostMapping("/sendFilter")
|
||||||
|
public String sendFilter(@ModelAttribute FilterForm filterForm, Model model) throws GitAPIException, IOException {
|
||||||
|
List<Commit> list = gitRepositoryService.getCommits(filterForm.getUrl(), filterForm.getBranch());
|
||||||
|
model.addAttribute("commits", list);
|
||||||
|
if (filterForm.getFilter() == null || filterForm.getFilter().isEmpty()) {
|
||||||
|
model.addAttribute("error", "'Строка' не должно быть пустым");
|
||||||
|
return "filtering";
|
||||||
|
}
|
||||||
|
return "resultRepo";
|
||||||
|
}*/
|
||||||
|
|
||||||
|
@RequestMapping(value = "/filtering", method = RequestMethod.GET)
|
||||||
|
public String listCommits(
|
||||||
|
Model model,
|
||||||
|
@ModelAttribute FilterForm filterForm,
|
||||||
|
@RequestParam("page") Optional<Integer> page,
|
||||||
|
@RequestParam("size") Optional<Integer> size,
|
||||||
|
@RequestParam String repositoryUrl,
|
||||||
|
@RequestParam String branchName) {
|
||||||
|
int currentPage = page.orElse(1);
|
||||||
|
int pageSize = size.orElse(5);
|
||||||
|
|
||||||
|
Page<Commit> commitsPage = indexService.getCommits(repositoryUrl, branchName, new OffsetablePageRequest(currentPage, pageSize));
|
||||||
|
int totalPages = commitsPage.getTotalPages();
|
||||||
|
if (totalPages > 0) {
|
||||||
|
List<Integer> pageNumbers = IntStream.rangeClosed(1, totalPages)
|
||||||
|
.boxed()
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
model.addAttribute("pageNumbers", pageNumbers);
|
||||||
|
}
|
||||||
|
filterForm = new FilterForm();
|
||||||
|
filterForm.setCommitsPage(commitsPage);
|
||||||
|
filterForm.setBranch(branchName);
|
||||||
|
filterForm.setUrl(repositoryUrl);
|
||||||
|
model.addAttribute("filterForm", filterForm);
|
||||||
|
return "filtering";
|
||||||
|
}
|
||||||
|
}
|
@ -1,58 +1,43 @@
|
|||||||
package ru.ulstu.extractor.mvc;
|
package ru.ulstu.extractor.controller;
|
||||||
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||||
import ru.ulstu.extractor.model.Branch;
|
import ru.ulstu.extractor.model.Branch;
|
||||||
import ru.ulstu.extractor.mvc.model.FilterForm;
|
import ru.ulstu.extractor.model.mvc.FilterForm;
|
||||||
import ru.ulstu.extractor.mvc.model.RepoForm;
|
import ru.ulstu.extractor.model.mvc.RepoForm;
|
||||||
import ru.ulstu.extractor.service.FilteringService;
|
|
||||||
import ru.ulstu.extractor.service.GitRepositoryService;
|
import ru.ulstu.extractor.service.GitRepositoryService;
|
||||||
|
import ru.ulstu.extractor.service.IndexService;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class GitExtractorController {
|
public class GitIndexingController {
|
||||||
private final FilteringService filteringService;
|
|
||||||
private final GitRepositoryService gitRepositoryService;
|
private final GitRepositoryService gitRepositoryService;
|
||||||
|
private final IndexService indexService;
|
||||||
|
|
||||||
public GitExtractorController(FilteringService filteringService,
|
public GitIndexingController(GitRepositoryService gitRepositoryService,
|
||||||
GitRepositoryService gitRepositoryService) {
|
IndexService indexService) {
|
||||||
this.filteringService = filteringService;
|
|
||||||
this.gitRepositoryService = gitRepositoryService;
|
this.gitRepositoryService = gitRepositoryService;
|
||||||
|
this.indexService = indexService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/newRepo")
|
@GetMapping("/newRepo")
|
||||||
public String indexNewRepo(Model model) {
|
public String indexNewRepo(Model model) {
|
||||||
model.addAttribute("repoForm", new RepoForm());
|
model.addAttribute(new RepoForm());
|
||||||
return "newRepo";
|
return "newRepo";
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/filtering")
|
|
||||||
public String filter(Model model) {
|
|
||||||
model.addAttribute("filterForm", new FilterForm());
|
|
||||||
return "filtering";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/sendFilter")
|
|
||||||
public String sendFilter(@ModelAttribute FilterForm filterForm, Model model) {
|
|
||||||
if (filterForm.getFilter() == null || filterForm.getFilter().isEmpty()) {
|
|
||||||
model.addAttribute("error", "'Строка' не должно быть пустым");
|
|
||||||
return "filtering";
|
|
||||||
}
|
|
||||||
return "resultRepo";
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/newRepo", method = RequestMethod.POST, params = "send")
|
@RequestMapping(value = "/newRepo", 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> list = gitRepositoryService.getBranches(repoForm.getRepo());
|
List<Branch> branches = gitRepositoryService.getBranches(repoForm.getRepo());
|
||||||
model.addAttribute("branches", list);
|
model.addAttribute("branches", branches);
|
||||||
return "newRepo";
|
return "newRepo";
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
model.addAttribute("error", ex.getMessage());
|
model.addAttribute("error", ex.getMessage());
|
||||||
@ -61,12 +46,20 @@ public class GitExtractorController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/newRepo", method = RequestMethod.POST, params = "next")
|
@RequestMapping(value = "/newRepo", method = RequestMethod.POST, params = "next")
|
||||||
public String setBranch(@ModelAttribute RepoForm repoForm, Model model) {
|
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 "newRepo";
|
||||||
} else {
|
} else {
|
||||||
return "filtering";
|
try {
|
||||||
|
indexService.index(repoForm.getRepo(), repoForm.getBranch());
|
||||||
|
} catch (Exception ex) {
|
||||||
|
model.addAttribute("error", ex.getMessage());
|
||||||
|
return "newRepo";
|
||||||
|
}
|
||||||
|
redirectAttributes.addAttribute("repositoryUrl", repoForm.getRepo());
|
||||||
|
redirectAttributes.addAttribute("branchName", repoForm.getBranch());
|
||||||
|
return "redirect:/filtering";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -29,8 +29,9 @@ public class RepoController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("commits")
|
@GetMapping("commits")
|
||||||
public List<Commit> getCommits(@RequestParam("url") String url) throws GitAPIException, IOException {
|
public List<Commit> getCommits(@RequestParam("repositoryUrl") String repositoryUrl,
|
||||||
return gitRepositoryService.getCommits(url);
|
@RequestParam("branchName") String branchName) throws GitAPIException, IOException {
|
||||||
|
return gitRepositoryService.getCommits(repositoryUrl, branchName);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
package ru.ulstu.extractor.db;
|
|
||||||
|
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
|
||||||
import org.springframework.jdbc.core.RowMapper;
|
|
||||||
import org.springframework.stereotype.Repository;
|
|
||||||
import ru.ulstu.extractor.model.Commit;
|
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Repository
|
|
||||||
public class CommitRepository {
|
|
||||||
private final static String SQL_SELECT_COMMITS = "SELECT * FROM commit";
|
|
||||||
private final static String SQL_INSERT_COMMITS = "INSERT INTO commit (hash, date, author, message) " +
|
|
||||||
"VALUES (?, ?, ?, ?)";
|
|
||||||
private final JdbcTemplate jdbcTemplate;
|
|
||||||
|
|
||||||
public CommitRepository(JdbcTemplate jdbcTemplate) {
|
|
||||||
this.jdbcTemplate = jdbcTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class CommitRowMapper implements RowMapper<Commit> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Commit mapRow(ResultSet rs, int rowNum) throws SQLException {
|
|
||||||
return new Commit(rs.getString("message"),
|
|
||||||
rs.getString("author"),
|
|
||||||
rs.getDate("date"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Commit> getCommits() {
|
|
||||||
return jdbcTemplate.query(SQL_SELECT_COMMITS, new CommitRowMapper());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void saveCommit(Commit commit) {
|
|
||||||
jdbcTemplate.update(SQL_INSERT_COMMITS, "", commit.getDate(),
|
|
||||||
commit.getAuthor(),
|
|
||||||
commit.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
23
src/main/java/ru/ulstu/extractor/model/Author.java
Normal file
23
src/main/java/ru/ulstu/extractor/model/Author.java
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package ru.ulstu.extractor.model;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
public class Author extends BaseEntity {
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public Author() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Author(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
}
|
86
src/main/java/ru/ulstu/extractor/model/BaseEntity.java
Normal file
86
src/main/java/ru/ulstu/extractor/model/BaseEntity.java
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
package ru.ulstu.extractor.model;
|
||||||
|
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.MappedSuperclass;
|
||||||
|
import javax.persistence.Version;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@MappedSuperclass
|
||||||
|
public abstract class BaseEntity implements Serializable, Comparable {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.TABLE)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@Version
|
||||||
|
private Integer version;
|
||||||
|
|
||||||
|
public BaseEntity() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public BaseEntity(Integer id, Integer version) {
|
||||||
|
this.id = id;
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (obj == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!getClass().isAssignableFrom(obj.getClass())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
BaseEntity other = (BaseEntity) obj;
|
||||||
|
if (id == null) {
|
||||||
|
if (other.id != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!id.equals(other.id)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + (id == null ? 0 : id.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return getClass().getSimpleName() + "{" +
|
||||||
|
"id=" + id +
|
||||||
|
", version=" + version +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(Object o) {
|
||||||
|
return id != null ? id.compareTo(((BaseEntity) o).getId()) : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reset() {
|
||||||
|
this.id = null;
|
||||||
|
this.version = null;
|
||||||
|
}
|
||||||
|
}
|
@ -1,14 +1,62 @@
|
|||||||
package ru.ulstu.extractor.model;
|
package ru.ulstu.extractor.model;
|
||||||
|
|
||||||
public class Branch {
|
import org.hibernate.annotations.Fetch;
|
||||||
|
import org.hibernate.annotations.FetchMode;
|
||||||
|
|
||||||
|
import javax.persistence.CascadeType;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.ManyToOne;
|
||||||
|
import javax.persistence.OneToMany;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
public class Branch extends BaseEntity {
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
private Repository repository;
|
||||||
|
|
||||||
|
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||||
|
@JoinColumn(name = "branch_id", unique = true)
|
||||||
|
@Fetch(FetchMode.SUBSELECT)
|
||||||
|
private List<Commit> commits = new ArrayList<>();
|
||||||
|
|
||||||
|
public Branch() {
|
||||||
|
}
|
||||||
|
|
||||||
public Branch(String name) {
|
public Branch(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Branch(Repository repository, String branchName) {
|
||||||
|
this.repository = repository;
|
||||||
|
this.name = branchName;
|
||||||
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Repository getRepository() {
|
||||||
|
return repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRepository(Repository repository) {
|
||||||
|
this.repository = repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Commit> getCommits() {
|
||||||
|
return commits;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCommits(List<Commit> commits) {
|
||||||
|
this.commits = commits;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,40 @@
|
|||||||
package ru.ulstu.extractor.model;
|
package ru.ulstu.extractor.model;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.Fetch;
|
||||||
|
import org.hibernate.annotations.FetchMode;
|
||||||
|
|
||||||
|
import javax.persistence.CascadeType;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.ManyToOne;
|
||||||
|
import javax.persistence.OneToMany;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class Commit {
|
@Entity
|
||||||
private String message;
|
public class Commit extends BaseEntity {
|
||||||
|
private String hash;
|
||||||
private Date date;
|
private Date date;
|
||||||
private String author;
|
private String message;
|
||||||
private Changes changes;
|
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||||
|
private Author author;
|
||||||
|
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||||
|
@JoinColumn(name = "commit_id", unique = true)
|
||||||
|
@Fetch(FetchMode.SUBSELECT)
|
||||||
|
private List<FileChange> fileChanges = new ArrayList<>();
|
||||||
|
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||||
|
private Branch branch;
|
||||||
|
|
||||||
public Commit(String message, String author, Date date) {
|
public Commit() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Commit(String message, Author author, Date date, String hash) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.author = author;
|
this.author = author;
|
||||||
this.date = date;
|
this.date = date;
|
||||||
|
this.hash = hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
@ -23,15 +45,43 @@ public class Commit {
|
|||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAuthor() {
|
public String getHash() {
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHash(String hash) {
|
||||||
|
this.hash = hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDate(Date date) {
|
||||||
|
this.date = date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthor(Author author) {
|
||||||
|
this.author = author;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<FileChange> getFileChanges() {
|
||||||
|
return fileChanges;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileChanges(List<FileChange> fileChanges) {
|
||||||
|
this.fileChanges = fileChanges;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Author getAuthor() {
|
||||||
return author;
|
return author;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Changes getChanges() {
|
public Branch getBranch() {
|
||||||
return changes;
|
return branch;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setChanges(Changes changes) {
|
public void setBranch(Branch branch) {
|
||||||
this.changes = changes;
|
this.branch = branch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,28 @@
|
|||||||
package ru.ulstu.extractor.model;
|
package ru.ulstu.extractor.model;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.Fetch;
|
||||||
|
import org.hibernate.annotations.FetchMode;
|
||||||
|
|
||||||
|
import javax.persistence.CascadeType;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.OneToMany;
|
||||||
|
import javax.persistence.Transient;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class FileChange {
|
@Entity
|
||||||
|
public class FileChange extends BaseEntity {
|
||||||
private String file;
|
private String file;
|
||||||
|
@Transient
|
||||||
private boolean removed;
|
private boolean removed;
|
||||||
|
@Transient
|
||||||
private boolean added;
|
private boolean added;
|
||||||
|
|
||||||
|
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||||
|
@JoinColumn(name = "file_change_id", unique = true)
|
||||||
|
@Fetch(FetchMode.SUBSELECT)
|
||||||
private List<LineChange> lineChanges = new ArrayList<>();
|
private List<LineChange> lineChanges = new ArrayList<>();
|
||||||
|
|
||||||
public FileChange() {
|
public FileChange() {
|
||||||
@ -47,4 +63,12 @@ public class FileChange {
|
|||||||
public void setLineChanges(List<LineChange> lineChanges) {
|
public void setLineChanges(List<LineChange> lineChanges) {
|
||||||
this.lineChanges = lineChanges;
|
this.lineChanges = lineChanges;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isRemoved() {
|
||||||
|
return removed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAdded() {
|
||||||
|
return added;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,13 @@
|
|||||||
package ru.ulstu.extractor.model;
|
package ru.ulstu.extractor.model;
|
||||||
|
|
||||||
public class LineChange {
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.Transient;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
public class LineChange extends BaseEntity {
|
||||||
|
@Transient
|
||||||
private boolean added;
|
private boolean added;
|
||||||
|
@Transient
|
||||||
private boolean removed;
|
private boolean removed;
|
||||||
private String lineFrom;
|
private String lineFrom;
|
||||||
private String lineTo;
|
private String lineTo;
|
||||||
@ -42,4 +48,19 @@ public class LineChange {
|
|||||||
return lineTo;
|
return lineTo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAdded() {
|
||||||
|
return added;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAdded(boolean added) {
|
||||||
|
this.added = added;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRemoved() {
|
||||||
|
return removed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRemoved(boolean removed) {
|
||||||
|
this.removed = removed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,93 @@
|
|||||||
|
package ru.ulstu.extractor.model;
|
||||||
|
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.domain.Sort;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class OffsetablePageRequest implements Pageable, Serializable {
|
||||||
|
private final int offset;
|
||||||
|
private final int count;
|
||||||
|
private final Sort sort;
|
||||||
|
|
||||||
|
public OffsetablePageRequest(int page, long pageSize) {
|
||||||
|
this(pageSize * page, pageSize, Sort.by("id"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public OffsetablePageRequest(long offset, long count, Sort sort) {
|
||||||
|
if (offset < 0) {
|
||||||
|
throw new IllegalArgumentException("Offset value must not be less than zero!");
|
||||||
|
}
|
||||||
|
if (count < 1) {
|
||||||
|
throw new IllegalArgumentException("Count value must not be less than one!");
|
||||||
|
}
|
||||||
|
this.offset = (int) offset;
|
||||||
|
this.count = (int) count;
|
||||||
|
this.sort = sort;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Sort getSort() {
|
||||||
|
return sort;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPageSize() {
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPageNumber() {
|
||||||
|
return offset / count;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getOffset() {
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPrevious() {
|
||||||
|
return offset > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Pageable next() {
|
||||||
|
return new OffsetablePageRequest(getOffset() + getPageSize(), getPageSize(), getSort());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Pageable previousOrFirst() {
|
||||||
|
return hasPrevious() ? previous() : first();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Pageable previous() {
|
||||||
|
return getOffset() == 0 ? this : new OffsetablePageRequest(getOffset() - getPageSize(), getPageSize(), getSort());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Pageable first() {
|
||||||
|
return new OffsetablePageRequest(0, getPageSize(), getSort());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (obj == null || getClass() != obj.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final OffsetablePageRequest other = (OffsetablePageRequest) obj;
|
||||||
|
return this.offset == other.offset && this.count == other.count;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + offset;
|
||||||
|
result = prime * result + count;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
23
src/main/java/ru/ulstu/extractor/model/Repository.java
Normal file
23
src/main/java/ru/ulstu/extractor/model/Repository.java
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package ru.ulstu.extractor.model;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
public class Repository extends BaseEntity {
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
public Repository() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Repository(String repositoryUrl) {
|
||||||
|
url = repositoryUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,13 @@
|
|||||||
package ru.ulstu.extractor.mvc.model;
|
package ru.ulstu.extractor.model.mvc;
|
||||||
|
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import ru.ulstu.extractor.model.Commit;
|
||||||
|
|
||||||
public class FilterForm {
|
public class FilterForm {
|
||||||
private String filter;
|
private String filter;
|
||||||
private String url;
|
private String url;
|
||||||
|
private String branch;
|
||||||
|
private Page<Commit> commitsPage;
|
||||||
|
|
||||||
public FilterForm() {
|
public FilterForm() {
|
||||||
}
|
}
|
||||||
@ -27,6 +32,22 @@ public class FilterForm {
|
|||||||
this.url = url;
|
this.url = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getBranch() {
|
||||||
|
return branch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBranch(String branch) {
|
||||||
|
this.branch = branch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Page<Commit> getCommitsPage() {
|
||||||
|
return commitsPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCommitsPage(Page<Commit> commitsPage) {
|
||||||
|
this.commitsPage = commitsPage;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "FilterForm{" +
|
return "FilterForm{" +
|
@ -1,8 +1,7 @@
|
|||||||
package ru.ulstu.extractor.mvc.model;
|
package ru.ulstu.extractor.model.mvc;
|
||||||
|
|
||||||
public class RepoForm {
|
public class RepoForm {
|
||||||
private String repo;
|
private String repo;
|
||||||
|
|
||||||
private String branch;
|
private String branch;
|
||||||
|
|
||||||
public String getRepo() {
|
public String getRepo() {
|
||||||
@ -24,7 +23,8 @@ public class RepoForm {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "RepoForm{" +
|
return "RepoForm{" +
|
||||||
"subject='" + repo +
|
"repo='" + repo + '\'' +
|
||||||
|
", branch='" + branch + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package ru.ulstu.extractor.repository;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
import ru.ulstu.extractor.model.Author;
|
||||||
|
import ru.ulstu.extractor.model.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface AuthorRepository extends JpaRepository<Author, Integer> {
|
||||||
|
@Query("SELECT a FROM Commit c, Repository r, Branch b, Author a WHERE c.author = a AND c.branch = b AND r = b.repository AND r = :repository AND b.name = :branchName")
|
||||||
|
List<Author> findByRepositoryAndBranch(@Param("repository") Repository repository, @Param("branchName") String branchName);
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package ru.ulstu.extractor.repository;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import ru.ulstu.extractor.model.Branch;
|
||||||
|
import ru.ulstu.extractor.model.Repository;
|
||||||
|
|
||||||
|
public interface BranchRepository extends JpaRepository<Branch, Integer> {
|
||||||
|
Branch findByRepositoryAndName(Repository repository, String name);
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package ru.ulstu.extractor.repository;
|
||||||
|
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
import ru.ulstu.extractor.model.Commit;
|
||||||
|
import ru.ulstu.extractor.model.Repository;
|
||||||
|
|
||||||
|
public interface CommitRepository extends JpaRepository<Commit, Integer> {
|
||||||
|
@Query("SELECT c FROM Commit c, Repository r, Branch b WHERE c.branch = b AND r = b.repository AND r = :repository AND b.name = :branchName")
|
||||||
|
Page<Commit> findByRepositoryAndBranch(Pageable pageable, @Param("repository") Repository repository, @Param("branchName") String branchName);
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package ru.ulstu.extractor.repository;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import ru.ulstu.extractor.model.Repository;
|
||||||
|
|
||||||
|
public interface RepositoryRepository extends JpaRepository<Repository, Integer> {
|
||||||
|
Repository findByUrl(String url);
|
||||||
|
}
|
39
src/main/java/ru/ulstu/extractor/service/CommitService.java
Normal file
39
src/main/java/ru/ulstu/extractor/service/CommitService.java
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package ru.ulstu.extractor.service;
|
||||||
|
|
||||||
|
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.PageImpl;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import ru.ulstu.extractor.model.Commit;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CommitService {
|
||||||
|
private final GitRepositoryService gitRepositoryService;
|
||||||
|
|
||||||
|
public CommitService(GitRepositoryService gitRepositoryService) {
|
||||||
|
this.gitRepositoryService = gitRepositoryService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Page<Commit> findPaginated(Pageable pageable, String repositoryUrl, String branchName) throws GitAPIException, IOException {
|
||||||
|
int pageSize = pageable.getPageSize();
|
||||||
|
int currentPage = pageable.getPageNumber();
|
||||||
|
int startItem = currentPage * pageSize;
|
||||||
|
List<Commit> commits = gitRepositoryService.getCommits(repositoryUrl, branchName);
|
||||||
|
|
||||||
|
if (commits.size() < startItem) {
|
||||||
|
commits = Collections.emptyList();
|
||||||
|
} else {
|
||||||
|
int toIndex = Math.min(startItem + pageSize, commits.size());
|
||||||
|
commits = commits.subList(startItem, toIndex);
|
||||||
|
}
|
||||||
|
return new PageImpl<>(commits, PageRequest.of(currentPage, pageSize), commits.size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1,32 +1,13 @@
|
|||||||
package ru.ulstu.extractor.service;
|
package ru.ulstu.extractor.service;
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import ru.ulstu.extractor.model.Commit;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class FilteringService {
|
public class FilteringService {
|
||||||
|
|
||||||
private final GitRepositoryService gitRepositoryService;
|
private final IndexService indexService;
|
||||||
|
|
||||||
public FilteringService(GitRepositoryService gitRepositoryService) {
|
public FilteringService(IndexService indexService) {
|
||||||
this.gitRepositoryService = gitRepositoryService;
|
this.indexService = indexService;
|
||||||
}
|
|
||||||
|
|
||||||
public List<Commit> getCommits(String urlRepo) {
|
|
||||||
return getCommits(urlRepo, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Commit> getCommits(String urlRepo, String filterCommitMessage) {
|
|
||||||
if (filterCommitMessage != null) {
|
|
||||||
return getCommits(urlRepo)
|
|
||||||
.stream()
|
|
||||||
.filter(commit -> commit.getMessage().contains(filterCommitMessage))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
} else {
|
|
||||||
return getCommits(urlRepo);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,19 @@
|
|||||||
package ru.ulstu.extractor.service;
|
package ru.ulstu.extractor.service;
|
||||||
|
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.eclipse.jgit.api.CreateBranchCommand;
|
||||||
import org.eclipse.jgit.api.Git;
|
import org.eclipse.jgit.api.Git;
|
||||||
import org.eclipse.jgit.api.ListBranchCommand;
|
import org.eclipse.jgit.api.ListBranchCommand;
|
||||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||||
import org.eclipse.jgit.diff.DiffFormatter;
|
import org.eclipse.jgit.diff.DiffFormatter;
|
||||||
import org.eclipse.jgit.internal.storage.file.FileRepository;
|
import org.eclipse.jgit.internal.storage.file.FileRepository;
|
||||||
|
import org.eclipse.jgit.lib.Ref;
|
||||||
import org.eclipse.jgit.lib.Repository;
|
import org.eclipse.jgit.lib.Repository;
|
||||||
import org.eclipse.jgit.revwalk.RevCommit;
|
import org.eclipse.jgit.revwalk.RevCommit;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import ru.ulstu.extractor.model.Author;
|
||||||
import ru.ulstu.extractor.model.Branch;
|
import ru.ulstu.extractor.model.Branch;
|
||||||
import ru.ulstu.extractor.model.Changes;
|
|
||||||
import ru.ulstu.extractor.model.Commit;
|
import ru.ulstu.extractor.model.Commit;
|
||||||
import ru.ulstu.extractor.model.FileChange;
|
import ru.ulstu.extractor.model.FileChange;
|
||||||
import ru.ulstu.extractor.model.LineChange;
|
import ru.ulstu.extractor.model.LineChange;
|
||||||
@ -30,6 +33,7 @@ import static org.apache.logging.log4j.util.Strings.isBlank;
|
|||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class GitRepositoryService {
|
public class GitRepositoryService {
|
||||||
|
private static final String BRANCH_PREFIX = "refs/remotes/origin/";
|
||||||
@Value("${extractor.custom-projects-dir}")
|
@Value("${extractor.custom-projects-dir}")
|
||||||
private String customProjectsDir;
|
private String customProjectsDir;
|
||||||
|
|
||||||
@ -39,14 +43,14 @@ public class GitRepositoryService {
|
|||||||
Repository localRepo = new FileRepository(getProjectGitDirectory(url));
|
Repository localRepo = new FileRepository(getProjectGitDirectory(url));
|
||||||
git = new Git(localRepo);
|
git = new Git(localRepo);
|
||||||
git.pull().call();
|
git.pull().call();
|
||||||
|
localRepo.close();
|
||||||
} else {
|
} else {
|
||||||
git = Git.cloneRepository()
|
git = Git.cloneRepository()
|
||||||
.setURI(url)
|
.setURI(url)
|
||||||
.setDirectory(getProjectDirectoryFile(url))
|
.setDirectory(getProjectDirectoryFile(url))
|
||||||
.call();
|
.call();
|
||||||
}
|
}
|
||||||
Iterable<RevCommit> commits = git.log().call();
|
git.close();
|
||||||
//commits.forEach(c -> System.out.println(c.getFullMessage()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getProjectDirectory(String url) {
|
private String getProjectDirectory(String url) {
|
||||||
@ -68,13 +72,20 @@ public class GitRepositoryService {
|
|||||||
return file.exists();
|
return file.exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Commit> getCommits(String url) throws GitAPIException, IOException {
|
public List<Commit> getCommits(String repositoryUrl, String branchName) throws GitAPIException, IOException {
|
||||||
cloneOrUpdateRepo(url);
|
cloneOrUpdateRepo(repositoryUrl);
|
||||||
Repository localRepo = new FileRepository(getProjectGitDirectory(url));
|
Repository localRepo = new FileRepository(getProjectGitDirectory(repositoryUrl));
|
||||||
Git git = new Git(localRepo);
|
Git git = new Git(localRepo);
|
||||||
git.pull().call();
|
git.pull().call();
|
||||||
|
if (!localRepo.getBranch().equals(branchName)) {
|
||||||
|
Ref ref = git.checkout().
|
||||||
|
setCreateBranch(true).
|
||||||
|
setName(branchName).
|
||||||
|
setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.TRACK).
|
||||||
|
setStartPoint("origin/" + branchName).
|
||||||
|
call();
|
||||||
|
}
|
||||||
List<RevCommit> commits = new ArrayList<>();
|
List<RevCommit> commits = new ArrayList<>();
|
||||||
//TODO: сделать преобразование в коллекцию "наших объектов"
|
|
||||||
git.log().call().forEach(commits::add);
|
git.log().call().forEach(commits::add);
|
||||||
|
|
||||||
List<Commit> list = new ArrayList<>();
|
List<Commit> list = new ArrayList<>();
|
||||||
@ -82,18 +93,21 @@ public class GitRepositoryService {
|
|||||||
for (RevCommit revCommit : commits) {
|
for (RevCommit revCommit : commits) {
|
||||||
Commit commit = new Commit(
|
Commit commit = new Commit(
|
||||||
revCommit.getFullMessage(),
|
revCommit.getFullMessage(),
|
||||||
revCommit.getAuthorIdent().getName(),
|
new Author(revCommit.getAuthorIdent().getName()),
|
||||||
Date.from(Instant.ofEpochSecond(revCommit.getCommitTime())));
|
Date.from(Instant.ofEpochSecond(revCommit.getCommitTime())),
|
||||||
|
revCommit.getName());
|
||||||
if (prevCommit != null) {
|
if (prevCommit != null) {
|
||||||
commit.setChanges(findDiffBetweenTwoRevisions(revCommit, prevCommit, localRepo));
|
commit.setFileChanges(findDiffBetweenTwoRevisions(revCommit, prevCommit, localRepo));
|
||||||
}
|
}
|
||||||
list.add(commit);
|
list.add(commit);
|
||||||
prevCommit = revCommit;
|
prevCommit = revCommit;
|
||||||
}
|
}
|
||||||
|
git.close();
|
||||||
|
localRepo.close();
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Changes findDiffBetweenTwoRevisions(RevCommit laterCommit, RevCommit earlierCommit, Repository localRepo) {
|
public List<FileChange> findDiffBetweenTwoRevisions(RevCommit laterCommit, RevCommit earlierCommit, Repository localRepo) {
|
||||||
if (laterCommit == null || earlierCommit == null) {
|
if (laterCommit == null || earlierCommit == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -109,8 +123,8 @@ public class GitRepositoryService {
|
|||||||
return parseOutputDiff(output);
|
return parseOutputDiff(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Changes parseOutputDiff(String output) {
|
private List<FileChange> parseOutputDiff(String output) {
|
||||||
Changes changes = new Changes();
|
List<FileChange> changes = new ArrayList<>();
|
||||||
String[] strings = output.split("\n");
|
String[] strings = output.split("\n");
|
||||||
FileChange fileChange = new FileChange();
|
FileChange fileChange = new FileChange();
|
||||||
int stringsLength = strings.length - 1;
|
int stringsLength = strings.length - 1;
|
||||||
@ -121,7 +135,7 @@ public class GitRepositoryService {
|
|||||||
fileChange = new FileChange();
|
fileChange = new FileChange();
|
||||||
fileChange.setFile(maybeFileName.get());
|
fileChange.setFile(maybeFileName.get());
|
||||||
/// вытащить другие изменения из коммита
|
/// вытащить другие изменения из коммита
|
||||||
changes.getFileChanges().add(fileChange);
|
changes.add(fileChange);
|
||||||
}
|
}
|
||||||
LineChange lineChange = new LineChange();
|
LineChange lineChange = new LineChange();
|
||||||
if (strings[i].startsWith("-")) {
|
if (strings[i].startsWith("-")) {
|
||||||
@ -196,10 +210,17 @@ public class GitRepositoryService {
|
|||||||
cloneOrUpdateRepo(url);
|
cloneOrUpdateRepo(url);
|
||||||
Repository localRepo = new FileRepository(getProjectGitDirectory(url));
|
Repository localRepo = new FileRepository(getProjectGitDirectory(url));
|
||||||
Git git = new Git(localRepo);
|
Git git = new Git(localRepo);
|
||||||
return git.branchList().setListMode(ListBranchCommand.ListMode.REMOTE)
|
List<Branch> branches = git.branchList().setListMode(ListBranchCommand.ListMode.REMOTE)
|
||||||
.call()
|
.call()
|
||||||
.stream()
|
.stream()
|
||||||
.map(r -> new Branch(r.getName()))
|
.map(r -> new Branch(r.getName().replace(BRANCH_PREFIX, "")))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
git.close();
|
||||||
|
localRepo.close();
|
||||||
|
return branches;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove(String repositoryUrl) throws IOException {
|
||||||
|
FileUtils.deleteDirectory(getProjectDirectoryFile(repositoryUrl));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
65
src/main/java/ru/ulstu/extractor/service/IndexService.java
Normal file
65
src/main/java/ru/ulstu/extractor/service/IndexService.java
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
package ru.ulstu.extractor.service;
|
||||||
|
|
||||||
|
import com.sun.istack.NotNull;
|
||||||
|
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import ru.ulstu.extractor.model.Author;
|
||||||
|
import ru.ulstu.extractor.model.Branch;
|
||||||
|
import ru.ulstu.extractor.model.Commit;
|
||||||
|
import ru.ulstu.extractor.model.Repository;
|
||||||
|
import ru.ulstu.extractor.repository.AuthorRepository;
|
||||||
|
import ru.ulstu.extractor.repository.BranchRepository;
|
||||||
|
import ru.ulstu.extractor.repository.CommitRepository;
|
||||||
|
import ru.ulstu.extractor.repository.RepositoryRepository;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class IndexService {
|
||||||
|
private final GitRepositoryService gitRepositoryService;
|
||||||
|
private final RepositoryRepository repositoryRepository;
|
||||||
|
private final BranchRepository branchRepository;
|
||||||
|
private final CommitRepository commitRepository;
|
||||||
|
private final AuthorRepository authorRepository;
|
||||||
|
|
||||||
|
|
||||||
|
public IndexService(GitRepositoryService gitRepositoryService,
|
||||||
|
RepositoryRepository repositoryRepository,
|
||||||
|
BranchRepository branchRepository,
|
||||||
|
CommitRepository commitRepository,
|
||||||
|
AuthorRepository authorRepository) {
|
||||||
|
this.gitRepositoryService = gitRepositoryService;
|
||||||
|
this.repositoryRepository = repositoryRepository;
|
||||||
|
this.branchRepository = branchRepository;
|
||||||
|
this.commitRepository = commitRepository;
|
||||||
|
this.authorRepository = authorRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void index(@NotNull String repositoryUrl, @NotNull String branchName) throws GitAPIException, IOException {
|
||||||
|
Repository repository = repositoryRepository.findByUrl(repositoryUrl);
|
||||||
|
if (repository == null) {
|
||||||
|
repositoryRepository.save(new Repository(repositoryUrl));
|
||||||
|
}
|
||||||
|
Branch branch = branchRepository.findByRepositoryAndName(repository, branchName);
|
||||||
|
if (branch == null) {
|
||||||
|
branchRepository.save(new Branch(repository, branchName));
|
||||||
|
}
|
||||||
|
List<Commit> commits = gitRepositoryService.getCommits(repositoryUrl, branchName);
|
||||||
|
commitRepository.deleteAll(branch.getCommits());
|
||||||
|
branch.getCommits().clear();
|
||||||
|
branch.setCommits(commits);
|
||||||
|
branchRepository.save(branch);
|
||||||
|
gitRepositoryService.remove(repositoryUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Author> getRepositoryAuthors(@NotNull String repositoryUrl, @NotNull String branchName) {
|
||||||
|
return authorRepository.findByRepositoryAndBranch(repositoryRepository.findByUrl(repositoryUrl), branchName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Page<Commit> getCommits(@NotNull String repositoryUrl, @NotNull String branchName, Pageable pageable) {
|
||||||
|
return commitRepository.findByRepositoryAndBranch(pageable, repositoryRepository.findByUrl(repositoryUrl), branchName);
|
||||||
|
}
|
||||||
|
}
|
@ -11,6 +11,9 @@ spring.datasource.url=jdbc:postgresql://localhost:5432/repo
|
|||||||
spring.datasource.username=postgres
|
spring.datasource.username=postgres
|
||||||
spring.datasource.password=postgres
|
spring.datasource.password=postgres
|
||||||
spring.datasource.driverclassName=org.postgresql.Driver
|
spring.datasource.driverclassName=org.postgresql.Driver
|
||||||
|
spring.jpa.hibernate.ddl-auto=validate
|
||||||
|
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
|
||||||
|
spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults=false
|
||||||
# Liquibase Settings
|
# Liquibase Settings
|
||||||
spring.liquibase.drop-first=false
|
spring.liquibase.drop-first=false
|
||||||
spring.liquibase.enabled=true
|
spring.liquibase.enabled=true
|
||||||
|
73
src/main/resources/db/changelog-20210326_170000-schema.xml
Normal file
73
src/main/resources/db/changelog-20210326_170000-schema.xml
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
|
||||||
|
<changeSet author="barmina" id="20210326-170000-1">
|
||||||
|
<createTable tableName="repository">
|
||||||
|
<column name="id" type="integer">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="url" type="text"/>
|
||||||
|
</createTable>
|
||||||
|
<addPrimaryKey columnNames="id" constraintName="pk_repository" tableName="repository"/>
|
||||||
|
|
||||||
|
<createTable tableName="branch">
|
||||||
|
<column name="id" type="integer">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="name" type="text"/>
|
||||||
|
<column name="repository_id" type="integer"/>
|
||||||
|
</createTable>
|
||||||
|
<addPrimaryKey columnNames="id" constraintName="pk_branch" tableName="branch"/>
|
||||||
|
<addForeignKeyConstraint baseTableName="branch" baseColumnNames="repository_id" constraintName="fk_repository"
|
||||||
|
referencedTableName="repository"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
|
||||||
|
<createTable tableName="author">
|
||||||
|
<column name="id" type="integer">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="name" type="text"/>
|
||||||
|
</createTable>
|
||||||
|
<addPrimaryKey columnNames="id" constraintName="pk_author" tableName="author"/>
|
||||||
|
|
||||||
|
<createTable tableName="file_change">
|
||||||
|
<column name="id" type="integer">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="file" type="text"/>
|
||||||
|
<column name="commit_id" type="integer"/>
|
||||||
|
</createTable>
|
||||||
|
<addPrimaryKey columnNames="id" constraintName="pk_file_change" tableName="file_change"/>
|
||||||
|
<addForeignKeyConstraint baseTableName="file_change" baseColumnNames="commit_id" constraintName="fk_commit"
|
||||||
|
referencedTableName="commit"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
|
||||||
|
<createTable tableName="line_change">
|
||||||
|
<column name="id" type="integer">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="line_from" type="text"/>
|
||||||
|
<column name="line_to" type="text"/>
|
||||||
|
<column name="file_change_id" type="integer"/>
|
||||||
|
</createTable>
|
||||||
|
<addPrimaryKey columnNames="id" constraintName="pk_line_change" tableName="line_change"/>
|
||||||
|
<addForeignKeyConstraint baseTableName="line_change" baseColumnNames="file_change_id"
|
||||||
|
constraintName="fk_file_change" referencedTableName="file_change"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
|
||||||
|
<dropColumn tableName="commit" columnName="author"/>
|
||||||
|
<addColumn tableName="commit">
|
||||||
|
<column name="author_id" type="integer"/>
|
||||||
|
</addColumn>
|
||||||
|
<addColumn tableName="commit">
|
||||||
|
<column name="branch_id" type="integer"/>
|
||||||
|
</addColumn>
|
||||||
|
<addForeignKeyConstraint baseTableName="commit" baseColumnNames="author_id" constraintName="fk_author"
|
||||||
|
referencedTableName="author"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
<addForeignKeyConstraint baseTableName="commit" baseColumnNames="branch_id" constraintName="fk_branch"
|
||||||
|
referencedTableName="branch"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
38
src/main/resources/db/changelog-20210329_120000-schema.xml
Normal file
38
src/main/resources/db/changelog-20210329_120000-schema.xml
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
|
||||||
|
<changeSet author="orion" id="20210329-120000-1">
|
||||||
|
<addColumn tableName="repository">
|
||||||
|
<column name="version" type="integer"/>
|
||||||
|
</addColumn>
|
||||||
|
<addColumn tableName="branch">
|
||||||
|
<column name="version" type="integer"/>
|
||||||
|
</addColumn>
|
||||||
|
<addColumn tableName="commit">
|
||||||
|
<column name="version" type="integer"/>
|
||||||
|
</addColumn>
|
||||||
|
<addColumn tableName="author">
|
||||||
|
<column name="version" type="integer"/>
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
|
<changeSet author="orion" id="20210329-120000-2">
|
||||||
|
<addColumn tableName="file_change">
|
||||||
|
<column name="version" type="integer"/>
|
||||||
|
</addColumn>
|
||||||
|
<addColumn tableName="line_change">
|
||||||
|
<column name="version" type="integer"/>
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
|
<changeSet author="orion" id="20210329-120000-3" objectQuotingStrategy="QUOTE_ALL_OBJECTS">
|
||||||
|
<createTable tableName="hibernate_sequences">
|
||||||
|
<column name="sequence_name" type="VARCHAR(255)">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="sequence_next_hi_value" type="BIGINT"/>
|
||||||
|
<column name="next_val" type="bigint"/>
|
||||||
|
</createTable>
|
||||||
|
<addPrimaryKey columnNames="sequence_name" constraintName="hibernate_sequences_pkey"
|
||||||
|
tableName="hibernate_sequences"/>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -4,4 +4,6 @@
|
|||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
|
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
|
||||||
<include file="db/changelog-20210317_140000-schema.xml"/>
|
<include file="db/changelog-20210317_140000-schema.xml"/>
|
||||||
|
<include file="db/changelog-20210326_170000-schema.xml"/>
|
||||||
|
<include file="db/changelog-20210329_120000-schema.xml"/>
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
|
@ -19,14 +19,10 @@
|
|||||||
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
<span class="navbar-toggler-icon"></span>
|
<span class="navbar-toggler-icon"></span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||||
<ul class="navbar-nav mr-auto">
|
<ul class="navbar-nav mr-auto">
|
||||||
<li class="nav-item active">
|
|
||||||
<a class="nav-link" href="/" th:text="#{messages.menu.home}">Home</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="#" th:text="#{messages.menu.new-repo}">Link</a>
|
<a class="nav-link" href="/" th:text="#{messages.menu.new-repo}">Link</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="#" th:text="#{messages.menu.indexed-repos}">Link</a>
|
<a class="nav-link" href="#" th:text="#{messages.menu.indexed-repos}">Link</a>
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||||
</head>
|
</head>
|
||||||
<div class="container" layout:fragment="content">
|
<div class="container" layout:fragment="content">
|
||||||
<body>
|
|
||||||
<form action="#" th:action="@{/sendFilter}" th:object="${filterForm}" method="post">
|
<form action="#" th:action="@{/sendFilter}" th:object="${filterForm}" method="post">
|
||||||
<p><b>Фильтровать данные:</b><Br></p>
|
<p><b>Фильтровать данные:</b><Br></p>
|
||||||
По автору
|
По автору
|
||||||
@ -30,23 +29,30 @@
|
|||||||
<input type="hidden" th:field="*{url}">
|
<input type="hidden" th:field="*{url}">
|
||||||
</p>
|
</p>
|
||||||
<p style="color:red" th:text="${error}"></p>
|
<p style="color:red" th:text="${error}"></p>
|
||||||
<!-- <table>-->
|
<table class="table table-striped">
|
||||||
<!-- <tr>-->
|
<thead class="thead-dark">
|
||||||
<!-- <th>Author</th>-->
|
<tr>
|
||||||
<!-- <th>Date</th>-->
|
<th scope="col">Author</th>
|
||||||
<!-- <th>Commit</th>-->
|
<th scope="col" style="width: 30%">Date</th>
|
||||||
<!-- </tr>-->
|
<th scope="col">Commit</th>
|
||||||
<!-- <tr th:each="commit : ${commits}">-->
|
</tr>
|
||||||
<!-- <td th:text="${commit.author}">Onions</td>-->
|
</thead>
|
||||||
<!-- <td th:text="${commit.date}">2.41</td>-->
|
<tbody>
|
||||||
<!-- <td th:text="${commit.message}">yes</td>-->
|
<tr th:each="commit: ${filterForm.commitsPage.content}">
|
||||||
<!-- </tr>-->
|
<td th:text="${commit.author.name}"></td>
|
||||||
<!-- </table>-->
|
<td th:text="${commit.date}"></td>
|
||||||
|
<td th:text="${commit.message}"></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
<p>
|
<p>
|
||||||
<input type="submit" value="Отправить"/>
|
<input type="submit" value="Отправить"/>
|
||||||
</p>
|
</p>
|
||||||
</form>
|
</form>
|
||||||
</body>
|
</div>
|
||||||
|
<div th:if="${filterForm.commitPage.totalPages > 0}" class="pagination"
|
||||||
|
th:each="pageNumber : ${pageNumbers}">
|
||||||
|
<a th:href="@{/filtering.html(size=${commitPage.size}, page=${pageNumber})}"
|
||||||
|
th:class="${pageNumber==commitPage.number + 1} ? active"></a>
|
||||||
</div>
|
</div>
|
||||||
</html>
|
</html>
|
||||||
|
@ -3,34 +3,61 @@
|
|||||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||||
layout:decorate="~{default}">
|
layout:decorate="~{default}">
|
||||||
<head>
|
<head>
|
||||||
<title>Простая обработка формы на Spring MVC</title>
|
<title>Индексировать новый репозиторий</title>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||||
</head>
|
</head>
|
||||||
<div class="container" layout:fragment="content">
|
<div class="container" layout:fragment="content">
|
||||||
<body>
|
|
||||||
<form action="#" th:action="@{/newRepo}" th:object="${repoForm}" method="post">
|
<form action="#" th:action="@{/newRepo}" th:object="${repoForm}" method="post">
|
||||||
<p style="color:red" th:text="${error}"></p>
|
<p style="color:red" th:text="${error}"></p>
|
||||||
<p><b>Ваш git репозиторий:</b><br>
|
<button class="btn btn-outline-dark dropdown-toggle" type="button" data-toggle="collapse"
|
||||||
<input type="text" size="40" th:field="*{repo}">
|
data-target="#collapseOne" aria-expanded="false" aria-controls="collapseExample"
|
||||||
</p>
|
th:if="${repoForm.repo != null}"
|
||||||
<p>
|
th:text="${repoForm.repo == null ? 'Репозиторий' : repoForm.repo}">
|
||||||
<input type="submit" name="send" value="Отправить"/>
|
Button with data-target
|
||||||
</p>
|
</button>
|
||||||
<p>Ветки:<br>
|
<div id="collapseOne" th:class="${repoForm.repo == null ? 'collapse show' : 'collapse'}"
|
||||||
<select id="select-branch" class="selectpicker" data-live-search="true" th:field="*{branch}">
|
aria-labelledby="headingOne">
|
||||||
<option th:each="branch : ${branches}"
|
<div class="card-body">
|
||||||
th:value="${branch.name}"
|
<div class="form-group">
|
||||||
th:utext="${branch.name}"/>
|
<label for="repoUrl">Ваш git репозиторий (https url):</label>
|
||||||
</option>
|
<div class="row">
|
||||||
</select>
|
<div class="col-md-8 col-sm-12">
|
||||||
</p>
|
<input id="repoUrl" type="text" class="form-control"
|
||||||
<p>
|
aria-label="Ваш git репозиторий (https url)"
|
||||||
<input type="submit" name="next" value="Продолжить"/>
|
th:field="*{repo}">
|
||||||
</p>
|
</div>
|
||||||
|
<div class="col-md-4 col-sm-12">
|
||||||
|
<input type="submit" class="btn btn-outline-primary w-100" name="send"
|
||||||
|
value="Индексировать"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="collapseTwo" class="collapse show" aria-labelledby="headingOne" th:if="${repoForm.repo != null}">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="select-branch">Ветки:</label>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-8 col-sm-12">
|
||||||
|
<select id="select-branch" class="selectpicker" data-live-search="true" th:field="*{branch}"
|
||||||
|
data-width="90%">
|
||||||
|
<option th:each="branch : ${branches}"
|
||||||
|
th:value="${branch.name}"
|
||||||
|
th:utext="${branch.name}"/>
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4 col-sm-12">
|
||||||
|
<input type="submit" class="btn btn-outline-success w-100" name="next" value="Продолжить"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</body>
|
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script language="JavaScript">
|
||||||
$('#select-branch').selectpicker('refresh');
|
$('#select-branch').selectpicker('refresh');
|
||||||
</script>
|
</script>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user