Skip to content

Commit

Permalink
fix: include first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Feb 14, 2022
1 parent ee07591 commit 31fc605
Show file tree
Hide file tree
Showing 24 changed files with 3,762 additions and 18 deletions.
18 changes: 9 additions & 9 deletions src/main/java/se/bjurr/gitchangelog/internal/git/GitRepo.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,22 +228,21 @@ private Map<String, RevTag> getAnnotatedTagPerTagName(
return tagPerCommit;
}

private List<RevCommit> getDiffingCommits(final RevCommit from, final RevCommit to)
throws Exception {
return this.getCommitList(from, to);
}

private ArrayList<RevCommit> getCommitList(final RevCommit from, final RevCommit to)
throws Exception {
private List<RevCommit> getCommitList(final RevCommit from, final RevCommit to) throws Exception {
final LogCommand logCommand = this.git.log().addRange(from, to);
if (this.hasPathFilter()) {
logCommand.addPath(this.pathFilter);
}
final ArrayList<RevCommit> list = new ArrayList<>();
final List<RevCommit> list = new ArrayList<>();
final Iterator<RevCommit> itr = logCommand.call().iterator();

while (itr.hasNext()) {
list.add(itr.next());
}
this.revWalk.parseHeaders(from);
if (from.getParentCount() == 0) {
list.add(from);
}
return list;
}

Expand Down Expand Up @@ -308,7 +307,7 @@ private List<GitTag> gitTags(
final RevCommit from = this.revWalk.lookupCommit(fromObjectId);
final RevCommit to = this.revWalk.lookupCommit(toObjectId);

this.commitsToInclude = this.getDiffingCommits(from, to);
this.commitsToInclude = this.getCommitList(from, to);

final List<Ref> tagList = this.tagsBetweenFromAndTo(from, to);
/**
Expand Down Expand Up @@ -489,6 +488,7 @@ private List<Ref> tagsBetweenFromAndTo(final ObjectId from, final ObjectId to) t
while (itr.hasNext()) {
icludedCommits.add(itr.next());
}

final List<Ref> includedTags = new ArrayList<>();
for (final Ref tag : tagList) {
final ObjectId peeledTag = this.getPeeled(tag);
Expand Down
23 changes: 22 additions & 1 deletion src/test/java/se/bjurr/gitchangelog/api/GitChangelogApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import se.bjurr.gitchangelog.internal.integrations.github.GitHubMockInterceptor;
import se.bjurr.gitchangelog.internal.integrations.github.GitHubServiceFactory;
import se.bjurr.gitchangelog.internal.integrations.jira.JiraClientFactory;
Expand Down Expand Up @@ -82,6 +84,26 @@ public void after() {
mock(null);
}

@Test
public void testThatFirstVersionCanBeGenerated() throws Exception {
final GitChangelogApi given =
gitChangelogApiBuilder() //
.withFromCommit(ZERO_COMMIT) //
.withToCommit("0.0.1");

ApprovalsWrapper.verify(given);
}

@Test
public void testThatSecondVersionCanBeGenerated() throws Exception {
final GitChangelogApi given =
gitChangelogApiBuilder() //
.withFromCommit(ZERO_COMMIT) //
.withToRef("1.0");

ApprovalsWrapper.verify(given);
}

@Test
public void testThatTagsThatAreEmptyAfterCommitsHaveBeenIgnoredAreRemoved() throws Exception {
final String templatePath = "templatetest/testAuthorsCommitsExtended.mustache";
Expand Down Expand Up @@ -305,7 +327,6 @@ public void testThatFileCanBeSupplied() throws Exception {
.withTemplatePath(templatePath) //
.toFile(path.toFile());

System.out.println(path.toFile().getAbsolutePath());
assertThat(path.toFile()).exists().isFile();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,16 @@ context:
"hashFull": "5aaeb907f68915aab5483f59d7026206935c0dc7",
"merge": false,
"message": "Initial commit"
},
{
"authorEmailAddress": "[email protected]",
"authorName": "Tomas Bjerre",
"commitTime": "2015-11-12 05:29:31",
"commitTimeLong": 1447306171000,
"hash": "a1aa5ff5b625e63",
"hashFull": "a1aa5ff5b625e63aa5ad7b59367ec7f75658afb8",
"merge": false,
"message": "Initial commit"
}
],
"tags": [
Expand Down Expand Up @@ -13533,6 +13543,16 @@ context:
"hashFull": "5aaeb907f68915aab5483f59d7026206935c0dc7",
"merge": false,
"message": "Initial commit"
},
{
"authorEmailAddress": "[email protected]",
"authorName": "Tomas Bjerre",
"commitTime": "2015-11-12 05:29:31",
"commitTimeLong": 1447306171000,
"hash": "a1aa5ff5b625e63",
"hashFull": "a1aa5ff5b625e63aa5ad7b59367ec7f75658afb8",
"merge": false,
"message": "Initial commit"
}
],
"authorName": "Tomas Bjerre",
Expand Down Expand Up @@ -13569,6 +13589,16 @@ context:
"hashFull": "5aaeb907f68915aab5483f59d7026206935c0dc7",
"merge": false,
"message": "Initial commit"
},
{
"authorEmailAddress": "[email protected]",
"authorName": "Tomas Bjerre",
"commitTime": "2015-11-12 05:29:31",
"commitTimeLong": 1447306171000,
"hash": "a1aa5ff5b625e63",
"hashFull": "a1aa5ff5b625e63aa5ad7b59367ec7f75658afb8",
"merge": false,
"message": "Initial commit"
}
],
"issues": [
Expand Down Expand Up @@ -13603,6 +13633,16 @@ context:
"hashFull": "5aaeb907f68915aab5483f59d7026206935c0dc7",
"merge": false,
"message": "Initial commit"
},
{
"authorEmailAddress": "[email protected]",
"authorName": "Tomas Bjerre",
"commitTime": "2015-11-12 05:29:31",
"commitTimeLong": 1447306171000,
"hash": "a1aa5ff5b625e63",
"hashFull": "a1aa5ff5b625e63aa5ad7b59367ec7f75658afb8",
"merge": false,
"message": "Initial commit"
}
],
"authors": [
Expand Down Expand Up @@ -13637,6 +13677,16 @@ context:
"hashFull": "5aaeb907f68915aab5483f59d7026206935c0dc7",
"merge": false,
"message": "Initial commit"
},
{
"authorEmailAddress": "[email protected]",
"authorName": "Tomas Bjerre",
"commitTime": "2015-11-12 05:29:31",
"commitTimeLong": 1447306171000,
"hash": "a1aa5ff5b625e63",
"hashFull": "a1aa5ff5b625e63aa5ad7b59367ec7f75658afb8",
"merge": false,
"message": "Initial commit"
}
],
"authorName": "Tomas Bjerre",
Expand Down Expand Up @@ -13694,6 +13744,16 @@ context:
"hashFull": "5aaeb907f68915aab5483f59d7026206935c0dc7",
"merge": false,
"message": "Initial commit"
},
{
"authorEmailAddress": "[email protected]",
"authorName": "Tomas Bjerre",
"commitTime": "2015-11-12 05:29:31",
"commitTimeLong": 1447306171000,
"hash": "a1aa5ff5b625e63",
"hashFull": "a1aa5ff5b625e63aa5ad7b59367ec7f75658afb8",
"merge": false,
"message": "Initial commit"
}
],
"authors": [
Expand Down Expand Up @@ -13728,6 +13788,16 @@ context:
"hashFull": "5aaeb907f68915aab5483f59d7026206935c0dc7",
"merge": false,
"message": "Initial commit"
},
{
"authorEmailAddress": "[email protected]",
"authorName": "Tomas Bjerre",
"commitTime": "2015-11-12 05:29:31",
"commitTimeLong": 1447306171000,
"hash": "a1aa5ff5b625e63",
"hashFull": "a1aa5ff5b625e63aa5ad7b59367ec7f75658afb8",
"merge": false,
"message": "Initial commit"
}
],
"authorName": "Tomas Bjerre",
Expand Down Expand Up @@ -14721,6 +14791,16 @@ context:
"hashFull": "5aaeb907f68915aab5483f59d7026206935c0dc7",
"merge": false,
"message": "Initial commit"
},
{
"authorEmailAddress": "[email protected]",
"authorName": "Tomas Bjerre",
"commitTime": "2015-11-12 05:29:31",
"commitTimeLong": 1447306171000,
"hash": "a1aa5ff5b625e63",
"hashFull": "a1aa5ff5b625e63aa5ad7b59367ec7f75658afb8",
"merge": false,
"message": "Initial commit"
}
],
"authorName": "Tomas Bjerre",
Expand Down Expand Up @@ -17007,6 +17087,16 @@ context:
"hashFull": "5aaeb907f68915aab5483f59d7026206935c0dc7",
"merge": false,
"message": "Initial commit"
},
{
"authorEmailAddress": "[email protected]",
"authorName": "Tomas Bjerre",
"commitTime": "2015-11-12 05:29:31",
"commitTimeLong": 1447306171000,
"hash": "a1aa5ff5b625e63",
"hashFull": "a1aa5ff5b625e63aa5ad7b59367ec7f75658afb8",
"merge": false,
"message": "Initial commit"
}
],
"authors": [
Expand Down Expand Up @@ -17621,6 +17711,16 @@ context:
"hashFull": "5aaeb907f68915aab5483f59d7026206935c0dc7",
"merge": false,
"message": "Initial commit"
},
{
"authorEmailAddress": "[email protected]",
"authorName": "Tomas Bjerre",
"commitTime": "2015-11-12 05:29:31",
"commitTimeLong": 1447306171000,
"hash": "a1aa5ff5b625e63",
"hashFull": "a1aa5ff5b625e63aa5ad7b59367ec7f75658afb8",
"merge": false,
"message": "Initial commit"
}
],
"authorName": "Tomas Bjerre",
Expand Down Expand Up @@ -19922,6 +20022,16 @@ context:
"hashFull": "5aaeb907f68915aab5483f59d7026206935c0dc7",
"merge": false,
"message": "Initial commit"
},
{
"authorEmailAddress": "[email protected]",
"authorName": "Tomas Bjerre",
"commitTime": "2015-11-12 05:29:31",
"commitTimeLong": 1447306171000,
"hash": "a1aa5ff5b625e63",
"hashFull": "a1aa5ff5b625e63aa5ad7b59367ec7f75658afb8",
"merge": false,
"message": "Initial commit"
}
],
"authors": [
Expand Down Expand Up @@ -20536,6 +20646,16 @@ context:
"hashFull": "5aaeb907f68915aab5483f59d7026206935c0dc7",
"merge": false,
"message": "Initial commit"
},
{
"authorEmailAddress": "[email protected]",
"authorName": "Tomas Bjerre",
"commitTime": "2015-11-12 05:29:31",
"commitTimeLong": 1447306171000,
"hash": "a1aa5ff5b625e63",
"hashFull": "a1aa5ff5b625e63aa5ad7b59367ec7f75658afb8",
"merge": false,
"message": "Initial commit"
}
],
"authorName": "Tomas Bjerre",
Expand Down
Loading

0 comments on commit 31fc605

Please sign in to comment.