Skip to content

Commit fc65f2f

Browse files
authored
Merge pull request #921 from mta-trackunit/fix-add-to-stage-continue
fix: support continue chain so package.json will be updated
2 parents 261715e + f4e1388 commit fc65f2f

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

packages/semver/src/executors/version/utils/git.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,21 @@ describe('git', () => {
201201
expect(cp.exec).not.toBeCalled();
202202
});
203203

204+
it('should skip add to git stage if skipStage is true but should continue the chain', async () => {
205+
jest.spyOn(cp, 'exec').mockReturnValue(of('ok'));
206+
207+
const value = await lastValueFrom(
208+
addToStage({
209+
paths: ['packages/demo/file.txt', 'packages/demo/other-file.ts'],
210+
dryRun: false,
211+
skipStage: true,
212+
}),
213+
);
214+
215+
expect(cp.exec).not.toBeCalled();
216+
expect(value).toEqual(undefined);
217+
});
218+
204219
it('should skip git add if paths argument is empty', async () => {
205220
jest.spyOn(cp, 'exec').mockReturnValue(of('ok'));
206221

packages/semver/src/executors/version/utils/git.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as gitRawCommits from 'git-raw-commits';
2-
import { EMPTY, Observable, throwError } from 'rxjs';
2+
import { EMPTY, Observable, of, throwError } from 'rxjs';
33
import { catchError, last, map, scan, startWith } from 'rxjs/operators';
44
import { exec } from '../../common/exec';
55
import { logStep, _logStep } from './logger';
@@ -137,7 +137,8 @@ export function addToStage({
137137
if (paths.length === 0) {
138138
return EMPTY;
139139
} else if (skipStage) {
140-
return EMPTY;
140+
// skip stage and return like this to ensure the chain will continue.
141+
return of(undefined);
141142
}
142143

143144
const gitAddOptions = [...(dryRun ? ['--dry-run'] : []), ...paths];

0 commit comments

Comments
 (0)