|
39 | 39 | import java.util.ArrayList; |
40 | 40 | import java.util.Arrays; |
41 | 41 | import java.util.Collections; |
| 42 | +import java.util.GregorianCalendar; |
42 | 43 | import java.util.List; |
43 | 44 |
|
44 | 45 | import org.apache.maven.execution.MavenSession; |
|
47 | 48 | import org.apache.maven.settings.Settings; |
48 | 49 | import org.eclipse.egit.github.core.Blob; |
49 | 50 | import org.eclipse.egit.github.core.Commit; |
| 51 | +import org.eclipse.egit.github.core.CommitUser; |
50 | 52 | import org.eclipse.egit.github.core.Reference; |
51 | 53 | import org.eclipse.egit.github.core.RepositoryId; |
52 | 54 | import org.eclipse.egit.github.core.Tree; |
53 | 55 | import org.eclipse.egit.github.core.TreeEntry; |
54 | 56 | import org.eclipse.egit.github.core.TypedResource; |
| 57 | +import org.eclipse.egit.github.core.User; |
55 | 58 | import org.eclipse.egit.github.core.client.RequestException; |
56 | 59 | import org.eclipse.egit.github.core.service.DataService; |
| 60 | +import org.eclipse.egit.github.core.service.UserService; |
57 | 61 | import org.eclipse.egit.github.core.util.EncodingUtils; |
58 | 62 |
|
59 | 63 | /** |
@@ -423,6 +427,22 @@ public void execute() throws MojoExecutionException { |
423 | 427 | commit.setMessage(message); |
424 | 428 | commit.setTree(tree); |
425 | 429 |
|
| 430 | + try { |
| 431 | + UserService userService = new UserService(service.getClient()); |
| 432 | + User user = userService.getUser(); |
| 433 | + |
| 434 | + CommitUser author = new CommitUser(); |
| 435 | + author.setName(user.getName()); |
| 436 | + author.setEmail(user.getEmail()); |
| 437 | + author.setDate(new GregorianCalendar().getTime()); |
| 438 | + |
| 439 | + commit.setAuthor(author); |
| 440 | + commit.setCommitter(author); |
| 441 | + } catch (IOException e) { |
| 442 | + throw new MojoExecutionException("Error retrieving user info: " |
| 443 | + + getExceptionMessage(e), e); |
| 444 | + } |
| 445 | + |
426 | 446 | // Set parent commit SHA-1 if reference exists |
427 | 447 | if (ref != null) |
428 | 448 | commit.setParents(Collections.singletonList(new Commit().setSha(ref |
|
0 commit comments