diff --git a/docs/reports/4.2-SNAPSHOT/ci-management.html b/docs/reports/4.2-SNAPSHOT/ci-management.html
index ef25489a8..3e33a8be4 100644
--- a/docs/reports/4.2-SNAPSHOT/ci-management.html
+++ b/docs/reports/4.2-SNAPSHOT/ci-management.html
@@ -1,6 +1,6 @@
@@ -25,7 +25,7 @@
- Last Published: 2022-03-30
+ Last Published: 2022-04-01
| Version: 4.2-SNAPSHOT
diff --git a/docs/reports/4.2-SNAPSHOT/dependency-convergence.html b/docs/reports/4.2-SNAPSHOT/dependency-convergence.html
index 23344ea2f..7a5d197cf 100644
--- a/docs/reports/4.2-SNAPSHOT/dependency-convergence.html
+++ b/docs/reports/4.2-SNAPSHOT/dependency-convergence.html
@@ -1,6 +1,6 @@
@@ -25,7 +25,7 @@
- Last Published: 2022-03-30
+ Last Published: 2022-04-01
| Version: 4.2-SNAPSHOT
@@ -84,10 +84,10 @@
Reactor Dependency Convergence<
4
Number of dependencies (NOD):
-84
+88
Number of unique artifacts (NOA):
-103
+107
Number of version-conflicting artifacts (NOC):
10
@@ -96,7 +96,7 @@ Reactor Dependency Convergence<
0
Convergence (NOD/NOA):
- 81 %
+ 82 %
Ready for release (100% convergence and no SNAPSHOTS):
Error You do not have 100% convergence.
@@ -127,12 +127,12 @@ com.trilead:trilead-ssh2
1.0.0-build217
-com.mycila:license-maven-plugin-svn:jar:4.2-SNAPSHOT \- org.tmatesoft.svnkit:svnkit:jar:1.10.4:compile \- com.jcraft:jsch.agentproxy.svnkit-trilead-ssh2:jar:0.0.7:compile \- (com.trilead:trilead-ssh2:jar:1.0.0-build217:compile - omitted for conflict with 1.0.0-build222)
+com.mycila:license-maven-plugin-svn:jar:4.2-SNAPSHOT \- org.tmatesoft.svnkit:svnkit:jar:1.10.5:compile \- com.jcraft:jsch.agentproxy.svnkit-trilead-ssh2:jar:0.0.7:compile \- (com.trilead:trilead-ssh2:jar:1.0.0-build217:compile - omitted for conflict with 1.0.0-build222)
1.0.0-build222
-com.mycila:license-maven-plugin-svn:jar:4.2-SNAPSHOT \- org.tmatesoft.svnkit:svnkit:jar:1.10.4:compile \- com.trilead:trilead-ssh2:jar:1.0.0-build222:compile
+com.mycila:license-maven-plugin-svn:jar:4.2-SNAPSHOT \- org.tmatesoft.svnkit:svnkit:jar:1.10.5:compile \- com.trilead:trilead-ssh2:jar:1.0.0-build222:compile
commons-io:commons-io
@@ -159,12 +159,12 @@ net.java.dev.jna:jna
3.4.0
-com.mycila:license-maven-plugin-svn:jar:4.2-SNAPSHOT \- org.tmatesoft.svnkit:svnkit:jar:1.10.4:compile \- com.jcraft:jsch.agentproxy.connector-factory:jar:0.0.7:compile +- com.jcraft:jsch.agentproxy.usocket-jna:jar:0.0.7:compile | \- (net.java.dev.jna:jna:jar:3.4.0:compile - omitted for conflict with 5.6.0) \- com.jcraft:jsch.agentproxy.pageant:jar:0.0.7:compile \- (net.java.dev.jna:jna:jar:3.4.0:compile - omitted for conflict with 5.6.0)
+com.mycila:license-maven-plugin-svn:jar:4.2-SNAPSHOT \- org.tmatesoft.svnkit:svnkit:jar:1.10.5:compile \- com.jcraft:jsch.agentproxy.connector-factory:jar:0.0.7:compile +- com.jcraft:jsch.agentproxy.usocket-jna:jar:0.0.7:compile | \- (net.java.dev.jna:jna:jar:3.4.0:compile - omitted for conflict with 5.6.0) \- com.jcraft:jsch.agentproxy.pageant:jar:0.0.7:compile \- (net.java.dev.jna:jna:jar:3.4.0:compile - omitted for conflict with 5.6.0)
5.6.0
-com.mycila:license-maven-plugin-svn:jar:4.2-SNAPSHOT \- org.tmatesoft.svnkit:svnkit:jar:1.10.4:compile +- net.java.dev.jna:jna:jar:5.6.0:compile \- net.java.dev.jna:jna-platform:jar:5.6.0:compile \- (net.java.dev.jna:jna:jar:5.6.0:compile - omitted for duplicate)
+com.mycila:license-maven-plugin-svn:jar:4.2-SNAPSHOT \- org.tmatesoft.svnkit:svnkit:jar:1.10.5:compile +- net.java.dev.jna:jna:jar:5.6.0:compile \- net.java.dev.jna:jna-platform:jar:5.6.0:compile \- (net.java.dev.jna:jna:jar:5.6.0:compile - omitted for duplicate)
org.apache.maven.shared:maven-shared-utils
@@ -292,7 +292,7 @@ org.slf4j:slf4j-api
com.mycila:license-maven-plugin-git:jar:4.2-SNAPSHOT \- com.mycila:license-maven-plugin:jar:4.2-SNAPSHOT:compile \- org.apache.maven.shared:maven-common-artifact-filters:jar:3.2.0:compile \- org.apache.maven:maven-core:jar:3.8.5:compile (version managed from 3.1.1) \- (org.slf4j:slf4j-api:jar:1.7.32:compile - omitted for conflict with 1.7.30)
-com.mycila:license-maven-plugin-svn:jar:4.2-SNAPSHOT \- com.mycila:license-maven-plugin:jar:4.2-SNAPSHOT:compile \- org.apache.maven.shared:maven-common-artifact-filters:jar:3.2.0:compile \- org.apache.maven:maven-core:jar:3.8.5:compile (version managed from 3.1.1) \- org.slf4j:slf4j-api:jar:1.7.32:compile
+com.mycila:license-maven-plugin-svn:jar:4.2-SNAPSHOT +- com.mycila:license-maven-plugin:jar:4.2-SNAPSHOT:compile | \- org.apache.maven.shared:maven-common-artifact-filters:jar:3.2.0:compile | \- org.apache.maven:maven-core:jar:3.8.5:compile (version managed from 3.1.1) | \- (org.slf4j:slf4j-api:jar:1.7.32:compile - omitted for duplicate) \- org.tmatesoft.svnkit:svnkit:jar:1.10.5:compile +- org.apache.sshd:sshd-core:jar:2.8.0:compile | +- org.slf4j:slf4j-api:jar:1.7.32:compile | \- org.slf4j:jcl-over-slf4j:jar:1.7.32:compile | \- (org.slf4j:slf4j-api:jar:1.7.32:compile - omitted for duplicate) \- org.apache.sshd:sshd-common:jar:2.8.0:compile \- (org.slf4j:slf4j-api:jar:1.7.32:compile - omitted for duplicate)
com.mycila:license-maven-plugin:maven-plugin:4.2-SNAPSHOT \- org.apache.maven:maven-core:jar:3.8.5:provided (scope not updated to compile) \- org.slf4j:slf4j-api:jar:1.7.32:provided
diff --git a/docs/reports/4.2-SNAPSHOT/dependency-info.html b/docs/reports/4.2-SNAPSHOT/dependency-info.html
index e6a7a4c4d..bc5a3664c 100644
--- a/docs/reports/4.2-SNAPSHOT/dependency-info.html
+++ b/docs/reports/4.2-SNAPSHOT/dependency-info.html
@@ -1,6 +1,6 @@
@@ -25,7 +25,7 @@
- Last Published: 2022-03-30
+ Last Published: 2022-04-01
| Version: 4.2-SNAPSHOT
diff --git a/docs/reports/4.2-SNAPSHOT/dependency-management.html b/docs/reports/4.2-SNAPSHOT/dependency-management.html
index cb1a94698..46a54230d 100644
--- a/docs/reports/4.2-SNAPSHOT/dependency-management.html
+++ b/docs/reports/4.2-SNAPSHOT/dependency-management.html
@@ -1,6 +1,6 @@
@@ -25,7 +25,7 @@
- Last Published: 2022-03-30
+ Last Published: 2022-04-01
| Version: 4.2-SNAPSHOT
diff --git a/docs/reports/4.2-SNAPSHOT/distribution-management.html b/docs/reports/4.2-SNAPSHOT/distribution-management.html
index f6783f06f..0b8102f8e 100644
--- a/docs/reports/4.2-SNAPSHOT/distribution-management.html
+++ b/docs/reports/4.2-SNAPSHOT/distribution-management.html
@@ -1,6 +1,6 @@
@@ -25,7 +25,7 @@
- Last Published: 2022-03-30
+ Last Published: 2022-04-01
| Version: 4.2-SNAPSHOT
diff --git a/docs/reports/4.2-SNAPSHOT/index.html b/docs/reports/4.2-SNAPSHOT/index.html
index 2aafe6e96..1368715e3 100644
--- a/docs/reports/4.2-SNAPSHOT/index.html
+++ b/docs/reports/4.2-SNAPSHOT/index.html
@@ -1,6 +1,6 @@
@@ -25,7 +25,7 @@
- Last Published: 2022-03-30
+ Last Published: 2022-04-01
| Version: 4.2-SNAPSHOT
diff --git a/docs/reports/4.2-SNAPSHOT/issue-management.html b/docs/reports/4.2-SNAPSHOT/issue-management.html
index f3bdf2539..1d360b294 100644
--- a/docs/reports/4.2-SNAPSHOT/issue-management.html
+++ b/docs/reports/4.2-SNAPSHOT/issue-management.html
@@ -1,6 +1,6 @@
@@ -25,7 +25,7 @@
- Last Published: 2022-03-30
+ Last Published: 2022-04-01
| Version: 4.2-SNAPSHOT
diff --git a/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/ci-management.html b/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/ci-management.html
index 4e1da5b82..573505029 100644
--- a/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/ci-management.html
+++ b/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/ci-management.html
@@ -1,6 +1,6 @@
@@ -25,7 +25,7 @@
- Last Published: 2022-03-30
+ Last Published: 2022-04-01
| Version: 4.2-SNAPSHOT
diff --git a/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/dependencies.html b/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/dependencies.html
index cb7fada9d..0a2cdb952 100644
--- a/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/dependencies.html
+++ b/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/dependencies.html
@@ -1,6 +1,6 @@
@@ -25,7 +25,7 @@
- Last Published: 2022-03-30
+ Last Published: 2022-04-01
| Version: 4.2-SNAPSHOT
diff --git a/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/dependency-info.html b/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/dependency-info.html
index 26d96b471..efe91b68c 100644
--- a/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/dependency-info.html
+++ b/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/dependency-info.html
@@ -1,6 +1,6 @@
@@ -25,7 +25,7 @@
- Last Published: 2022-03-30
+ Last Published: 2022-04-01
| Version: 4.2-SNAPSHOT
diff --git a/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/dependency-management.html b/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/dependency-management.html
index 576404f80..9e12ad591 100644
--- a/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/dependency-management.html
+++ b/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/dependency-management.html
@@ -1,6 +1,6 @@
@@ -25,7 +25,7 @@
- Last Published: 2022-03-30
+ Last Published: 2022-04-01
| Version: 4.2-SNAPSHOT
diff --git a/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/distribution-management.html b/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/distribution-management.html
index 3bd4fb91f..6cb1c5922 100644
--- a/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/distribution-management.html
+++ b/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/distribution-management.html
@@ -1,6 +1,6 @@
@@ -25,7 +25,7 @@
- Last Published: 2022-03-30
+ Last Published: 2022-04-01
| Version: 4.2-SNAPSHOT
diff --git a/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/index.html b/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/index.html
index 70dcdbc66..d51394403 100644
--- a/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/index.html
+++ b/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/index.html
@@ -1,6 +1,6 @@
@@ -25,7 +25,7 @@
- Last Published: 2022-03-30
+ Last Published: 2022-04-01
| Version: 4.2-SNAPSHOT
diff --git a/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/issue-management.html b/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/issue-management.html
index 03122b8e0..d972e31e2 100644
--- a/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/issue-management.html
+++ b/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/issue-management.html
@@ -1,6 +1,6 @@
@@ -25,7 +25,7 @@
- Last Published: 2022-03-30
+ Last Published: 2022-04-01
| Version: 4.2-SNAPSHOT
diff --git a/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/jacoco/com.mycila.maven.plugin.license.git/GitLookup$DateSource.html b/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/jacoco/com.mycila.maven.plugin.license.git/GitLookup$DateSource.html
index 0d92e2643..a7acbb9d5 100644
--- a/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/jacoco/com.mycila.maven.plugin.license.git/GitLookup$DateSource.html
+++ b/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/jacoco/com.mycila.maven.plugin.license.git/GitLookup$DateSource.html
@@ -1 +1 @@
-
GitLookup.DateSource GitLookup.DateSource Element Missed Instructions Cov. Missed Branches Cov. Missed Cxty Missed Lines Missed Methods Total 0 of 24 100% 0 of 0 n/a 0 1 0 2 0 1 static {...} 100% n/a 0 1 0 2 0 1
\ No newline at end of file
+
GitLookup.DateSource GitLookup.DateSource Element Missed Instructions Cov. Missed Branches Cov. Missed Cxty Missed Lines Missed Methods Total 0 of 24 100% 0 of 0 n/a 0 1 0 2 0 1 static {...} 100% n/a 0 1 0 2 0 1
\ No newline at end of file
diff --git a/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/jacoco/com.mycila.maven.plugin.license.git/GitLookup.html b/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/jacoco/com.mycila.maven.plugin.license.git/GitLookup.html
index 1d0d977ae..ba6efb5d9 100644
--- a/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/jacoco/com.mycila.maven.plugin.license.git/GitLookup.html
+++ b/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/jacoco/com.mycila.maven.plugin.license.git/GitLookup.html
@@ -1 +1 @@
-
GitLookup GitLookup
\ No newline at end of file
+
GitLookup GitLookup
\ No newline at end of file
diff --git a/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/jacoco/com.mycila.maven.plugin.license.git/GitLookup.java.html b/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/jacoco/com.mycila.maven.plugin.license.git/GitLookup.java.html
index 5cd006054..ee280c754 100644
--- a/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/jacoco/com.mycila.maven.plugin.license.git/GitLookup.java.html
+++ b/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/jacoco/com.mycila.maven.plugin.license.git/GitLookup.java.html
@@ -37,7 +37,15 @@
import java.io.File;
import java.io.IOException;
import java.io.UncheckedIOException;
-import java.util.*;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+import java.util.TimeZone;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -50,7 +58,7 @@
*/
public class GitLookup implements Closeable {
-
public static final TimeZone DEFAULT_ZONE = TimeZone.getTimeZone("GMT");
+
public static final TimeZone DEFAULT_ZONE = TimeZone.getTimeZone("GMT");
public static final String MAX_COMMITS_LOOKUP_KEY = "license.git.maxCommitsLookup";
// keep for compatibility
@@ -59,8 +67,8 @@
public static final String COPYRIGHT_LAST_YEAR_TIME_ZONE_KEY = "license.git.copyrightLastYearTimeZone";
public static final String COMMITS_TO_IGNORE_KEY = "license.git.commitsToIgnore";
-
public enum DateSource {
-
AUTHOR, COMMITER
+
public enum DateSource {
+
AUTHOR, COMMITER
}
private final int checkCommitsCount;
@@ -76,37 +84,37 @@
* to the same git repository.
*/
public static GitLookup create(File file, Map<String, String> props) {
-
final GitLookup.DateSource dateSource = Optional.ofNullable(props.get(COPYRIGHT_LAST_YEAR_SOURCE_KEY))
-
.map(String::trim)
-
.map(String::toUpperCase)
-
.map(GitLookup.DateSource::valueOf)
-
.orElse(GitLookup.DateSource.AUTHOR);
+
final GitLookup.DateSource dateSource = Optional.ofNullable(props.get(COPYRIGHT_LAST_YEAR_SOURCE_KEY))
+
.map(String::trim)
+
.map(String::toUpperCase)
+
.map(GitLookup.DateSource::valueOf)
+
.orElse(GitLookup.DateSource.AUTHOR);
-
final int checkCommitsCount = Stream.of(
+
final int checkCommitsCount = Stream.of(
MAX_COMMITS_LOOKUP_KEY,
COPYRIGHT_LAST_YEAR_MAX_COMMITS_LOOKUP_KEY) // Backwards compatibility
-
.map(props::get)
-
.filter(Objects::nonNull)
-
.map(String::trim)
-
.map(Integer::parseInt)
-
.findFirst()
-
.orElse(Integer.MAX_VALUE);
-
-
final Set<ObjectId> commitsToIgnore = Stream.of(COMMITS_TO_IGNORE_KEY)
.map(props::get)
.filter(Objects::nonNull)
-
.flatMap(s -> Stream.of(s.split(",")))
-
.map(String::trim)
-
.filter(s -> !s.isEmpty())
-
.map(ObjectId::fromString)
-
.collect(Collectors.toSet());
-
-
final TimeZone timeZone = Optional.ofNullable(props.get(COPYRIGHT_LAST_YEAR_TIME_ZONE_KEY))
-
.map(String::trim)
-
.map(TimeZone::getTimeZone)
-
.orElse(DEFAULT_ZONE);
-
-
return new GitLookup(file, dateSource, timeZone, checkCommitsCount, commitsToIgnore);
+
.map(String::trim)
+
.map(Integer::parseInt)
+
.findFirst()
+
.orElse(Integer.MAX_VALUE);
+
+
final Set<ObjectId> commitsToIgnore = Stream.of(COMMITS_TO_IGNORE_KEY)
+
.map(props::get)
+
.filter(Objects::nonNull)
+
.flatMap(s -> Stream.of(s.split(",")))
+
.map(String::trim)
+
.filter(s -> !s.isEmpty())
+
.map(ObjectId::fromString)
+
.collect(Collectors.toSet());
+
+
final TimeZone timeZone = Optional.ofNullable(props.get(COPYRIGHT_LAST_YEAR_TIME_ZONE_KEY))
+
.map(String::trim)
+
.map(TimeZone::getTimeZone)
+
.orElse(DEFAULT_ZONE);
+
+
return new GitLookup(file, dateSource, timeZone, checkCommitsCount, commitsToIgnore);
}
/**
@@ -124,30 +132,30 @@
* @param commitsToIgnore the commits to ignore while inspecting the history for {@code anyFile}
* @throws IOException
*/
-
private GitLookup(File anyFile, DateSource dateSource, TimeZone timeZone, int checkCommitsCount, Set<ObjectId> commitsToIgnore) {
-
requireNonNull(anyFile);
-
requireNonNull(dateSource);
-
requireNonNull(timeZone);
-
requireNonNull(commitsToIgnore);
+
private GitLookup(File anyFile, DateSource dateSource, TimeZone timeZone, int checkCommitsCount, Set<ObjectId> commitsToIgnore) {
+
requireNonNull(anyFile);
+
requireNonNull(dateSource);
+
requireNonNull(timeZone);
+
requireNonNull(commitsToIgnore);
try {
-
this.repository = new FileRepositoryBuilder().findGitDir(anyFile).build();
+
this.repository = new FileRepositoryBuilder().findGitDir(anyFile).build();
/* A workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=457961 */
// Also contains contents of .git/shallow and can detect shallow repo
// the line below reads and caches the entries in the FileObjectDatabase of the repository to
// avoid concurrent modifications during RevWalk
// Closing the repository will close the FileObjectDatabase.
// Here the newReader() is a WindowCursor which delegates the getShallowCommits() to the FileObjectDatabase.
-
this.shallow = !this.repository.getObjectDatabase().newReader().getShallowCommits().isEmpty();
-
this.pathResolver = new GitPathResolver(repository.getWorkTree().getAbsolutePath());
-
this.dateSource = dateSource;
-
this.timeZone = timeZone;
-
this.checkCommitsCount = checkCommitsCount;
-
this.commitsToIgnore = commitsToIgnore;
-
} catch (IOException e) {
-
throw new UncheckedIOException(e);
-
}
-
}
+
this.shallow = !this.repository.getObjectDatabase().newReader().getShallowCommits().isEmpty();
+
this.pathResolver = new GitPathResolver(repository.getWorkTree().getAbsolutePath());
+
this.dateSource = dateSource;
+
this.timeZone = timeZone;
+
this.checkCommitsCount = checkCommitsCount;
+
this.commitsToIgnore = commitsToIgnore;
+
} catch (IOException e) {
+
throw new UncheckedIOException(e);
+
}
+
}
/**
* Returns the year of the last change of the given {@code file} based on the history of the present git branch. The
@@ -162,25 +170,25 @@
* @throws GitAPIException if unable to process the git history
*/
int getYearOfLastChange(File file) throws GitAPIException, IOException {
-
String repoRelativePath = pathResolver.relativize(file);
+
String repoRelativePath = pathResolver.relativize(file);
-
if (isFileModifiedOrUnstaged(repoRelativePath)) {
-
return getCurrentYear();
+
if (isFileModifiedOrUnstaged(repoRelativePath)) {
+
return getCurrentYear();
}
-
int commitYear = 0;
-
RevWalk walk = getGitRevWalk(repoRelativePath, false);
-
for (RevCommit commit : walk) {
-
if (commitsToIgnore.contains(commit.getId())) {
-
continue;
+
int commitYear = 0;
+
RevWalk walk = getGitRevWalk(repoRelativePath, false);
+
for (RevCommit commit : walk) {
+
if (commitsToIgnore.contains(commit.getId())) {
+
continue;
}
-
int y = getYearFromCommit(commit);
-
if (y > commitYear) {
-
commitYear = y;
+
int y = getYearFromCommit(commit);
+
if (y > commitYear) {
+
commitYear = y;
}
-
}
-
walk.dispose();
-
return commitYear;
+
}
+
walk.dispose();
+
return commitYear;
}
/**
@@ -194,117 +202,117 @@
* @throws GitAPIException if unable to process the git history
*/
int getYearOfCreation(File file) throws IOException, GitAPIException {
-
String repoRelativePath = pathResolver.relativize(file);
-
-
int commitYear = 0;
-
RevWalk walk = getGitRevWalk(repoRelativePath, true);
-
Iterator<RevCommit> iterator = walk.iterator();
-
if (iterator.hasNext()) {
-
RevCommit commit = iterator.next();
-
commitYear = getYearFromCommit(commit);
+
String repoRelativePath = pathResolver.relativize(file);
+
+
int commitYear = 0;
+
RevWalk walk = getGitRevWalk(repoRelativePath, true);
+
Iterator<RevCommit> iterator = walk.iterator();
+
if (iterator.hasNext()) {
+
RevCommit commit = iterator.next();
+
commitYear = getYearFromCommit(commit);
}
-
walk.dispose();
+
walk.dispose();
// If we couldn't find a creation year from Git assume newly created file
-
if (commitYear == 0) {
-
return getCurrentYear();
+
if (commitYear == 0) {
+
return getCurrentYear();
}
-
return commitYear;
+
return commitYear;
}
String getAuthorNameOfCreation(File file) throws IOException {
-
String repoRelativePath = pathResolver.relativize(file);
-
String authorName = "";
-
RevWalk walk = getGitRevWalk(repoRelativePath, true);
-
Iterator<RevCommit> iterator = walk.iterator();
-
if (iterator.hasNext()) {
-
RevCommit commit = iterator.next();
-
authorName = getAuthorNameFromCommit(commit);
+
String repoRelativePath = pathResolver.relativize(file);
+
String authorName = "";
+
RevWalk walk = getGitRevWalk(repoRelativePath, true);
+
Iterator<RevCommit> iterator = walk.iterator();
+
if (iterator.hasNext()) {
+
RevCommit commit = iterator.next();
+
authorName = getAuthorNameFromCommit(commit);
}
-
walk.dispose();
-
return authorName;
+
walk.dispose();
+
return authorName;
}
String getAuthorEmailOfCreation(File file) throws IOException {
-
String repoRelativePath = pathResolver.relativize(file);
-
String authorEmail = "";
-
RevWalk walk = getGitRevWalk(repoRelativePath, true);
-
Iterator<RevCommit> iterator = walk.iterator();
-
if (iterator.hasNext()) {
-
RevCommit commit = iterator.next();
-
authorEmail = getAuthorEmailFromCommit(commit);
+
String repoRelativePath = pathResolver.relativize(file);
+
String authorEmail = "";
+
RevWalk walk = getGitRevWalk(repoRelativePath, true);
+
Iterator<RevCommit> iterator = walk.iterator();
+
if (iterator.hasNext()) {
+
RevCommit commit = iterator.next();
+
authorEmail = getAuthorEmailFromCommit(commit);
}
-
walk.dispose();
-
return authorEmail;
+
walk.dispose();
+
return authorEmail;
}
boolean isShallowRepository() {
-
return this.shallow;
+
return this.shallow;
}
private boolean isFileModifiedOrUnstaged(String repoRelativePath) throws GitAPIException {
@SuppressWarnings("resource")
-
Status status = new Git(repository).status().addPath(repoRelativePath).call();
-
return !status.isClean();
+
Status status = new Git(repository).status().addPath(repoRelativePath).call();
+
return !status.isClean();
}
private RevWalk getGitRevWalk(String repoRelativePath, boolean oldestCommitsFirst) throws IOException {
-
DiffConfig diffConfig = repository.getConfig().get(DiffConfig.KEY);
+
DiffConfig diffConfig = repository.getConfig().get(DiffConfig.KEY);
-
RevWalk walk = new RevWalk(repository);
-
walk.markStart(walk.parseCommit(repository.resolve(Constants.HEAD)));
-
walk.setTreeFilter(AndTreeFilter.create(Arrays.asList(
-
PathFilter.create(repoRelativePath),
-
FollowFilter.create(repoRelativePath, diffConfig), // Allows us to follow files as they move or are renamed
+
RevWalk walk = new RevWalk(repository);
+
walk.markStart(walk.parseCommit(repository.resolve(Constants.HEAD)));
+
walk.setTreeFilter(AndTreeFilter.create(Arrays.asList(
+
PathFilter.create(repoRelativePath),
+
FollowFilter.create(repoRelativePath, diffConfig), // Allows us to follow files as they move or are renamed
TreeFilter.ANY_DIFF)
));
-
walk.setRevFilter(MaxCountRevFilter.create(checkCommitsCount));
-
walk.setRetainBody(false);
-
if (oldestCommitsFirst) {
-
walk.sort(RevSort.REVERSE);
+
walk.setRevFilter(MaxCountRevFilter.create(checkCommitsCount));
+
walk.setRetainBody(false);
+
if (oldestCommitsFirst) {
+
walk.sort(RevSort.REVERSE);
}
-
return walk;
+
return walk;
}
private int getCurrentYear() {
-
return toYear(System.currentTimeMillis(), timeZone);
+
return toYear(System.currentTimeMillis(), timeZone);
}
private int getYearFromCommit(RevCommit commit) {
-
switch (dateSource) {
+
switch (dateSource) {
case COMMITER:
-
int epochSeconds = commit.getCommitTime();
-
return toYear(epochSeconds * 1000L, timeZone);
+
int epochSeconds = commit.getCommitTime();
+
return toYear(epochSeconds * 1000L, timeZone);
case AUTHOR:
-
PersonIdent id = commit.getAuthorIdent();
-
Date date = id.getWhen();
-
return toYear(date.getTime(), id.getTimeZone());
+
PersonIdent id = commit.getAuthorIdent();
+
Date date = id.getWhen();
+
return toYear(date.getTime(), id.getTimeZone());
default:
-
throw new IllegalStateException("Unexpected " + DateSource.class.getName() + " " + dateSource);
+
throw new IllegalStateException("Unexpected " + DateSource.class.getName() + " " + dateSource);
}
}
private static int toYear(long epochMilliseconds, TimeZone timeZone) {
-
Calendar result = Calendar.getInstance(timeZone);
-
result.setTimeInMillis(epochMilliseconds);
-
return result.get(Calendar.YEAR);
+
Calendar result = Calendar.getInstance(timeZone);
+
result.setTimeInMillis(epochMilliseconds);
+
return result.get(Calendar.YEAR);
}
private String getAuthorNameFromCommit(RevCommit commit) {
-
PersonIdent id = commit.getAuthorIdent();
-
return id.getName();
+
PersonIdent id = commit.getAuthorIdent();
+
return id.getName();
}
private String getAuthorEmailFromCommit(RevCommit commit) {
-
PersonIdent id = commit.getAuthorIdent();
-
return id.getEmailAddress();
+
PersonIdent id = commit.getAuthorIdent();
+
return id.getEmailAddress();
}
@Override
public void close() {
-
repository.close();
-
}
+
repository.close();
+
}
}