Skip to content

Commit

Permalink
mask user
Browse files Browse the repository at this point in the history
  • Loading branch information
dermatthes committed Jun 26, 2020
1 parent dc10281 commit 2878bab
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Git/HttpsGitRepository.php
Expand Up @@ -22,6 +22,8 @@ class HttpsGitRepository extends GitRepository
*/
private $gitPassword;

private $gitUser;

/**
* HttpsGitRepository constructor.
* @param string $origin
Expand All @@ -36,10 +38,14 @@ class HttpsGitRepository extends GitRepository
public function __construct(string $origin, string $repoDirectory, string $userName, string $email, string $gitUser, string $gitPassword)
{
$this->gitPassword = $gitPassword;
$this->gitUser = $gitUser;

$url = phore_parse_url($origin);
if ( ! empty($gitUser) || !empty($gitPassword))
$url = $url->withUserPass($gitUser, $gitPassword);
if ( ! empty($gitUser) || !empty($gitPassword)) {
$url = $url->withUserPass($gitUser, $gitPassword);
}
$this->gitPassword = $url->pass;
$this->gitUser = $url->user;

parent::__construct((string)$url, $repoDirectory, $userName, $email);
}
Expand Down Expand Up @@ -83,6 +89,7 @@ public function pull()
$this->currentPulledVersion = phore_exec("git -C :target rev-parse HEAD", ["target" => $this->repoDirectory]);
} catch (PhoreExecException $e) {
$msg = str_replace($this->gitPassword, "[MASKED]", $e->getMessage());
$msg = str_replace($this->gitUser, "[MASKED]", $msg);
$e->setMessage($msg);
throw $e;
}
Expand All @@ -97,6 +104,7 @@ public function push()
phore_exec("git -C :target push", ["target" => $this->repoDirectory]);
} catch (PhoreExecException $e) {
$msg = str_replace($this->gitPassword, "[MASKED]", $e->getMessage());
$msg = str_replace($this->gitUser, "[MASKED]", $msg);
$e->setMessage($msg);
throw $e;
}
Expand All @@ -122,6 +130,7 @@ public function getChangedFiles(): array
$this->currentPulledVersion = phore_exec("git -C :target rev-parse HEAD", ["target" => $this->repoDirectory]);
} catch (PhoreExecException $e) {
$msg = str_replace($this->gitPassword, "[MASKED]", $e->getMessage());
$msg = str_replace($this->gitUser, "[MASKED]", $msg);
$e->setMessage($msg);
throw $e;
}
Expand All @@ -134,6 +143,7 @@ public function getChangedFiles(): array
]);
} catch (PhoreExecException $e) {
$msg = str_replace($this->gitPassword, "[MASKED]", $e->getMessage());
$msg = str_replace($this->gitUser, "[MASKED]", $msg);
$e->setMessage($msg);
throw $e;
}
Expand Down

0 comments on commit 2878bab

Please sign in to comment.