-
Notifications
You must be signed in to change notification settings - Fork 16
Add author to commits #28
base: master
Are you sure you want to change the base?
Changes from 2 commits
891ffa0
dd04017
86b4d36
529f94e
7a93cf7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,9 +32,7 @@ public function commands() | |
| { | ||
| $commands = array_get($this->config, 'commands_before', []); | ||
|
|
||
| foreach ($this->event->affectedPaths() as $path) { | ||
| $commands[] = "git add {$path}"; | ||
| } | ||
| $commands[] = "git add --all"; | ||
|
|
||
| $commands[] = $this->commitCommand(); | ||
|
|
||
|
|
@@ -61,21 +59,36 @@ protected function commitCommand() | |
| $parts = ['git']; | ||
|
|
||
| if ($username = array_get($this->config, 'git_username')) { | ||
| $parts[] = sprintf('-c "user.name=%s"', $username); | ||
| $parts[] = '-c'; | ||
| $parts[] = escapeshellarg("user.name=" . $username); | ||
|
knut-forkalsrud marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| if ($email = array_get($this->config, 'git_email')) { | ||
| $parts[] = sprintf('-c "user.email=%s"', $email); | ||
| $parts[] = '-c'; | ||
| $parts[] = escapeshellarg("user.email=" . $email); | ||
| } | ||
|
|
||
| $message = 'commit -m "' . $this->label(); | ||
| $message .= $this->user ? ' by ' . $this->user->username() : ''; | ||
| $message .= '"'; | ||
| $parts[] = $message; | ||
|
|
||
| $parts[] = 'commit'; | ||
| if ($this->user) { | ||
| $parts[] = escapeshellarg($this->author()); | ||
| } | ||
| $parts[] = '-m'; | ||
| $parts[] = escapeshellarg(sprintf("%s%s", $this->label(), $this->user ? ' by ' . $this->user->username() : '')); | ||
|
knut-forkalsrud marked this conversation as resolved.
Outdated
|
||
| return join(' ', $parts); | ||
| } | ||
|
|
||
|
|
||
|
|
||
| /** | ||
| * Create a Git author parameter from the user's name and email address, | ||
| * i.e, "--author=A U Thor <author@example.com>" | ||
| */ | ||
| protected function author() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method could be private
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed it could be private, however all the other similar methods are protected, so I'd rather follow suit on that. |
||
| $user = $this->user->toArray(); | ||
| return sprintf("--author=%s <%s>", $user['name'], $user['email']); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you use the getter methods on the User object?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, I can't get |
||
| } | ||
|
|
||
|
|
||
| /** | ||
| * Get the label of the class, which is the action name. | ||
| * | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.