easegit-cli 1.0.4 → 1.0.5
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/git/plumbing.d.ts +1 -1
- package/dist/git/plumbing.js +10 -6
- package/package.json +1 -1
package/dist/git/plumbing.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export declare function getCheckpointInfo(refName: string): {
|
|
|
36
36
|
commitSha: string;
|
|
37
37
|
} | null;
|
|
38
38
|
/**
|
|
39
|
-
* Restore working directory from a
|
|
39
|
+
* Restore working directory from a commit SHA (restores all files including untracked)
|
|
40
40
|
*/
|
|
41
41
|
export declare function restoreFromTree(commitSha: string): void;
|
|
42
42
|
/**
|
package/dist/git/plumbing.js
CHANGED
|
@@ -143,7 +143,8 @@ function createCheckpointRef(treeSha, operation) {
|
|
|
143
143
|
*/
|
|
144
144
|
function getLatestCheckpointRef() {
|
|
145
145
|
try {
|
|
146
|
-
|
|
146
|
+
// Use -version:refname to sort refs numerically by the timestamp in the refname
|
|
147
|
+
const refs = gitExec(['for-each-ref', 'refs/easegit/checkpoints/', '--sort=-version:refname', '--format=%(refname)', '--count=1']);
|
|
147
148
|
return refs || null;
|
|
148
149
|
}
|
|
149
150
|
catch {
|
|
@@ -172,14 +173,17 @@ function getCheckpointInfo(refName) {
|
|
|
172
173
|
}
|
|
173
174
|
}
|
|
174
175
|
/**
|
|
175
|
-
* Restore working directory from a
|
|
176
|
+
* Restore working directory from a commit SHA (restores all files including untracked)
|
|
176
177
|
*/
|
|
177
178
|
function restoreFromTree(commitSha) {
|
|
178
|
-
|
|
179
|
-
|
|
179
|
+
// Get the tree from the commit
|
|
180
|
+
const treeSha = gitExec(['rev-parse', `${commitSha}^{tree}`]);
|
|
181
|
+
// Read the tree into index
|
|
182
|
+
gitExec(['read-tree', treeSha]);
|
|
183
|
+
// Checkout all files from index into working directory
|
|
184
|
+
gitExec(['checkout-index', '-f', '-a']);
|
|
185
|
+
// Clean up any files that existed in the old checkpoint but not the new one
|
|
180
186
|
gitExec(['clean', '-fd']);
|
|
181
|
-
// Checkout the tree without moving HEAD
|
|
182
|
-
gitExec(['checkout', commitSha, '--', '.']);
|
|
183
187
|
}
|
|
184
188
|
/**
|
|
185
189
|
* Check if there are merge conflicts
|