lint-staged 10.1.6 → 10.1.7

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.
Files changed (2) hide show
  1. package/lib/gitWorkflow.js +10 -14
  2. package/package.json +1 -1
@@ -159,6 +159,7 @@ class GitWorkflow {
159
159
  return index !== ' ' && workingTree !== ' ' && index !== '?' && workingTree !== '?'
160
160
  })
161
161
  .map((line) => line.substr(3)) // Remove first three letters (index, workingTree, and a whitespace)
162
+ .filter(Boolean) // Filter empty string
162
163
  debug('Found partially staged files:', partiallyStaged)
163
164
  return partiallyStaged.length ? partiallyStaged : null
164
165
  }
@@ -186,24 +187,19 @@ class GitWorkflow {
186
187
  */
187
188
  if (!shouldBackup) return
188
189
 
190
+ // When backup is enabled, the revert will clear ongoing merge status.
191
+ await this.backupMergeStatus()
192
+
189
193
  // Get a list of unstaged deleted files, because certain bugs might cause them to reappear:
190
- // - in git versions =< 2.13.0 the `--keep-index` flag resurrects deleted files
194
+ // - in git versions =< 2.13.0 the `git stash --keep-index` option resurrects deleted files
191
195
  // - git stash can't infer RD or MD states correctly, and will lose the deletion
192
196
  this.deletedFiles = await this.getDeletedFiles()
193
197
 
194
- // the `git stash` clears metadata about a possible git merge
195
- // Manually check and backup if necessary
196
- await this.backupMergeStatus()
197
-
198
- // Save stash of original state
199
- await this.execGit(['stash', 'save', STASH])
200
- await this.execGit(['stash', 'apply', '--quiet', '--index', await this.getBackupStash()])
201
-
202
- // Restore meta information about ongoing git merge, cleared by `git stash`
203
- await this.restoreMergeStatus()
204
-
205
- // If stashing resurrected deleted files, clean them out
206
- await Promise.all(this.deletedFiles.map((file) => unlink(file)))
198
+ // Save stash of all staged files.
199
+ // The `stash create` command creates a dangling commit without removing any files,
200
+ // and `stash store` saves it as an actual stash.
201
+ const hash = await this.execGit(['stash', 'create'])
202
+ await this.execGit(['stash', 'store', '--quiet', '--message', STASH, hash])
207
203
 
208
204
  debug('Done backing up original state!')
209
205
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lint-staged",
3
- "version": "10.1.6",
3
+ "version": "10.1.7",
4
4
  "description": "Lint files staged by git",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/okonet/lint-staged",