add controller
This commit is contained in:
parent
d9eab69b68
commit
685eb9584d
@ -54,6 +54,8 @@ dependencies {
|
|||||||
compile group: 'io.springfox', name: 'springfox-boot-starter', version: '3.0.0'
|
compile group: 'io.springfox', name: 'springfox-boot-starter', version: '3.0.0'
|
||||||
|
|
||||||
compile group: 'com.ibm.icu', name: 'icu4j', version: '63.1'
|
compile group: 'com.ibm.icu', name: 'icu4j', version: '63.1'
|
||||||
|
compile group: 'org.eclipse.jgit', name: 'org.eclipse.jgit', version: '5.9.0.202009080501-r'
|
||||||
|
|
||||||
testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test'
|
testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
22
src/main/java/ru/ulstu/extractor/GitRepositoryService.java
Normal file
22
src/main/java/ru/ulstu/extractor/GitRepositoryService.java
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package ru.ulstu.extractor;
|
||||||
|
|
||||||
|
import org.eclipse.jgit.api.Git;
|
||||||
|
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||||
|
import org.eclipse.jgit.revwalk.RevCommit;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class GitRepositoryService {
|
||||||
|
private final static String LOCAL_PATH = "c:\\temp\\1";
|
||||||
|
|
||||||
|
public void clone(String url) throws GitAPIException {
|
||||||
|
Git git = Git.cloneRepository()
|
||||||
|
.setURI(url)
|
||||||
|
.setDirectory(Path.of(LOCAL_PATH).toFile())
|
||||||
|
.call();
|
||||||
|
Iterable<RevCommit> commits = git.log().call();
|
||||||
|
commits.forEach(c -> System.out.println(c.getFullMessage()));
|
||||||
|
}
|
||||||
|
}
|
25
src/main/java/ru/ulstu/extractor/RepoController.java
Normal file
25
src/main/java/ru/ulstu/extractor/RepoController.java
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package ru.ulstu.extractor;
|
||||||
|
|
||||||
|
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import static ru.ulstu.extractor.RepoController.URL;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(URL)
|
||||||
|
public class RepoController {
|
||||||
|
public static final String URL = "/";
|
||||||
|
private final GitRepositoryService gitRepositoryService;
|
||||||
|
|
||||||
|
public RepoController(GitRepositoryService gitRepositoryService) {
|
||||||
|
this.gitRepositoryService = gitRepositoryService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("clone")
|
||||||
|
public void cloneRepository(@RequestParam("url") String url) throws GitAPIException {
|
||||||
|
gitRepositoryService.clone(url);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user