Skip to content

Commit

Permalink
Merge pull request #921 from mta-trackunit/fix-add-to-stage-continue
Browse files Browse the repository at this point in the history
fix: support continue chain so package.json will be updated
  • Loading branch information
edbzn authored Dec 5, 2024
2 parents 261715e + f4e1388 commit fc65f2f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
15 changes: 15 additions & 0 deletions packages/semver/src/executors/version/utils/git.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,21 @@ describe('git', () => {
expect(cp.exec).not.toBeCalled();
});

it('should skip add to git stage if skipStage is true but should continue the chain', async () => {
jest.spyOn(cp, 'exec').mockReturnValue(of('ok'));

const value = await lastValueFrom(
addToStage({
paths: ['packages/demo/file.txt', 'packages/demo/other-file.ts'],
dryRun: false,
skipStage: true,
}),
);

expect(cp.exec).not.toBeCalled();
expect(value).toEqual(undefined);
});

it('should skip git add if paths argument is empty', async () => {
jest.spyOn(cp, 'exec').mockReturnValue(of('ok'));

Expand Down
5 changes: 3 additions & 2 deletions packages/semver/src/executors/version/utils/git.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as gitRawCommits from 'git-raw-commits';
import { EMPTY, Observable, throwError } from 'rxjs';
import { EMPTY, Observable, of, throwError } from 'rxjs';
import { catchError, last, map, scan, startWith } from 'rxjs/operators';
import { exec } from '../../common/exec';
import { logStep, _logStep } from './logger';
Expand Down Expand Up @@ -137,7 +137,8 @@ export function addToStage({
if (paths.length === 0) {
return EMPTY;
} else if (skipStage) {
return EMPTY;
// skip stage and return like this to ensure the chain will continue.
return of(undefined);
}

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

0 comments on commit fc65f2f

Please sign in to comment.