Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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]");
Copy link
Contributor

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

Copy link
Author

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?

Copy link
Contributor

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.

Copy link
Contributor

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.

Format formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
Calendar now = Calendar.getInstance();
user.setDate(now.getTime());
return user;
}
}