easegit-cli 1.0.4 → 1.0.6
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 +14 -9
- 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
|
@@ -123,9 +123,8 @@ function createCheckpointRef(treeSha, operation) {
|
|
|
123
123
|
const timestamp = Date.now();
|
|
124
124
|
const refName = `refs/easegit/checkpoints/${timestamp}`;
|
|
125
125
|
// Create a commit object for the checkpoint
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const commitArgs = ['commit-tree', treeSha, '-m', message];
|
|
126
|
+
// Use multiple -m flags for multi-line messages (Windows compatible)
|
|
127
|
+
const commitArgs = ['commit-tree', treeSha, '-m', `EaseGit checkpoint before ${operation}`, '-m', `Timestamp: ${timestamp}`];
|
|
129
128
|
try {
|
|
130
129
|
const head = gitExec(['rev-parse', 'HEAD']);
|
|
131
130
|
commitArgs.splice(2, 0, '-p', head);
|
|
@@ -143,7 +142,8 @@ function createCheckpointRef(treeSha, operation) {
|
|
|
143
142
|
*/
|
|
144
143
|
function getLatestCheckpointRef() {
|
|
145
144
|
try {
|
|
146
|
-
|
|
145
|
+
// Use -version:refname to sort refs numerically by the timestamp in the refname
|
|
146
|
+
const refs = gitExec(['for-each-ref', 'refs/easegit/checkpoints/', '--sort=-version:refname', '--format=%(refname)', '--count=1']);
|
|
147
147
|
return refs || null;
|
|
148
148
|
}
|
|
149
149
|
catch {
|
|
@@ -172,14 +172,19 @@ function getCheckpointInfo(refName) {
|
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
/**
|
|
175
|
-
* Restore working directory from a
|
|
175
|
+
* Restore working directory from a commit SHA (restores all files including untracked)
|
|
176
176
|
*/
|
|
177
177
|
function restoreFromTree(commitSha) {
|
|
178
|
-
|
|
179
|
-
|
|
178
|
+
// Get the tree from the commit
|
|
179
|
+
const treeSha = gitExec(['rev-parse', `${commitSha}^{tree}`]);
|
|
180
|
+
// Clear working directory first (except .git)
|
|
180
181
|
gitExec(['clean', '-fd']);
|
|
181
|
-
//
|
|
182
|
-
gitExec(['
|
|
182
|
+
// Read the tree into index
|
|
183
|
+
gitExec(['read-tree', treeSha]);
|
|
184
|
+
// Checkout all files from index into working directory
|
|
185
|
+
gitExec(['checkout-index', '-f', '-a']);
|
|
186
|
+
// Reset the index to match the restored tree so git status shows clean
|
|
187
|
+
gitExec(['reset', '--mixed']);
|
|
183
188
|
}
|
|
184
189
|
/**
|
|
185
190
|
* Check if there are merge conflicts
|