This repository was archived by the owner on May 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 196
#69 fixed #71
Closed
Closed
#69 fixed #71
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,37 +21,38 @@ | |
| */ | ||
| package com.github.maven.plugins.site; | ||
|
|
||
| import static java.lang.Integer.MAX_VALUE; | ||
| import static org.eclipse.egit.github.core.Blob.ENCODING_BASE64; | ||
| import static org.eclipse.egit.github.core.TreeEntry.MODE_BLOB; | ||
| import static org.eclipse.egit.github.core.TreeEntry.TYPE_BLOB; | ||
| import static org.eclipse.egit.github.core.TypedResource.TYPE_COMMIT; | ||
|
|
||
| import com.github.maven.plugins.core.GitHubProjectMojo; | ||
| import com.github.maven.plugins.core.PathUtils; | ||
| import com.github.maven.plugins.core.StringUtils; | ||
|
|
||
| import java.io.ByteArrayOutputStream; | ||
| import java.io.File; | ||
| import java.io.FileInputStream; | ||
| import java.io.IOException; | ||
| import static java.lang.Integer.MAX_VALUE; | ||
| import java.text.Format; | ||
| import java.text.MessageFormat; | ||
| import java.text.SimpleDateFormat; | ||
| import java.util.ArrayList; | ||
| import java.util.Arrays; | ||
| import java.util.Calendar; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
|
|
||
| import org.apache.maven.execution.MavenSession; | ||
| import org.apache.maven.plugin.MojoExecutionException; | ||
| import org.apache.maven.project.MavenProject; | ||
| import org.apache.maven.settings.Settings; | ||
| import org.eclipse.egit.github.core.Blob; | ||
| import static org.eclipse.egit.github.core.Blob.ENCODING_BASE64; | ||
| import org.eclipse.egit.github.core.Commit; | ||
| import org.eclipse.egit.github.core.CommitUser; | ||
| import org.eclipse.egit.github.core.Reference; | ||
| import org.eclipse.egit.github.core.RepositoryId; | ||
| import org.eclipse.egit.github.core.Tree; | ||
| import org.eclipse.egit.github.core.TreeEntry; | ||
| import static org.eclipse.egit.github.core.TreeEntry.MODE_BLOB; | ||
| import static org.eclipse.egit.github.core.TreeEntry.TYPE_BLOB; | ||
| import org.eclipse.egit.github.core.TypedResource; | ||
| import static org.eclipse.egit.github.core.TypedResource.TYPE_COMMIT; | ||
| import org.eclipse.egit.github.core.client.RequestException; | ||
| import org.eclipse.egit.github.core.service.DataService; | ||
| import org.eclipse.egit.github.core.util.EncodingUtils; | ||
|
|
@@ -418,10 +419,13 @@ public void execute() throws MojoExecutionException { | |
| + getExceptionMessage(e), e); | ||
| } | ||
|
|
||
| // Build commit | ||
| Commit commit = new Commit(); | ||
| commit.setMessage(message); | ||
| commit.setTree(tree); | ||
| // Build commit | ||
| Commit commit = new Commit(); | ||
| commit.setMessage(message); | ||
| commit.setTree(tree); | ||
| CommitUser user = this.createCommitUser(); | ||
| commit.setAuthor(user); | ||
| commit.setCommitter(user); | ||
|
|
||
| // Set parent commit SHA-1 if reference exists | ||
| if (ref != null) | ||
|
|
@@ -471,4 +475,13 @@ public void execute() throws MojoExecutionException { | |
| } | ||
| } | ||
| } | ||
| private CommitUser createCommitUser() { | ||
| CommitUser user = new CommitUser(); | ||
| user.setName("site-maven-plugin"); | ||
| user.setEmail("[email protected]"); | ||
| Format formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS"); | ||
| Calendar now = Calendar.getInstance(); | ||
| user.setDate(now.getTime()); | ||
| return user; | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
❓ so all commits are going to show up as a different user than the one running the commit... really not a good idea AFAIC
These values should be set to the ones configured for the repository in the local git config or fallback to the global git config
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.
Ideally yes, but at the moment the plugin doesn't work at all. Version 0.9 is broken and nobody can use it. Would be great if we can merge this temporary fix and release version 0.9.1. Then, we can think about making it fully configurable, etc. What do you think?
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've been unable to find the egit api docs; but I don't see why it should bypass the local git configuration stored in .git/config or the global config in the users home directory
I have several user accounts that I work with for different clients (so even using the
{user.name}provided by maven is not an option); this doesn't fix the problem for me.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.
@mprins @yegor256 I've just submitted a another pull request (#72) which similarly creates a CommitUser from the current github user's name and email address, which are provided by the EGit github UserService.