Skip to content
This repository has been archived by the owner on Apr 26, 2020. It is now read-only.

Commit

Permalink
[Sentry] Added overwrite config for the git command (#206)
Browse files Browse the repository at this point in the history
* Added overwrite config for the git command

* Removed the default setting it will fallback automatically
  • Loading branch information
petermein authored and antonmedv committed Jan 8, 2019
1 parent 39cc123 commit fa582e4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/sentry.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ unless it's a first release, then only first 200 will be sent.
- **date_deploy_started** *(optional)* - date that indicates when the deploy started. Defaults to current time.
- **date_deploy_finished** *(optional)* - date that indicates when the deploy ended. If not provided, the current time is used.
- **deploy_name** *(optional)* - name of the deploy
- **git_version_command** *(optional)* - the commmand that retrieves the git version information (Defaults is set to git log -n 1 --format="%h", other options are git describe --tags --abbrev=0)

```php
// deploy.php
Expand Down
14 changes: 9 additions & 5 deletions recipe/sentry.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ function () {
'sentry_server' => 'https://sentry.io',
'previous_commit' => null,
'environment' => get('symfony_env', 'prod'),
'deploy_name' => null,
'deploy_name' => null
];

$config = array_merge($defaultConfig, (array) get('sentry'));
array_walk(
$config,
static function (&$value) {
static function (&$value) use ($config) {
if (is_callable($value)) {
$value = $value();
$value = $value($config);
}
}
);
Expand Down Expand Up @@ -132,16 +132,20 @@ static function (&$value) {

function getReleaseGitRef(): Closure
{
return static function (): string {
return static function ($config = []): string {
cd('{{release_path}}');

if(isset($config['git_version_command'])){
return trim(run($config['git_version_command']));
}

return trim(run('git log -n 1 --format="%h"'));
};
}

function getGitCommitsRefs(): Closure
{
return static function (): array {
return static function ($config = []): array {
$previousReleaseRevision = null;

if (has('previous_release')) {
Expand Down

0 comments on commit fa582e4

Please sign in to comment.