Index: .gitignore
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>windows-1251
===================================================================
--- .gitignore (date 1431068156000)
+++ .gitignore (date 1431083679000)
@@ -57,3 +57,5 @@
crashlytics-build.properties
+
+patches
\ No newline at end of file
Index: maven-confluence-reporting-plugin/src/main/java/com/github/qwazer/mavenplugins/gitlog/GitLogHelper.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>windows-1251
===================================================================
--- maven-confluence-reporting-plugin/src/main/java/com/github/qwazer/mavenplugins/gitlog/GitLogHelper.java (date 1431068156000)
+++ maven-confluence-reporting-plugin/src/main/java/com/github/qwazer/mavenplugins/gitlog/GitLogHelper.java (date 1431083679000)
@@ -17,7 +17,7 @@
public class GitLogHelper {
private RevWalk walk;
- private Set<String> tagNames;
+ private Set<String> versionTagList;
private final Log log;
private Repository repository;
@@ -27,7 +27,7 @@
this.log = log;
}
- public void openRepository() throws IOException, NoGitRepositoryException {
+ public void openRepositoryAndInitVersionTagList(String gitLogTagNamesPattern) throws IOException, NoGitRepositoryException {
log.debug("Try to open git repository.");
try {
repository = new RepositoryBuilder().findGitDir().build();
@@ -36,12 +36,19 @@
}
log.debug("Opened " + repository + ". Try to load the commits.");
walk = createWalk(repository);
- log.debug("Loaded commits. try to load the tags.");
- tagNames = repository.getTags().keySet();
- log.debug("Loaded tag names: " + tagNames);
+ log.debug("Loaded commits. try to load version tags.");
+ versionTagList = new HashSet<String>();
+
+ for (String tagName : repository.getTags().keySet()){
+ if (tagName.matches(gitLogTagNamesPattern)){
+ versionTagList.add(tagName);
- }
+ }
+ }
+ log.debug("Loaded version tag names: " + versionTagList);
+ }
+
public Date extractDateOfCommitWithTagName(String tagName) throws IOException {
return extractDateOfCommitWithTagName(repository, tagName);
}
@@ -132,7 +139,7 @@
}
- public Set<String> getTagNames() {
- return tagNames;
+ public Set<String> getVersionTagList() {
+ return versionTagList;
}
}
Index: maven-confluence-reporting-plugin/src/test/java/com/github/qwazer/mavenplugins/gitlog/GitLogHelperTest.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>windows-1251
===================================================================
--- maven-confluence-reporting-plugin/src/test/java/com/github/qwazer/mavenplugins/gitlog/GitLogHelperTest.java (date 1431068156000)
+++ maven-confluence-reporting-plugin/src/test/java/com/github/qwazer/mavenplugins/gitlog/GitLogHelperTest.java (date 1431083679000)
@@ -21,6 +21,7 @@
* @author ar
* @since Date: 04.05.2015
*/
+@Ignore
public class GitLogHelperTest {
private static final String repoFile =
"/home/ar/projects/github/maven-confluence-plugin/maven-confluence-reporting-plugin/src/it/spring-roo/pom.xml";
\ No newline at end of file
Index: maven-confluence-reporting-plugin/src/test/java/com/github/qwazer/mavenplugins/gitlog/VersionUtilTest.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>windows-1251
===================================================================
--- maven-confluence-reporting-plugin/src/test/java/com/github/qwazer/mavenplugins/gitlog/VersionUtilTest.java (date 1431083679000)
+++ maven-confluence-reporting-plugin/src/test/java/com/github/qwazer/mavenplugins/gitlog/VersionUtilTest.java (date 1431083679000)
@@ -0,0 +1,163 @@
+package com.github.qwazer.mavenplugins.gitlog;
+
+import org.junit.Test;
+
+import java.util.List;
+
+import static java.util.Arrays.asList;
+import static junit.framework.Assert.assertEquals;
+
+
+public class VersionUtilTest {
+
+ @Test
+ public void testFindNearestVersionTagsBefore() throws Exception {
+
+ List<String> list = asList("1.0.0", "1.1.0", "2.0.0");
+ String version = "1.2.0";
+
+ String foundVersion = VersionUtil.findNearestVersionTagsBefore(list, version);
+ assertEquals("1.1.0", foundVersion);
+
+ }
+
+ @Test
+ public void testFindNearestVersionTagsBeforeRC() throws Exception {
+
+ List<String> list = asList("1.0.0-RC1", "1.0.0-RC2", "1.0.0-RC3");
+ String version = "1.0.0-RC2";
+
+ String foundVersion = VersionUtil.findNearestVersionTagsBefore(list, version);
+ assertEquals("1.0.0-RC2", foundVersion);
+
+ }
+
+ @Test
+ public void testFindNearestVersionTagsBeforeRC3() throws Exception {
+
+ List<String> list = asList("1.0.0-RC1", "1.0.0-RC2", "1.0.0-RC4");
+ String version = "1.0.0-RC3";
+
+ String foundVersion = VersionUtil.findNearestVersionTagsBefore(list, version);
+ assertEquals("1.0.0-RC2", foundVersion);
+
+ }
+
+ @Test
+ public void testFindNearestVersionTagsBeforeMC1() throws Exception {
+
+ List<String> list = asList("1.0.0-M01", "1.0.0-RC2", "1.0.0-RC4");
+ String version = "1.0.0-RC3";
+
+ String foundVersion = VersionUtil.findNearestVersionTagsBefore(list, version);
+ assertEquals("1.0.0-RC2", foundVersion);
+
+ }
+
+ @Test
+ public void testFindNearestVersionTagsBeforeMC2() throws Exception {
+
+ List<String> list = asList("1.0.0-M01", "1.0.0-M2", "1.0.0-RC4");
+ String version = "1.0.0-RC3";
+
+ String foundVersion = VersionUtil.findNearestVersionTagsBefore(list, version);
+ assertEquals("1.0.0-M2", foundVersion);
+
+ }
+
+ @Test
+ public void testFindNearestVersionTagsBefore1() throws Exception {
+
+ List<String> list = asList("1.0.0");
+ String version = "1.2.0";
+
+ String foundVersion = VersionUtil.findNearestVersionTagsBefore(list, version);
+ assertEquals("1.0.0", foundVersion);
+
+ }
+
+ @Test
+ public void testFindNearestVersionTagsBeforeNull() throws Exception {
+
+ List<String> list = asList();
+ String version = "1.2.0";
+
+ String foundVersion = VersionUtil.findNearestVersionTagsBefore(list, version);
+ assertEquals(null, foundVersion);
+
+
+ }
+
+ @Test
+ public void testFindNearestVersionTagsBefore12() throws Exception {
+
+ List<String> list = asList("tagName");
+ String version = "1.2.0";
+
+ String foundVersion = VersionUtil.findNearestVersionTagsBefore(list, version);
+ assertEquals("tagName", foundVersion);
+
+
+ }
+
+ @Test
+ public void testRemoveNonDigitPrefix() throws Exception {
+ String s = "1.2.3";
+ String r = VersionUtil.removeNonDigitPrefix(s);
+ assertEquals(s,r);
+ }
+ @Test
+ public void testRemoveNonDigitPrefix2() throws Exception {
+ String s = "abs-1.2.3";
+ String r = VersionUtil.removeNonDigitPrefix(s);
+ assertEquals("1.2.3",r);
+ }
+
+ @Test
+ public void testRemoveNonDigitPrefix3() throws Exception {
+ String s = "";
+ String r = VersionUtil.removeNonDigitPrefix(s);
+ assertEquals("",r);
+ }
+
+ @Test
+ public void testFindNearestVersionTagsRealCase01() throws Exception {
+
+ List<String> list = asList("7.17.1_deals_config_fix", "7.17.8", "7.18.0",
+ "7.18.1", "7.18.2", "7.18.3", "build-6.2.14", "build-6.2.4", "build-6.2.5",
+ "build-6.2.6", "build-6.2.7", "build-6.3", "build-6.4", "build-6.4.1",
+ "build-6.6.29", "build-6.8", "build-7.6.122", "cummulative",
+ "v7.18.4", "v7.19.0", "v7.19.1", "v7.19.2", "v7.19.3", "v7.19.4", "v7.19.5", "v7.20.0",
+ "v7.20.1", "v7.20.2", "v7.20.3", "v7.20.4", "v7.20.5", "v7.20.6", "v8.0.0",
+ "v8.0.1", "v8.0.2", "v8.0.3", "v8.0.4", "v8.0.5", "v8.0.6", "v8.0.7", "v8.0.9",
+ "v8.1.1", "v8.1.2", "v8.1.3", "v8.2.0", "v8.2.1", "v8.2.2", "v8.2.3", "v8.2.4",
+ "v8.2.5", "v8.3.0", "v8.3.1");
+ String version = "8.1.0";
+
+ String foundVersion = VersionUtil.findNearestVersionTagsBefore(list, version);
+ assertEquals("v8.0.9", foundVersion);
+
+
+ }
+
+ @Test
+ public void testFindNearestVersionTagsRealCase02() throws Exception {
+
+ List<String> list = asList("7.17.1_deals_config_fix", "7.17.8", "7.18.0",
+ "7.18.1", "7.18.2", "7.18.3", "build-6.2.14", "build-6.2.4", "build-6.2.5",
+ "build-6.2.6", "build-6.2.7", "build-6.3", "build-6.4", "build-6.4.1",
+ "build-6.6.29", "build-6.8", "build-7.6.122", "cummulative",
+ "v7.18.4", "v7.19.0", "v7.19.1", "v7.19.2", "v7.19.3", "v7.19.4", "v7.19.5", "v7.20.0",
+ "v7.20.1", "v7.20.2", "v7.20.3", "v7.20.4", "v7.20.5", "v7.20.6", "v8.0.0",
+ "v8.0.1", "v8.0.2", "v8.0.3", "v8.0.4", "v8.0.5", "v8.0.6", "v8.0.7", "v8.0.9",
+ "v8.1.1", "v8.1.2", "v8.1.3", "v8.2.0", "v8.2.1", "v8.2.2", "v8.2.3", "v8.2.4",
+ "v8.2.5", "v8.3.0", "v8.3.1");
+ String version = "8.2.0";
+
+ String foundVersion = VersionUtil.findNearestVersionTagsBefore(list, version);
+ assertEquals("v8.2.0", foundVersion);
+
+ }
+
+
+}
\ No newline at end of file
Index: maven-confluence-reporting-plugin/src/main/java/com/github/qwazer/mavenplugins/gitlog/VersionUtil.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>windows-1251
===================================================================
--- maven-confluence-reporting-plugin/src/main/java/com/github/qwazer/mavenplugins/gitlog/VersionUtil.java (date 1431068156000)
+++ maven-confluence-reporting-plugin/src/main/java/com/github/qwazer/mavenplugins/gitlog/VersionUtil.java (date 1431091662000)
@@ -6,9 +6,9 @@
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.codehaus.plexus.util.StringUtils;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/**
* @author ar
@@ -17,44 +17,29 @@
public class VersionUtil {
- public static List<String> calculateTagNamesOfVersions(Collection<String> versions, String currentVersion, CalculateRuleForSinceTagName calculateRuleForSinceTagName) {
- String tagNamePart = calculateSinceVersionTagNamePart(currentVersion, calculateRuleForSinceTagName);
- List<String> resList = new ArrayList<String>();
+ public static String calculateVersionTagNamePart(String version, CalculateRuleForSinceTagName calculateRuleForSinceTagName) {
- for (String s : versions) {
- if (s.contains(tagNamePart)) {
- resList.add(s);
- }
- }
- return resList;
-
- }
-
-
- public static String calculateSinceVersionTagNamePart(String version, CalculateRuleForSinceTagName calculateRuleForSinceTagName) {
-
if (calculateRuleForSinceTagName.equals(CalculateRuleForSinceTagName.NO_RULE)) {
return null;
}
- ArtifactVersion artifactVersion = new DefaultArtifactVersion(version);
- if (ArtifactUtils.isSnapshot(version)) {
- artifactVersion = new DefaultArtifactVersion(StringUtils.substring(version, 0, version.length() - Artifact.SNAPSHOT_VERSION.length() - 1));
- }
- if (version.equals(artifactVersion.getQualifier())) {
- // getLog().debug("The version is not in the regular format"); todo
- }
+ ArtifactVersion artifactVersion = parseArtifactVersion(version);
int major = artifactVersion.getMajorVersion();
int minor = artifactVersion.getMinorVersion();
int patch = artifactVersion.getIncrementalVersion();
switch (calculateRuleForSinceTagName) {
case SINCE_PREV_MAJOR_RELEASE:
+ if (minor == 0 && patch == 0) {
- major = major == 0 ? 0 : major - 1;
+ major = major == 0 ? 0 : major - 1;
+ } else {
- minor = 0;
- patch = 0;
+ minor = 0;
+ patch = 0;
+ }
break;
case SINCE_PREV_MINOR_RELEASE:
+ if (patch == 0) {
- minor = minor == 0 ? 0 : minor - 1;
+ minor = minor == 0 ? 0 : minor - 1;
+ }
patch = 0;
break;
case SINCE_PREV_PATCH_RELEASE:
@@ -65,6 +50,73 @@
}
return major + "." + minor + "." + patch;
+ }
+
+ private static ArtifactVersion parseArtifactVersion(String version) {
+ version = removeNonDigitPrefix(version);
+ ArtifactVersion artifactVersion = new DefaultArtifactVersion(version);
+ if (ArtifactUtils.isSnapshot(version)) {
+ artifactVersion = new DefaultArtifactVersion(StringUtils.substring(version, 0, version.length() - Artifact.SNAPSHOT_VERSION.length() - 1));
+ }
+ return artifactVersion;
+ }
+
+ protected static String removeNonDigitPrefix(String version) {
+ if (version != null && !version.isEmpty()) {
+ if (!Character.isDigit(version.charAt(0))) {
+ Matcher matcher = Pattern.compile("\\d+").matcher(version);
+ int i = 0;
+ if (matcher.find()) {
+ i = matcher.end();
+ }
+ if (i > 0) {
+ version = StringUtils.substring(version, i - 1, version.length());
+ }
+ }
+ }
+ return version;
+ }
+
+ public static Collection<String> filterTagNamesByTagNamePart(Collection<String> tagNames, String versionTagNamePart) {
+ List<String> list = new ArrayList<String>();
+ for (String tagName : tagNames) {
+ if (tagName.contains(versionTagNamePart)) {
+ list.add(tagName);
+ }
+ }
+ return list;
+ }
+
+ public static String findNearestVersionTagsBefore(Collection<String> versionTagList, String versionTagNamePart) {
+
+ Map<ArtifactVersion, String> artifactVersionStringMap = new HashMap<ArtifactVersion, String>();
+
+ for (String versionTag : versionTagList) {
+ artifactVersionStringMap.put(parseArtifactVersion(versionTag), versionTag);
+ }
+
+ ArtifactVersion currentVersion = parseArtifactVersion(versionTagNamePart);
+
+ List<ArtifactVersion> sortedList = new ArrayList<ArtifactVersion>(artifactVersionStringMap.keySet());
+
+ Collections.sort(sortedList);
+
+// Comparator<ArtifactVersion> comparator = new Comparator<ArtifactVersion>() {
+// public int compare(ArtifactVersion a1, ArtifactVersion a2) {
+// return a1.compareTo(a2);
+// }
+// };
+
+ int index = Collections.binarySearch(sortedList, currentVersion, null);
+
+ if (index >= 0) {
+ return artifactVersionStringMap.get(sortedList.get(index));
+ }
+ if (sortedList.size() > 0) {
+ return artifactVersionStringMap.get(sortedList.get(-index - 2));
+ } else {
+ return null;
+ }
}
}
Index: maven-confluence-reporting-plugin/src/main/java/org/bsc/maven/confluence/plugin/ConfluenceDeployMojo.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>windows-1251
===================================================================
--- maven-confluence-reporting-plugin/src/main/java/org/bsc/maven/confluence/plugin/ConfluenceDeployMojo.java (date 1431068156000)
+++ maven-confluence-reporting-plugin/src/main/java/org/bsc/maven/confluence/plugin/ConfluenceDeployMojo.java (date 1431092916000)
@@ -1,12 +1,7 @@
package org.bsc.maven.confluence.plugin;
-import java.io.StringWriter;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.Map;
-
+import biz.source_code.miniTemplator.MiniTemplator;
+import biz.source_code.miniTemplator.MiniTemplator.VariableNotDefinedException;
import com.github.qwazer.mavenplugins.gitlog.CalculateRuleForSinceTagName;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
@@ -20,37 +15,35 @@
import org.apache.maven.model.Dependency;
import org.apache.maven.model.DependencyManagement;
import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.project.MavenProjectBuilder;
-import org.apache.maven.project.ProjectBuildingException;
-import org.apache.maven.scm.manager.ScmManager;
-import org.bsc.maven.plugin.confluence.ConfluenceUtils;
-import org.bsc.maven.reporting.renderer.DependenciesRenderer;
-import org.bsc.maven.reporting.renderer.GitLogJiraIssuesRenderer;
-import org.bsc.maven.reporting.renderer.ProjectSummaryRenderer;
-import org.bsc.maven.reporting.renderer.ScmRenderer;
-import org.codehaus.plexus.i18n.I18N;
-import org.codehaus.swizzle.confluence.Confluence;
-import org.codehaus.swizzle.confluence.Page;
-
-import biz.source_code.miniTemplator.MiniTemplator;
-import biz.source_code.miniTemplator.MiniTemplator.VariableNotDefinedException;
-import java.util.List;
-import java.util.Set;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.MavenProjectBuilder;
+import org.apache.maven.project.ProjectBuildingException;
+import org.apache.maven.scm.manager.ScmManager;
import org.apache.maven.tools.plugin.DefaultPluginToolsRequest;
import org.apache.maven.tools.plugin.PluginToolsRequest;
import org.apache.maven.tools.plugin.extractor.ExtractionException;
import org.apache.maven.tools.plugin.generator.Generator;
import org.apache.maven.tools.plugin.generator.GeneratorUtils;
import org.apache.maven.tools.plugin.scanner.MojoScanner;
+import org.bsc.maven.plugin.confluence.ConfluenceUtils;
import org.bsc.maven.reporting.model.Site;
+import org.bsc.maven.reporting.renderer.DependenciesRenderer;
+import org.bsc.maven.reporting.renderer.GitLogJiraIssuesRenderer;
+import org.bsc.maven.reporting.renderer.ProjectSummaryRenderer;
+import org.bsc.maven.reporting.renderer.ScmRenderer;
import org.codehaus.plexus.component.repository.ComponentDependency;
+import org.codehaus.plexus.i18n.I18N;
+import org.codehaus.swizzle.confluence.Confluence;
+import org.codehaus.swizzle.confluence.Page;
+import java.io.StringWriter;
+import java.util.*;
+
/**
*
* Generate Project's documentation in confluence's wiki format and deploy it
@@ -63,6 +56,7 @@
private static final String PROJECT_SCM_MANAGER_VAR = "project.scmManager";
private static final String PROJECT_SUMMARY_VAR = "project.summary";
private static final String GITLOG_JIRA_ISSUES_VAR = "gitlog.jiraIssues";
+ private static final String GITLOG_SINCE_TAG_NAME = "gitlog.sinceTagName";
/**
* Local Repository.
@@ -370,19 +364,29 @@
//final Sink sink = getSink();
String currentVersion = project.getVersion();
- new GitLogJiraIssuesRenderer(sink, gitLogSinceTagName, gitLogJiraProjectKeyList, currentVersion, gitLogCalculateRuleForSinceTagName, getLog()).render();
+ GitLogJiraIssuesRenderer gitLogJiraIssuesRenderer = new GitLogJiraIssuesRenderer(sink, gitLogSinceTagName, gitLogJiraProjectKeyList, currentVersion,
+ gitLogCalculateRuleForSinceTagName, gitLogTagNamesPattern, getLog());
+ gitLogJiraIssuesRenderer.render();
+ gitLogSinceTagName = gitLogJiraIssuesRenderer.getGitLogSinceTagName();
+
try {
final String gitlog_jiraissues_var = w.toString();
-
getProperties().put(GITLOG_JIRA_ISSUES_VAR, gitlog_jiraissues_var); // to share with children
-
t.setVariable(GITLOG_JIRA_ISSUES_VAR, gitlog_jiraissues_var);
} catch (VariableNotDefinedException e) {
- getLog().warn(String.format("variable %s not defined in template", GITLOG_JIRA_ISSUES_VAR));
+ getLog().info(String.format("variable %s not defined in template", GITLOG_JIRA_ISSUES_VAR));
}
}
+
+ try {
+ getProperties().put(GITLOG_SINCE_TAG_NAME, gitLogSinceTagName); // to share with children
+ t.setVariable(GITLOG_SINCE_TAG_NAME, gitLogSinceTagName);
+ } catch (VariableNotDefinedException e) {
+ getLog().debug(String.format("variable %s not defined in template", GITLOG_SINCE_TAG_NAME));
+ }
+
}
final String wiki = t.generateOutput();
Index: maven-confluence-reporting-plugin/src/main/java/org/bsc/maven/reporting/renderer/GitLogJiraIssuesRenderer.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>windows-1251
===================================================================
--- maven-confluence-reporting-plugin/src/main/java/org/bsc/maven/reporting/renderer/GitLogJiraIssuesRenderer.java (date 1431068156000)
+++ maven-confluence-reporting-plugin/src/main/java/org/bsc/maven/reporting/renderer/GitLogJiraIssuesRenderer.java (date 1431092916000)
@@ -1,7 +1,7 @@
package org.bsc.maven.reporting.renderer;
-import com.github.qwazer.mavenplugins.gitlog.GitLogHelper;
import com.github.qwazer.mavenplugins.gitlog.CalculateRuleForSinceTagName;
+import com.github.qwazer.mavenplugins.gitlog.GitLogHelper;
import com.github.qwazer.mavenplugins.gitlog.VersionUtil;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.plugin.logging.Log;
@@ -22,6 +22,7 @@
private String gitLogSinceTagName;
private CalculateRuleForSinceTagName calculateRuleForSinceTagName;
private String currentVersion;
+ private String gitLogTagNamesPattern;
private List<String> jiraProjectKeyList;
/**
@@ -29,12 +30,15 @@
*
* @param sink the sink to use.
*/
- public GitLogJiraIssuesRenderer(Sink sink, String gitLogSinceTagName, List<String> jiraProjectKeyList, String currentVersion, CalculateRuleForSinceTagName calculateRuleForSinceTagName, Log log) {
+ public GitLogJiraIssuesRenderer(Sink sink, String gitLogSinceTagName, List<String> jiraProjectKeyList,
+ String currentVersion, CalculateRuleForSinceTagName calculateRuleForSinceTagName,
+ String gitLogTagNamesPattern, Log log) {
super(sink);
this.gitLogSinceTagName = gitLogSinceTagName;
this.currentVersion = currentVersion;
this.calculateRuleForSinceTagName = calculateRuleForSinceTagName;
this.jiraProjectKeyList = jiraProjectKeyList;
+ this.gitLogTagNamesPattern = gitLogTagNamesPattern;
this.log = log;
}
@@ -51,34 +55,29 @@
GitLogHelper gitLogHelper = new GitLogHelper(log);
try {
- gitLogHelper.openRepository();
+ gitLogHelper.openRepositoryAndInitVersionTagList(gitLogTagNamesPattern);
} catch (Exception e) {
log.warn("cannot open git repository with message " + e.getMessage());
}
Date sinceDate = new Date(0L);
- try {
+
if (!CalculateRuleForSinceTagName.NO_RULE.equals(calculateRuleForSinceTagName)) {
log.debug(String.format(
- "Try to calculated tag name part by currentVersion %s and sinceVersion %s"
+ "Try to calculate tag name part by currentVersion %s and rule %s"
, currentVersion, calculateRuleForSinceTagName));
- String tagNamePart = VersionUtil.calculateSinceVersionTagNamePart(currentVersion, calculateRuleForSinceTagName);
- log.info(String.format("Calculated tag name part %s", tagNamePart));
- Collection<String> tagNames = gitLogHelper.getTagNames();
- List<String> tagNamesOfVersions = VersionUtil.calculateTagNamesOfVersions(tagNames, currentVersion, calculateRuleForSinceTagName);
-
- for (String tagNameWithVersion : tagNamesOfVersions) {
- Date date = gitLogHelper.extractDateOfCommitWithTagName(tagNameWithVersion);
- if (date.after(sinceDate)) {
- sinceDate = date;
+ String tagNamePart = VersionUtil.calculateVersionTagNamePart(currentVersion, calculateRuleForSinceTagName);
+ log.info(String.format("Calculated tag name part is %s", tagNamePart));
+ Collection<String> versionTagList = gitLogHelper.getVersionTagList();
+ String nearestVersionTagName = VersionUtil.findNearestVersionTagsBefore(versionTagList, tagNamePart);
+ log.info("Nearest version tag name found: " + nearestVersionTagName);
+ gitLogSinceTagName = nearestVersionTagName;
- }
+ }
- }
- } else {
+ try {
- sinceDate = gitLogHelper.extractDateOfCommitWithTagName(gitLogSinceTagName);
+ sinceDate = gitLogHelper.extractDateOfCommitWithTagName(gitLogSinceTagName);
- }
} catch (IOException e) {
log.warn("cannot extract date of commit with tag name ", e);
}
@@ -101,12 +100,9 @@
sink.rawText(report);
- // endSection();
-
- return;
-
-
}
-
+ public String getGitLogSinceTagName() {
+ return gitLogSinceTagName;
+ }
}