@ -98,9 +98,11 @@ public class GitRepositoryService {
return branches ;
return branches ;
}
}
public List < Commit > getCommits ( String repositoryUrl , String branchName ) throws GitAPIException , IOException {
public List < Commit > getCommits ( String repositoryUrl , String branchName , int commitsFrom , int commitsTo , boolean needUpdate ) throws GitAPIException , IOException {
LOG . debug ( "Get commits of {}. Branch {}" , repositoryUrl , branchName ) ;
LOG . debug ( "Get commits of {}. Branch {}" , repositoryUrl , branchName ) ;
cloneOrUpdateRepo ( repositoryUrl , branchName ) ;
if ( needUpdate ) {
cloneOrUpdateRepo ( repositoryUrl , branchName ) ;
}
Repository localRepo = new FileRepository ( getProjectGitDirectory ( repositoryUrl ) ) ;
Repository localRepo = new FileRepository ( getProjectGitDirectory ( repositoryUrl ) ) ;
Git git = new Git ( localRepo ) ;
Git git = new Git ( localRepo ) ;
@ -110,9 +112,12 @@ public class GitRepositoryService {
List < Commit > list = new ArrayList < > ( ) ;
List < Commit > list = new ArrayList < > ( ) ;
RevCommit prevCommit = null ;
RevCommit prevCommit = null ;
LOG . debug ( "Start analyse {} commits" , commits . size ( ) ) ;
LOG . debug ( "Start analyse {} commits" , commits . size ( ) ) ;
int counter = commits . size ( ) ;
commitsFrom = Math . max ( commitsFrom , 0 ) ;
for ( RevCommit revCommit : commits ) {
commitsTo = Math . min ( commitsTo , commits . size ( ) ) ;
LOG . debug ( " {} of {} commits" , counter - - , commits . size ( ) ) ;
commitsTo = Math . max ( commitsTo , 0 ) ;
for ( int i = commitsFrom ; i < commitsTo ; i + + ) {
RevCommit revCommit = commits . get ( i ) ;
LOG . debug ( " {} to {} commits" , i , commitsTo ) ;
Commit commit = new Commit (
Commit commit = new Commit (
revCommit . getFullMessage ( ) ,
revCommit . getFullMessage ( ) ,
new Author ( revCommit . getAuthorIdent ( ) . getName ( ) ) ,
new Author ( revCommit . getAuthorIdent ( ) . getName ( ) ) ,
@ -229,7 +234,7 @@ public class GitRepositoryService {
if ( laterCommit = = null | | earlierCommit = = null ) {
if ( laterCommit = = null | | earlierCommit = = null ) {
return null ;
return null ;
}
}
String output = null ;
String output ;
try ( ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ) {
try ( ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ) {
DiffFormatter diffFormatter = new DiffFormatter ( out ) ;
DiffFormatter diffFormatter = new DiffFormatter ( out ) ;
diffFormatter . setRepository ( localRepo ) ;
diffFormatter . setRepository ( localRepo ) ;
@ -252,13 +257,8 @@ public class GitRepositoryService {
if ( maybeFileName . isPresent ( ) ) {
if ( maybeFileName . isPresent ( ) ) {
fileChange = new FileChange ( ) ;
fileChange = new FileChange ( ) ;
fileChange . setFile ( maybeFileName . get ( ) ) ;
fileChange . setFile ( maybeFileName . get ( ) ) ;
Future < Boolean > futureEntity = executorService . submit ( ( ) - > {
Future < Boolean > futureEntity = executorService . submit ( ( ) - > structuralUnitService . containsEntity ( getContent ( repository , commit , maybeFileName . get ( ) ) ) ) ;
return structuralUnitService . containsEntity ( getContent ( repository , commit , maybeFileName . get ( ) ) ) ;
Future < Boolean > futureBL = executorService . submit ( ( ) - > structuralUnitService . containsBusinessLogic ( getContent ( repository , commit , maybeFileName . get ( ) ) ) ) ;
} ) ;
Future < Boolean > futureBL = executorService . submit ( ( ) - > {
return structuralUnitService . containsBusinessLogic ( getContent ( repository , commit , maybeFileName . get ( ) ) ) ;
} ) ;
try {
try {
fileChange . setContainsBusinessLogic ( futureBL . get ( ) ) ;
fileChange . setContainsBusinessLogic ( futureBL . get ( ) ) ;
fileChange . setContainsEntity ( futureEntity . get ( ) ) ;
fileChange . setContainsEntity ( futureEntity . get ( ) ) ;