easegit-cli 1.0.5 → 1.0.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.
- package/dist/git/plumbing.js +19 -15
- package/package.json +1 -1
package/dist/git/plumbing.js
CHANGED
|
@@ -51,16 +51,19 @@ const path = __importStar(require("path"));
|
|
|
51
51
|
* Execute a Git command and return output
|
|
52
52
|
*/
|
|
53
53
|
function gitExec(args, cwd) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
54
|
+
const result = (0, child_process_1.spawnSync)('git', args, {
|
|
55
|
+
cwd: cwd || process.cwd(),
|
|
56
|
+
encoding: 'utf8',
|
|
57
|
+
stdio: ['pipe', 'pipe', 'pipe']
|
|
58
|
+
});
|
|
59
|
+
if (result.error) {
|
|
60
|
+
throw new Error(`Git command failed: ${result.error.message}`);
|
|
61
|
+
}
|
|
62
|
+
if (result.status !== 0) {
|
|
63
|
+
const stderr = result.stderr ? result.stderr.toString().trim() : '';
|
|
64
|
+
throw new Error(`Git command failed: ${stderr || 'Unknown error'}`);
|
|
65
|
+
}
|
|
66
|
+
return (result.stdout || '').toString().trim();
|
|
64
67
|
}
|
|
65
68
|
/**
|
|
66
69
|
* Check if current directory is a Git repository
|
|
@@ -123,9 +126,8 @@ function createCheckpointRef(treeSha, operation) {
|
|
|
123
126
|
const timestamp = Date.now();
|
|
124
127
|
const refName = `refs/easegit/checkpoints/${timestamp}`;
|
|
125
128
|
// Create a commit object for the checkpoint
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const commitArgs = ['commit-tree', treeSha, '-m', message];
|
|
129
|
+
// Use multiple -m flags for multi-line messages (Windows compatible)
|
|
130
|
+
const commitArgs = ['commit-tree', treeSha, '-m', `EaseGit checkpoint before ${operation}`, '-m', `Timestamp: ${timestamp}`];
|
|
129
131
|
try {
|
|
130
132
|
const head = gitExec(['rev-parse', 'HEAD']);
|
|
131
133
|
commitArgs.splice(2, 0, '-p', head);
|
|
@@ -178,12 +180,14 @@ function getCheckpointInfo(refName) {
|
|
|
178
180
|
function restoreFromTree(commitSha) {
|
|
179
181
|
// Get the tree from the commit
|
|
180
182
|
const treeSha = gitExec(['rev-parse', `${commitSha}^{tree}`]);
|
|
183
|
+
// Clear working directory first (except .git)
|
|
184
|
+
gitExec(['clean', '-fd']);
|
|
181
185
|
// Read the tree into index
|
|
182
186
|
gitExec(['read-tree', treeSha]);
|
|
183
187
|
// Checkout all files from index into working directory
|
|
184
188
|
gitExec(['checkout-index', '-f', '-a']);
|
|
185
|
-
//
|
|
186
|
-
gitExec(['
|
|
189
|
+
// Reset the index to match the restored tree so git status shows clean
|
|
190
|
+
gitExec(['reset', '--mixed']);
|
|
187
191
|
}
|
|
188
192
|
/**
|
|
189
193
|
* Check if there are merge conflicts
|