exec-staged 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/stage.js +16 -13
- package/package.json +1 -1
- package/src/lib/stage.ts +16 -13
package/dist/lib/stage.js
CHANGED
|
@@ -70,15 +70,15 @@ export class Stage {
|
|
|
70
70
|
this.logger.log('⚠️ Unsupported git version!');
|
|
71
71
|
throw new Error('unsupported git version');
|
|
72
72
|
}
|
|
73
|
-
let
|
|
73
|
+
let prefix;
|
|
74
74
|
try {
|
|
75
|
-
|
|
75
|
+
prefix = this.git(['rev-parse', '--show-prefix']).trim();
|
|
76
76
|
}
|
|
77
77
|
catch (error) {
|
|
78
78
|
this.logger.log('⚠️ Not a git repository!');
|
|
79
79
|
throw new Error('cwd is not a git repository');
|
|
80
80
|
}
|
|
81
|
-
if (
|
|
81
|
+
if (prefix !== '') {
|
|
82
82
|
this.logger.log('⚠️ Not in git root directory!');
|
|
83
83
|
throw new Error('cwd is not a git repository root directory');
|
|
84
84
|
}
|
|
@@ -237,16 +237,19 @@ export class Stage {
|
|
|
237
237
|
'-m',
|
|
238
238
|
STAGED_CHANGES_COMMIT_MESSAGE,
|
|
239
239
|
]);
|
|
240
|
-
// apply patch containing unstaged changes
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
240
|
+
// apply patch containing unstaged changes.
|
|
241
|
+
// `--allow-empty` could be used here, but it was not added to `git apply`
|
|
242
|
+
// until 2.35.0 (January 2022), so we skip the call when the patch is empty.
|
|
243
|
+
if (fs.statSync(this.patchPath).size > 0) {
|
|
244
|
+
this.git([
|
|
245
|
+
'apply',
|
|
246
|
+
'--recount',
|
|
247
|
+
'--unidiff-zero',
|
|
248
|
+
'--whitespace=nowarn',
|
|
249
|
+
'--3way',
|
|
250
|
+
this.patchPath,
|
|
251
|
+
]);
|
|
252
|
+
}
|
|
250
253
|
// unstaged deletions are not included in the patch and must be handled
|
|
251
254
|
// separately because the patch cannot be applied if such files are
|
|
252
255
|
// modified by tasks; use force: true to handle cases where the file
|
package/package.json
CHANGED
package/src/lib/stage.ts
CHANGED
|
@@ -90,16 +90,16 @@ export class Stage {
|
|
|
90
90
|
throw new Error('unsupported git version');
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
let
|
|
93
|
+
let prefix: string;
|
|
94
94
|
|
|
95
95
|
try {
|
|
96
|
-
|
|
96
|
+
prefix = this.git(['rev-parse', '--show-prefix']).trim();
|
|
97
97
|
} catch (error) {
|
|
98
98
|
this.logger.log('⚠️ Not a git repository!');
|
|
99
99
|
throw new Error('cwd is not a git repository');
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
if (
|
|
102
|
+
if (prefix !== '') {
|
|
103
103
|
this.logger.log('⚠️ Not in git root directory!');
|
|
104
104
|
throw new Error('cwd is not a git repository root directory');
|
|
105
105
|
}
|
|
@@ -311,16 +311,19 @@ export class Stage {
|
|
|
311
311
|
STAGED_CHANGES_COMMIT_MESSAGE,
|
|
312
312
|
]);
|
|
313
313
|
|
|
314
|
-
// apply patch containing unstaged changes
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
314
|
+
// apply patch containing unstaged changes.
|
|
315
|
+
// `--allow-empty` could be used here, but it was not added to `git apply`
|
|
316
|
+
// until 2.35.0 (January 2022), so we skip the call when the patch is empty.
|
|
317
|
+
if (fs.statSync(this.patchPath).size > 0) {
|
|
318
|
+
this.git([
|
|
319
|
+
'apply',
|
|
320
|
+
'--recount',
|
|
321
|
+
'--unidiff-zero',
|
|
322
|
+
'--whitespace=nowarn',
|
|
323
|
+
'--3way',
|
|
324
|
+
this.patchPath,
|
|
325
|
+
]);
|
|
326
|
+
}
|
|
324
327
|
|
|
325
328
|
// unstaged deletions are not included in the patch and must be handled
|
|
326
329
|
// separately because the patch cannot be applied if such files are
|