Skip to content

Commit 55532dc

Browse files
committed
feat: add no-stash option to staged command
1 parent 076ad73 commit 55532dc

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

packages/rstack/src/staged.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ Usage:
99
Runs lint-staged with tasks from define.staged in rstack.config.
1010
1111
Options:
12-
--allow-empty allow empty commits when tasks revert all staged changes
13-
-p, --concurrent <number|boolean> the number of tasks to run concurrently, or false for serial
14-
-v, --verbose show task output even when tasks succeed; by default only failed output is shown
12+
--allow-empty Allow empty commits when tasks revert all staged changes
13+
-p, --concurrent <number|boolean> The number of tasks to run concurrently, or false for serial
14+
--no-stash Disable the backup stash. Implies "--no-revert".
15+
-v, --verbose Show task output even when tasks succeed; by default only failed output is shown
1516
-h, --help Display this help message`;
1617

1718
export async function runStagedCLI(args: string[]): Promise<void> {
@@ -22,6 +23,7 @@ export async function runStagedCLI(args: string[]): Promise<void> {
2223
allowEmpty: { type: 'boolean' },
2324
concurrent: { type: 'string', short: 'p' },
2425
help: { type: 'boolean', short: 'h' },
26+
'no-stash': { type: 'boolean' },
2527
verbose: { type: 'boolean', short: 'v' },
2628
},
2729
allowPositionals: false,
@@ -49,6 +51,7 @@ export async function runStagedCLI(args: string[]): Promise<void> {
4951
allowEmpty: values['allow-empty'] ?? values.allowEmpty ?? false,
5052
concurrent: values.concurrent === undefined ? true : JSON.parse(values.concurrent),
5153
config: stagedConfig,
54+
stash: !values['no-stash'],
5255
verbose: values.verbose ?? false,
5356
});
5457
if (!success) {

packages/rstack/test/cli/staged/index.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ test('should display the staged help message', ({ execCli, expect }) => {
6868
expect(output).toContain('Usage:\n $ rs staged [options]');
6969
expect(output).toContain('Runs lint-staged with tasks from define.staged in rstack.config.');
7070
expect(output).toContain('--allow-empty');
71+
expect(output).toContain('--no-stash');
7172
expect(output).toContain('-v, --verbose');
7273
expect(output).toContain('-h, --help');
7374
});
@@ -104,3 +105,10 @@ for (const option of ['--verbose', '-v']) {
104105
});
105106
});
106107
}
108+
109+
test('should run staged tasks without a backup stash', async ({ execCli, expect }) => {
110+
await withGitFixture((cwd) => {
111+
const output = execCli('staged --allow-empty --no-stash 2>&1', { cwd });
112+
expect(output).toContain('Skipping backup because `--no-stash` was used');
113+
});
114+
});

0 commit comments

Comments
 (0)