Skip to content

Commit 87aef7e

Browse files
committed
refactor: rename parentRelease -> previousRelease
1 parent 4d9a57c commit 87aef7e

4 files changed

Lines changed: 45 additions & 45 deletions

File tree

lib/commands/ls.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export default class extends Command {
6666
: "-" ) },
6767
"pushed": { "title": ansi.hl( "NOT\nPUSHED" ), "width": 8, "align": "end", "headerAlign": "center" },
6868
"lastRelease": { "title": ansi.hl( "LAST\nRELEASE" ), "width": 20, "align": "end", "headerAlign": "center" },
69-
"parentRelease": { "title": ansi.hl( "PARENT\nRELEASE" ), "width": 23, "align": "end", "headerAlign": "center" },
69+
"previousRelease": { "title": ansi.hl( "PREVIOUS\nRELEASE" ), "width": 23, "align": "end", "headerAlign": "center" },
7070
"unreleasedCommits": { "title": ansi.hl( "UNRELEASED\nCOMMITS" ), "width": 12, "align": "end", "headerAlign": "center" },
7171
},
7272
} ).pipe( process.stdout );
@@ -101,7 +101,7 @@ export default class extends Command {
101101
: null;
102102

103103
const isDirty = status.isDirty || currentBranchPushStatus,
104-
isUnreleased = ( status.parentReleaseDistance || ( !status.head.branch && status.head.abbrev ) ) && pkg.isReleaseEnabled;
104+
isUnreleased = ( status.previousReleaseDistance || ( !status.head.branch && status.head.abbrev ) ) && pkg.isReleaseEnabled;
105105

106106
// unreleased filter includes unreleased and dirty packages
107107
if ( options.unreleased && !( isUnreleased || isDirty ) ) continue;
@@ -121,12 +121,12 @@ export default class extends Command {
121121
? ansi.error( ` ${ currentBranchPushStatus } ` )
122122
: " - ",
123123
"lastRelease": this.#formatVersion( status.releases.lastRelease, pkg.isReleaseEnabled ),
124-
"parentRelease": this.#formatVersion( status.parentRelease, pkg.isReleaseEnabled ) + ( status.parentRelease && status.releases?.lastRelease.eq( status.parentRelease )
124+
"previousRelease": this.#formatVersion( status.previousRelease, pkg.isReleaseEnabled ) + ( status.previousRelease && status.releases?.lastRelease.eq( status.previousRelease )
125125
? " 🚩"
126126
: " " ),
127127
"unreleasedCommits": pkg.isReleaseEnabled
128-
? ( status.parentReleaseDistance
129-
? ansi.error( ` ${ status.parentReleaseDistance } ` )
128+
? ( status.previousReleaseDistance
129+
? ansi.error( ` ${ status.previousReleaseDistance } ` )
130130
: " - " )
131131
: ansi.dim( " DISABLED " ),
132132
} );

lib/commands/status.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ Stable release (latest): ${ ansi.hl( status.releases.lastStableRelease?.versionS
4040
Last release (next): ${ ansi.hl( status.releases.lastRelease?.versionString || "-" ) }
4141
4242
Branch name: ${ ansi.hl( status.head.branch ) }
43-
Parent release: ${ ansi.hl( status.parentRelease?.versionString || "-" ) }${ status.parentRelease && status.releases.lastRelease?.eq( status.parentRelease )
43+
Previous release: ${ ansi.hl( status.previousRelease?.versionString || "-" ) }${ status.previousRelease && status.releases.lastRelease?.eq( status.previousRelease )
4444
? " 🚩"
4545
: "" }
4646
Working tree status: ${ status.isDirty
4747
? ansi.error( " DIRTY " )
4848
: ansi.ok( " COMMITED " ) }
4949
Unreleased commits: ${ pkg.isReleaseEnabled
50-
? ( status.parentReleaseDistance
51-
? ansi.error( " " + status.parentReleaseDistance + " " )
50+
? ( status.previousReleaseDistance
51+
? ansi.error( " " + status.previousReleaseDistance + " " )
5252
: ansi.ok( " RELEASED " ) )
5353
: "-" }
5454
`.trim() );
@@ -128,16 +128,16 @@ Clone wiki: ${ ansi.hl( upstream.wikiSshCloneUrl ) }
128128
}
129129
},
130130
},
131-
"parentRelease": {
132-
"title": ansi.hl( "PARENT\nRELEASE" ),
131+
"previousRelease": {
132+
"title": ansi.hl( "PREVIOUS\nRELEASE" ),
133133
"headerAlign": "center",
134134
"headerValign": "end",
135135
"width": 15,
136136
"align": "end",
137137
"format": status => {
138138
if ( pkg.isReleaseEnabled ) {
139-
if ( status.parentRelease ) {
140-
return `${ status.parentRelease.versionString }${ status.releases.lastRelease.eq( status.parentRelease )
139+
if ( status.previousRelease ) {
140+
return `${ status.previousRelease.versionString }${ status.releases.lastRelease.eq( status.previousRelease )
141141
? " 🚩"
142142
: " " }`;
143143
}
@@ -158,8 +158,8 @@ Clone wiki: ${ ansi.hl( upstream.wikiSshCloneUrl ) }
158158
"align": "end",
159159
"format": status => {
160160
if ( pkg.isReleaseEnabled ) {
161-
if ( status.parentReleaseDistance ) {
162-
return ansi.error( ` ${ status.parentReleaseDistance } ` );
161+
if ( status.previousReleaseDistance ) {
162+
return ansi.error( ` ${ status.previousReleaseDistance } ` );
163163
}
164164
else {
165165
return " - ";
@@ -174,12 +174,12 @@ Clone wiki: ${ ansi.hl( upstream.wikiSshCloneUrl ) }
174174
} );
175175

176176
for ( const branchName of Object.keys( status.branchStatus ).sort() ) {
177-
const res = await pkg.git.getParentRelease( { "commitRef": branchName } );
177+
const res = await pkg.git.getPreviousRelease( { "commitRef": branchName } );
178178

179179
table.write( {
180180
branchName,
181181
"syncStatus": status.branchStatus[ branchName ],
182-
"parentRelease": res.data,
182+
"previousRelease": res.data,
183183
"unreleasedCommits": res.data,
184184
} );
185185
}
@@ -188,7 +188,7 @@ Clone wiki: ${ ansi.hl( upstream.wikiSshCloneUrl ) }
188188

189189
return `${ table.content.trim() }
190190
🔶 - current branch
191-
🚩 - latest release
191+
🚩 - last release
192192
`.trim();
193193
}
194194

lib/git.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export default class Git extends CoreGit {
6060
var res;
6161

6262
if ( release ) {
63-
res = await this.getParentRelease( {
63+
res = await this.getPreviousRelease( {
6464
commitRef,
6565
stable,
6666
"changes": true,
@@ -76,7 +76,7 @@ export default class Git extends CoreGit {
7676
200,
7777
new GitChangelog( res.data.changes, {
7878
"upstream": this.upstream,
79-
"startRelease": res.data.parentRelease,
79+
"startRelease": res.data.previousRelease,
8080
"endRelease": null,
8181
commitTypes,
8282
} )

lib/package/release.js

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ export default class Publish {
1919
#yes;
2020
#repeatOnError;
2121

22-
#parentRelease;
22+
#previousRelease;
2323
#newRelease;
2424
#isMajorRelease;
2525
#originalBranch;
26-
#parentReleaseBranch;
26+
#previousReleaseBranch;
2727
#newReleaseBranch;
2828
#changelog;
2929
#changelogMarkdown;
@@ -76,30 +76,30 @@ export default class Publish {
7676
res = await this.getChangelog();
7777
if ( !res.ok ) return res;
7878

79-
this.#parentReleaseBranch = `v${ this.#parentRelease?.majorNumber || "0" }.x`;
79+
this.#previousReleaseBranch = `v${ this.#previousRelease?.majorNumber || "0" }.x`;
8080

8181
// detached head
8282
if ( !status.head.isBranchHead ) {
8383
return result( [ 500, "Release on tbe detached head is not possible" ] );
8484
}
8585

8686
// not a release branch head
87-
else if ( status.head.branch !== this.#parentReleaseBranch ) {
87+
else if ( status.head.branch !== this.#previousReleaseBranch ) {
8888
this.#originalBranch = status.head.branch;
8989

9090
// check allowed release branches
9191
if ( this.#pkg.cliConfig?.release.releaseBranches != null && ( !this.#pkg.cliConfig.release.releaseBranches || !this.#pkg.cliConfig.release.releaseBranches.includes( this.#originalBranch ) ) ) {
9292
return result( [ 500, "Unable to create release from the current branch" ] );
9393
}
9494

95-
// parent release commit must be a branch head for the parent release branch
96-
if ( this.#parentRelease ) {
97-
res = await this.#pkg.git.getCommit( { "commitRef": this.#parentRelease.versionString } );
95+
// previous release commit must be a branch head for the previous release branch
96+
if ( this.#previousRelease ) {
97+
res = await this.#pkg.git.getCommit( { "commitRef": this.#previousRelease.versionString } );
9898
if ( !res.ok ) return res;
99-
const parentReleaseCommit = res.data;
99+
const previousReleaseCommit = res.data;
100100

101-
if ( !parentReleaseCommit.branches.has( this.#parentReleaseBranch ) ) {
102-
return result( [ 500, `Release "${ this.#parentRelease.versionString }" must be a release branch "${ this.#parentReleaseBranch }" head` ] );
101+
if ( !previousReleaseCommit.branches.has( this.#previousReleaseBranch ) ) {
102+
return result( [ 500, `Release "${ this.#previousRelease.versionString }" must be a release branch "${ this.#previousReleaseBranch }" head` ] );
103103
}
104104
}
105105
}
@@ -114,7 +114,7 @@ export default class Publish {
114114
this.#newReleaseBranch = `v${ this.#newRelease.majorNumber }.x`;
115115

116116
// detect major release
117-
if ( this.#newRelease.isMajor && this.#parentRelease && this.#newRelease.majorNumber !== this.#parentRelease.majorNumber ) {
117+
if ( this.#newRelease.isMajor && this.#previousRelease && this.#newRelease.majorNumber !== this.#previousRelease.majorNumber ) {
118118
this.#isMajorRelease = true;
119119
}
120120

@@ -173,7 +173,7 @@ export default class Publish {
173173
console.log();
174174

175175
console.log( `New version: ${ ansi.underline( this.#newRelease.versionString ) }, tags: ${ this.#createTagsText() || "-" }` );
176-
console.log( `Parent version: ${ this.#parentRelease?.versionString || "-" }` );
176+
console.log( `Previous version: ${ this.#previousRelease?.versionString || "-" }` );
177177

178178
if ( this.#isMajorRelease ) {
179179
console.log( `New release branch "${ this.#newReleaseBranch }" will be created` );
@@ -228,18 +228,18 @@ export default class Publish {
228228
// prepare release branch
229229
if ( this.#originalBranch ) {
230230

231-
// merge the original branch to the parent release branch
232-
if ( this.#parentRelease ) {
233-
res = await this.#execGitCommand( `Switching to the branch "${ this.#parentReleaseBranch }"`, [ "switch", this.#parentReleaseBranch ], { "repeatOnError": false } );
231+
// merge the original branch to the previous release branch
232+
if ( this.#previousRelease ) {
233+
res = await this.#execGitCommand( `Switching to the branch "${ this.#previousReleaseBranch }"`, [ "switch", this.#previousReleaseBranch ], { "repeatOnError": false } );
234234
if ( !res.ok ) return res;
235235

236-
res = await this.#execGitCommand( `Merging the branch "${ this.#originalBranch }" to the branch "${ this.#parentReleaseBranch }"`, [ "merge", "--no-edit", "--quiet", "--ff-only", this.#originalBranch ], { "repeatOnError": false } );
236+
res = await this.#execGitCommand( `Merging the branch "${ this.#originalBranch }" to the branch "${ this.#previousReleaseBranch }"`, [ "merge", "--no-edit", "--quiet", "--ff-only", this.#originalBranch ], { "repeatOnError": false } );
237237
if ( !res.ok ) return res;
238238
}
239239

240240
// create release branch, if HEAD has no release branch
241-
else if ( !status.head.branches.has( this.#parentReleaseBranch ) ) {
242-
res = await this.#execGitCommand( `Creating and switching to the branch "${ this.#parentReleaseBranch }"`, [ "switch", "--create", this.#parentReleaseBranch ], { "repeatOnError": false } );
241+
else if ( !status.head.branches.has( this.#previousReleaseBranch ) ) {
242+
res = await this.#execGitCommand( `Creating and switching to the branch "${ this.#previousReleaseBranch }"`, [ "switch", "--create", this.#previousReleaseBranch ], { "repeatOnError": false } );
243243
if ( !res.ok ) return res;
244244
}
245245
}
@@ -251,17 +251,17 @@ export default class Publish {
251251
res = await this.#execGitCommand( `Creating and switching to the new release branch "${ this.#newReleaseBranch }"`, [ "switch", "--create", this.#newReleaseBranch ], { "repeatOnError": false } );
252252
if ( !res.ok ) return res;
253253

254-
// move parent release branch head
255-
if ( this.#parentRelease ) {
254+
// move previous release branch head
255+
if ( this.#previousRelease ) {
256256
res = await this.#execGitCommand(
257-
`Moving branch head "${ this.#parentReleaseBranch }" to the release "${ this.#parentRelease.versionString }"`,
257+
`Moving branch head "${ this.#previousReleaseBranch }" to the release "${ this.#previousRelease.versionString }"`,
258258
[
259259

260260
//
261261
"branch",
262262
"--force",
263-
this.#parentReleaseBranch,
264-
this.#parentRelease.versionString,
263+
this.#previousReleaseBranch,
264+
this.#previousRelease.versionString,
265265
],
266266
{ "repeatOnError": false }
267267
);
@@ -338,7 +338,7 @@ export default class Publish {
338338

339339
//
340340
this.#newReleaseBranch,
341-
this.#parentReleaseBranch,
341+
this.#previousReleaseBranch,
342342
this.#newRelease.versionString,
343343
this.#latestTag,
344344
this.#nextTag,
@@ -420,7 +420,7 @@ export default class Publish {
420420
async getChangelog ( { force } = {} ) {
421421
if ( force || !this.#changelog ) {
422422
this.#changelog = null;
423-
this.#parentRelease = null;
423+
this.#previousRelease = null;
424424

425425
// get changes
426426
const res = await this.#pkg.git.getChangelog( {
@@ -432,7 +432,7 @@ export default class Publish {
432432
if ( !res.ok ) return res;
433433

434434
this.#changelog = res.data;
435-
this.#parentRelease = this.#changelog.startRelease;
435+
this.#previousRelease = this.#changelog.startRelease;
436436
}
437437

438438
return result( 200, this.#changelog );

0 commit comments

Comments
 (0)