Skip to content

Commit 3bf15f1

Browse files
committed
feat: change release branch to vx.x format
1 parent eda7879 commit 3bf15f1

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

lib/package/release.js

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

22+
#previousRelease;
2223
#currentRelease;
2324
#isMajorRelease;
2425
#currentBranch;
@@ -71,7 +72,7 @@ export default class Publish {
7172
if ( !res.ok ) return res;
7273
const status = res.data;
7374

74-
this.#previousBranch = `v${ this.#changelog.previousRelease?.majorNumber || "0" }.branch`;
75+
this.#previousBranch = `v${ this.#previousRelease?.majorNumber || "0" }.x`;
7576

7677
// check branch
7778
if ( !status.head.isBranchHead ) {
@@ -93,10 +94,10 @@ export default class Publish {
9394
if ( !res.ok ) return res;
9495
this.#currentRelease = res.data;
9596

96-
this.#currentBranch = `v${ this.#currentRelease.majorNumber }.branch`;
97+
this.#currentBranch = `v${ this.#currentRelease.majorNumber }.x`;
9798

9899
// detect major release
99-
if ( this.#currentRelease.isMajor && this.#changelog.previousRelease && this.#currentRelease.majorNumber !== this.#changelog.previousRelease.majorNumber ) {
100+
if ( this.#currentRelease.isMajor && this.#previousRelease && this.#currentRelease.majorNumber !== this.#previousRelease.majorNumber ) {
100101
this.#isMajorRelease = true;
101102
}
102103

@@ -155,7 +156,7 @@ export default class Publish {
155156
console.log();
156157

157158
console.log( `New version: ${ ansi.underline( this.#currentRelease.versionString ) }, tags: ${ this.#createTagsText() || "-" }` );
158-
console.log( `Previous version: ${ this.#changelog.previousRelease?.versionString || "-" }` );
159+
console.log( `Previous version: ${ this.#previousRelease?.versionString || "-" }` );
159160

160161
if ( this.#isMajorRelease ) {
161162
console.log( `New release branch "${ this.#currentBranch }" will be created` );
@@ -213,14 +214,14 @@ export default class Publish {
213214
if ( !res.ok ) return res;
214215

215216
// move previous release branch head
216-
if ( this.#changelog.previousRelease ) {
217+
if ( this.#previousRelease ) {
217218
res = await this.#pkg.git.exec( [
218219

219220
//
220221
"branch",
221222
"--force",
222223
this.#previousBranch,
223-
this.#changelog.previousRelease.versionString,
224+
this.#previousRelease.versionString,
224225
] );
225226
if ( !res.ok ) return res;
226227
}
@@ -420,6 +421,7 @@ export default class Publish {
420421
async getChangelog ( { force } = {} ) {
421422
if ( force || !this.#changelog ) {
422423
this.#changelog = null;
424+
this.#previousRelease = null;
423425

424426
// get changes
425427
const res = await this.#pkg.git.getChangelog( {
@@ -431,6 +433,7 @@ export default class Publish {
431433
if ( !res.ok ) return res;
432434

433435
this.#changelog = res.data;
436+
this.#previousRelease = this.#changelog.previousRelease;
434437
}
435438

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

0 commit comments

Comments
 (0)