From 97cac155f9b70f3cba33ee55e73b0f6b0225190c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milan=20Ho=C5=A1ko?= Date: Wed, 5 Aug 2020 12:26:34 +0200 Subject: [PATCH] Add methods for settings email and name or both Add methods setUserName, setUserEmail and setUserNameAndEmail, for quick set the name, email or both --- src/GitRepository.php | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/GitRepository.php b/src/GitRepository.php index 66d67b2..4ff2555 100644 --- a/src/GitRepository.php +++ b/src/GitRepository.php @@ -996,5 +996,45 @@ public function getCommitData($commit) return $data; } + + /** + * Set the user name + * `git config user.name %user_name` + * @param string $user_name + * @return self + */ + public function setUserName($user_name) + { + $this->begin(); + exec('git config user.name "' . $user_name . '"'); + $this->end(); + return $this; + } + + /** + * Set the user email + * `git config user.email %user_email` + * @param string $user_email + * @return self + */ + public function setUserEmail($user_email) + { + $this->begin(); + exec('git config user.email "' . $user_email . '"'); + $this->end(); + return $this; + } + + /** + * Set the user name and email + * @param string $user_name + * @param string $user_email + * @return self + */ + public function setUserNameAndEmail($user_name, $user_email) + { + return $this->setUserName($user_name) + ->setUserEmail($user_email); + } }