From d14c3ac2ce899902d0c88565a9ff9aab8cbe1f71 Mon Sep 17 00:00:00 2001 From: Daniel Farkas Date: Thu, 15 Oct 2026 15:50:02 +0200 Subject: [PATCH] Fix sentry recipe when release_path no longer exists Running `dep deploy:sentry` standalone (or after `deploy:symlink`) failed with `The "release_path" does not exist`, because the recipe read the revision and git log from {{release_path}}. - Use {{release_or_current_path}} for revision and git commands. - Resolve the previous release from `releases_list` when `previous_release` is not set (standalone run). - Limit commits with `git rev-list --max-count=200`; the previous array_slice counted the `commit ` header lines too, so only 100 commits were sent for the first release. Co-Authored-By: Claude Opus 5.5 --- contrib/sentry.php | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/contrib/sentry.php b/contrib/sentry.php index 516c16557..c564234ea 100644 --- a/contrib/sentry.php +++ b/contrib/sentry.php @@ -184,19 +184,38 @@ static function (&$value) use ($config) { }, ); +function getPreviousReleasePath(): ?string +{ + // Set by `deploy:release` when running as part of a deployment. + if (has('previous_release')) { + return get('previous_release'); + } + + // Standalone run (e.g. `dep deploy:sentry`): the newest release is the current + // one, so the previous one is the second in the list. + $releasesList = get('releases_list'); + if (isset($releasesList[1])) { + return parse("{{deploy_path}}/releases/{$releasesList[1]}"); + } + + return null; +} + function getPreviousReleaseRevision(): ?string { + $previousReleasePath = getPreviousReleasePath(); + switch (get('update_code_strategy')) { case 'local_archive': case 'archive': - if (has('previous_release')) { - return run('cat {{previous_release}}/REVISION'); + if ($previousReleasePath !== null) { + return trim(run("cat $previousReleasePath/REVISION")); } return null; case 'clone': - if (has('previous_release')) { - cd('{{previous_release}}'); + if ($previousReleasePath !== null) { + cd($previousReleasePath); return trim(run('git rev-parse HEAD')); } @@ -211,10 +230,10 @@ function getCurrentReleaseRevision(): string switch (get('update_code_strategy')) { case 'local_archive': case 'archive': - return run('cat {{release_path}}/REVISION'); + return run('cat {{release_or_current_path}}/REVISION'); case 'clone': - cd('{{release_path}}'); + cd('{{release_or_current_path}}'); return trim(run('git rev-parse HEAD')); default: @@ -230,7 +249,7 @@ function getReleaseGitRef(): Closure if ($strategy === 'archive') { cd('{{deploy_path}}/.dep/repo'); } else { - cd('{{release_path}}'); + cd('{{release_or_current_path}}'); } if (isset($config['git_version_command'])) { @@ -261,13 +280,13 @@ function getGitCommitsRefs(): Closure if (get('update_code_strategy') === 'archive') { cd('{{deploy_path}}/.dep/repo'); } else { - cd('{{release_path}}'); + cd('{{release_or_current_path}}'); } - $result = run(sprintf('git rev-list --pretty="%s" %s', 'format:%H#%an#%ae#%at#%s', $commitRange)); + // limit number of commits for first release with many commits + $result = run(sprintf('git rev-list --max-count=200 --pretty="%s" %s', 'format:%H#%an#%ae#%at#%s', $commitRange)); $lines = array_filter( - // limit number of commits for first release with many commits - array_map('trim', array_slice(explode("\n", $result), 0, 200)), + array_map('trim', explode("\n", $result)), static function (string $line): bool { return !empty($line) && strpos($line, 'commit') !== 0; },