-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Submodule support #79
Conversation
I'll put this on my todo-list. |
I have a better idea on how to handle submodules. E.g. in the parent repo, we have When diffing between A and C, we will also show the diff between D and F for commit C |
Sounds good! |
Great, I'll update the pull request once I have it working. |
How does this look? I've opted out of having submodule changes per commit, as it makes the changelog too noisy, especially when mulitiple commits reference the same changes in submodules, e.g. via branch merges. Instead, I diff submodules between the earliest and the latest commit mentioned in the parent repository for any given diffset. |
This is on my todo-list. Will have a look later. |
@@ -380,6 +379,12 @@ public GitChangelogApi withSettings(final URL url) { | |||
return this; | |||
} | |||
|
|||
/** {@link Settings}. */ | |||
public GitChangelogApi withSettings(final Settings settings) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont like to expose Settings in the API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a better way to provide an existing Settings object?
|
||
public GitRepo() { | ||
this.repository = null; | ||
this.revWalk = null; | ||
this.submodules = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer an empty map here, not null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
} | ||
} | ||
} else { | ||
this.submodules = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should not be needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
@@ -89,6 +105,11 @@ public void close() throws IOException { | |||
LOG.error(e.getMessage(), e); | |||
} | |||
} | |||
if (submodules != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if
is not needed, if changing to empty map as default value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
@@ -142,6 +163,45 @@ public ObjectId getRef(final String fromRef) throws GitChangelogRepositoryExcept | |||
throw new GitChangelogRepositoryException(fromRef + " not found in:\n" + toString()); | |||
} | |||
|
|||
public boolean hasSubmodules() { | |||
return submodules != null && submodules.size() > 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This null-check is not needed, if changing to empty map as default value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
commit = this.revWalk.parseCommit(getCommit(commitHash)); | ||
prevCommit = commit.getParentCount() > 0 ? commit.getParent(0) : null; | ||
} catch (GitChangelogRepositoryException | IOException e) { | ||
e.printStackTrace(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw GitChangelogRepositoryException
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
diffFormatter.format(diffFormatter.toFileHeader(entry)); | ||
} | ||
} catch (IOException e) { | ||
e.printStackTrace(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw GitChangelogRepositoryException
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
try { | ||
return new CanonicalTreeParser(null, reader, treeId); | ||
} catch (IOException e) { | ||
e.printStackTrace(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw GitChangelogRepositoryException
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
.withSettings(settings) | ||
.getChangelog(useIntegrationIfConfigured)); | ||
} catch (GitChangelogRepositoryException e) { | ||
e.printStackTrace(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw GitChangelogRepositoryException
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Hi @tomasbjerre , I have added a couple of test cases.
Something like GitRepoWithSubmodules class that inherits from GitRepo? Or is there an easier way to get access to repository and revWalk class members from GitRepo, as submodule functionality makes use of those? |
b65386f
to
4b5ca4f
Compare
1dcafd8
to
9cb1ff1
Compare
a1bf908
to
ccace50
Compare
5955bcb
to
7dc00e2
Compare
0d44d86
to
0ab5a28
Compare
Hello, this is for #52
I'm not too sure how to correctly support submodules, to be honest, but this seems to be working for my use case: pushing tags on each build for the parent repository and its submodules, in other words, we rely on tags being the same across the repository.
What do you think?
I have also added a simple check for when toRef and fromRef are the same, #62 - in this case we return an empty list of tags.