Skip to content

Commit 1b05891

Browse files
committed
style: refactor code
1 parent 47938bd commit 1b05891

1 file changed

Lines changed: 20 additions & 20 deletions

File tree

lib/package/release.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ export default class Publish {
2323
#currentRelease;
2424
#isMajorRelease;
2525
#originalBranch;
26-
#currentBranch;
27-
#previousBranch;
26+
#currentReleaseBranch;
27+
#previousReleaseBranch;
2828
#changelog;
2929
#changelogMarkdown;
3030
#changelogText;
@@ -76,15 +76,15 @@ export default class Publish {
7676
res = await this.getChangelog();
7777
if ( !res.ok ) return res;
7878

79-
this.#previousBranch = `v${ this.#previousRelease?.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.#previousBranch ) {
87+
else if ( status.head.branch !== this.#previousReleaseBranch ) {
8888
this.#originalBranch = status.head.branch;
8989

9090
// check allowed branch
@@ -98,8 +98,8 @@ export default class Publish {
9898
if ( !res.ok ) return res;
9999
const previousReleaseCommit = res.data;
100100

101-
if ( !previousReleaseCommit.branches.has( this.#previousBranch ) ) {
102-
return result( [ 500, `Release "${ this.#previousRelease.versionString }" must be a release branch "${ this.#previousBranch }" 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
}
@@ -111,7 +111,7 @@ export default class Publish {
111111
if ( !res.ok ) return res;
112112
this.#currentRelease = res.data;
113113

114-
this.#currentBranch = `v${ this.#currentRelease.majorNumber }.x`;
114+
this.#currentReleaseBranch = `v${ this.#currentRelease.majorNumber }.x`;
115115

116116
// detect major release
117117
if ( this.#currentRelease.isMajor && this.#previousRelease && this.#currentRelease.majorNumber !== this.#previousRelease.majorNumber ) {
@@ -176,7 +176,7 @@ export default class Publish {
176176
console.log( `Previous version: ${ this.#previousRelease?.versionString || "-" }` );
177177

178178
if ( this.#isMajorRelease ) {
179-
console.log( `New release branch "${ this.#currentBranch }" will be created` );
179+
console.log( `New release branch "${ this.#currentReleaseBranch }" will be created` );
180180
}
181181
console.log();
182182

@@ -230,16 +230,16 @@ export default class Publish {
230230

231231
// merge the previous release branch with the original branch
232232
if ( this.#previousRelease ) {
233-
res = await this.#execGitCommand( `Switching to the branch "${ this.#previousBranch }"`, [ "switch", this.#previousBranch ], { "repeatOnError": false } );
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.#previousBranch }"`, [ "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.#previousBranch ) ) {
242-
res = await this.#execGitCommand( `Creating and switching to the branch "${ this.#previousBranch }"`, [ "switch", "--create", this.#previousBranch ], { "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
}
@@ -248,19 +248,19 @@ export default class Publish {
248248
if ( this.#isMajorRelease ) {
249249

250250
// create and switch major release branch
251-
res = await this.#execGitCommand( `Creating and switching to the new release branch "${ this.#currentBranch }"`, [ "switch", "--create", this.#currentBranch ], { "repeatOnError": false } );
251+
res = await this.#execGitCommand( `Creating and switching to the new release branch "${ this.#currentReleaseBranch }"`, [ "switch", "--create", this.#currentReleaseBranch ], { "repeatOnError": false } );
252252
if ( !res.ok ) return res;
253253

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

260260
//
261261
"branch",
262262
"--force",
263-
this.#previousBranch,
263+
this.#previousReleaseBranch,
264264
this.#previousRelease.versionString,
265265
],
266266
{ "repeatOnError": false }
@@ -315,13 +315,13 @@ export default class Publish {
315315

316316
// track current release branch
317317
if ( this.#isMajorRelease ) {
318-
res = await this.#execGitCommand( `Setting upstream for the branch "${ this.#currentBranch }"`, [
318+
res = await this.#execGitCommand( `Setting upstream for the branch "${ this.#currentReleaseBranch }"`, [
319319

320320
//
321321
"push",
322322
"--set-upstream",
323323
"origin",
324-
this.#currentBranch,
324+
this.#currentReleaseBranch,
325325
] );
326326
if ( !res.ok ) return res;
327327
}
@@ -337,8 +337,8 @@ export default class Publish {
337337
...new Set( [
338338

339339
//
340-
this.#currentBranch,
341-
this.#previousBranch,
340+
this.#currentReleaseBranch,
341+
this.#previousReleaseBranch,
342342
this.#currentRelease.versionString,
343343
this.#latestTag,
344344
this.#nextTag,
@@ -399,7 +399,7 @@ export default class Publish {
399399
res = await this.#execGitCommand( `Switching to the branch "${ this.#originalBranch }"`, [ "switch", this.#originalBranch ], { "repeatOnError": false } );
400400
if ( !res.ok ) return res;
401401

402-
res = await this.#execGitCommand( `Merging the branch "${ this.#currentBranch }" to the branch "${ this.#originalBranch }"`, [ "merge", "--no-edit", "--quiet", "--ff-only", this.#currentBranch ], { "repeatOnError": false } );
402+
res = await this.#execGitCommand( `Merging the branch "${ this.#currentReleaseBranch }" to the branch "${ this.#originalBranch }"`, [ "merge", "--no-edit", "--quiet", "--ff-only", this.#currentReleaseBranch ], { "repeatOnError": false } );
403403
if ( !res.ok ) return res;
404404

405405
if ( this.#pkg.git.upstream ) {

0 commit comments

Comments
 (0)