Skip to content

Commit d7011cc

Browse files
committed
Don't modify state inside set callback
1 parent 66f036e commit d7011cc

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

docs/recipe/deploy/release.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,35 @@ The name of the release.
1818

1919

2020
### releases_log
21-
[Source](https://github.com/deployphp/deployer/blob/master/recipe/deploy/release.php#L16)
21+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/deploy/release.php#L14)
2222

2323
Holds releases log from `.dep/releases_log` file.
2424

2525

2626

2727
### releases_list
28-
[Source](https://github.com/deployphp/deployer/blob/master/recipe/deploy/release.php#L41)
28+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/deploy/release.php#L39)
2929

3030
Return list of release names on host.
3131

3232

3333

3434
### release_path
35-
[Source](https://github.com/deployphp/deployer/blob/master/recipe/deploy/release.php#L68)
35+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/deploy/release.php#L66)
3636

3737
Return release path.
3838

3939

4040

4141
### release_revision
42-
[Source](https://github.com/deployphp/deployer/blob/master/recipe/deploy/release.php#L79)
42+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/deploy/release.php#L77)
4343

4444
Current release revision. Usually a git hash.
4545

4646

4747

4848
### release_or_current_path
49-
[Source](https://github.com/deployphp/deployer/blob/master/recipe/deploy/release.php#L85)
49+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/deploy/release.php#L83)
5050

5151
Return the release path during a deployment
5252
but fallback to the current path otherwise.
@@ -57,15 +57,15 @@ but fallback to the current path otherwise.
5757
## Tasks
5858

5959
### deploy:release
60-
[Source](https://github.com/deployphp/deployer/blob/master/recipe/deploy/release.php#L92)
60+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/deploy/release.php#L90)
6161

6262
Prepare release.
6363

6464
Clean up unfinished releases and prepare next release
6565

6666

6767
### releases
68-
[Source](https://github.com/deployphp/deployer/blob/master/recipe/deploy/release.php#L141)
68+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/deploy/release.php#L144)
6969

7070
Show releases list.
7171

recipe/deploy/release.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
// The name of the release.
88
set('release_name', function () {
99
$latest = run('cat .dep/latest_release || echo 0');
10-
$releaseName = strval(intval($latest) + 1);
11-
run("echo $releaseName > .dep/latest_release");
12-
return $releaseName;
10+
return strval(intval($latest) + 1);
1311
});
1412

1513
// Holds releases log from `.dep/releases_log` file.
@@ -110,6 +108,11 @@
110108
throw new Exception("Release name \"$releaseName\" already exists.\nRelease name can be overridden via:\n dep deploy -o release_name=$releaseName");
111109
}
112110

111+
// Save release_name.
112+
if (is_numeric($releaseName) && is_integer(intval($releaseName))) {
113+
run("echo $releaseName > .dep/latest_release");
114+
}
115+
113116
// Metainfo.
114117
$timestamp = timestamp();
115118
$metainfo = [
@@ -155,6 +158,8 @@
155158
if (in_array($release, $releasesList, true)) {
156159
if (test("[ -f releases/$release/BAD_RELEASE ]")) {
157160
$status = "<error>$release</error> (bad)";
161+
} else if (test("[ -f releases/$release/DIRTY_RELEASE ]")) {
162+
$status = "<error>$release</error> (dirty)";
158163
} else {
159164
$status = "<info>$release</info>";
160165
}

0 commit comments

Comments
 (0)