gent-cli 1.7.0 → 1.8.0
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/package.json
CHANGED
package/src/commands/commit.js
CHANGED
|
@@ -82,21 +82,22 @@ async function commit(options) {
|
|
|
82
82
|
|
|
83
83
|
// Create commit object
|
|
84
84
|
const commit = {
|
|
85
|
-
|
|
85
|
+
sha: generateCommitHash(),
|
|
86
86
|
message: message,
|
|
87
87
|
author: {
|
|
88
88
|
name: authorName,
|
|
89
89
|
email: authorEmail
|
|
90
90
|
},
|
|
91
91
|
timestamp: new Date().toISOString(),
|
|
92
|
-
parent: repository.branches[repository.currentBranch]
|
|
92
|
+
parent: repository.branches[repository.currentBranch] ? [repository.branches[repository.currentBranch]] : [],
|
|
93
93
|
files: []
|
|
94
94
|
};
|
|
95
95
|
|
|
96
96
|
// Create a map of parent files for quick lookup
|
|
97
97
|
const parentFilesMap = new Map();
|
|
98
|
-
if (commit.parent) {
|
|
99
|
-
const
|
|
98
|
+
if (commit.parent && commit.parent.length > 0) {
|
|
99
|
+
const parentSha = commit.parent[0];
|
|
100
|
+
const parentCommit = repository.commits.find(c => c.sha === parentSha);
|
|
100
101
|
if (parentCommit) {
|
|
101
102
|
parentCommit.files.forEach(f => parentFilesMap.set(f.path, f.hash));
|
|
102
103
|
}
|
|
@@ -140,7 +141,7 @@ async function commit(options) {
|
|
|
140
141
|
// Add commit to repository
|
|
141
142
|
repository.commits = repository.commits || [];
|
|
142
143
|
repository.commits.push(commit);
|
|
143
|
-
repository.branches[repository.currentBranch] = commit.
|
|
144
|
+
repository.branches[repository.currentBranch] = commit.sha;
|
|
144
145
|
|
|
145
146
|
// Save repository and clear staging
|
|
146
147
|
await writeJSON(path.join(gentPath, COMMITS_FILE), repository);
|
|
@@ -150,7 +151,7 @@ async function commit(options) {
|
|
|
150
151
|
spinner.succeed(chalk.green('✓ Changes committed successfully!'));
|
|
151
152
|
|
|
152
153
|
// Display commit info
|
|
153
|
-
console.log(chalk.cyan(`\n[${repository.currentBranch} ${commit.
|
|
154
|
+
console.log(chalk.cyan(`\n[${repository.currentBranch} ${commit.sha.substring(0, 7)}] ${message}`));
|
|
154
155
|
console.log(chalk.gray(`Author: ${commit.author.name} <${commit.author.email}>`));
|
|
155
156
|
console.log(chalk.gray(`Date: ${new Date(commit.timestamp).toLocaleString()}`));
|
|
156
157
|
console.log(chalk.gray(`\n${commit.files.length} file(s) changed`));
|
package/src/commands/log.js
CHANGED
|
@@ -55,10 +55,10 @@ function displayDetailedLog(commits, currentCommitHash, currentBranch) {
|
|
|
55
55
|
console.log(chalk.bold.cyan(`\nCommit History (${currentBranch} branch):\n`));
|
|
56
56
|
|
|
57
57
|
commits.forEach((commit, index) => {
|
|
58
|
-
const isHead = commit.
|
|
58
|
+
const isHead = commit.sha === currentCommitHash;
|
|
59
59
|
const headLabel = isHead ? chalk.yellow.bold(' (HEAD)') : '';
|
|
60
60
|
|
|
61
|
-
console.log(chalk.yellow(`commit ${commit.
|
|
61
|
+
console.log(chalk.yellow(`commit ${commit.sha}`) + headLabel);
|
|
62
62
|
console.log(chalk.white(`Author: ${commit.author.name} <${commit.author.email}>`));
|
|
63
63
|
console.log(chalk.white(`Date: ${new Date(commit.timestamp).toLocaleString()}`));
|
|
64
64
|
console.log(chalk.gray(` (${formatDistanceToNow(new Date(commit.timestamp), { addSuffix: true })})`));
|
|
@@ -79,9 +79,9 @@ function displayDetailedLog(commits, currentCommitHash, currentBranch) {
|
|
|
79
79
|
*/
|
|
80
80
|
function displayOnelineLog(commits, currentCommitHash) {
|
|
81
81
|
commits.forEach(commit => {
|
|
82
|
-
const isHead = commit.
|
|
82
|
+
const isHead = commit.sha === currentCommitHash;
|
|
83
83
|
const headLabel = isHead ? chalk.yellow(' (HEAD)') : '';
|
|
84
|
-
const shortHash = chalk.yellow(commit.
|
|
84
|
+
const shortHash = chalk.yellow(commit.sha.substring(0, 7));
|
|
85
85
|
const message = chalk.white(commit.message);
|
|
86
86
|
const timeAgo = chalk.gray(`(${formatDistanceToNow(new Date(commit.timestamp), { addSuffix: true })})`);
|
|
87
87
|
|
package/src/commands/pull.js
CHANGED
package/src/utils/cloud-sync.js
CHANGED
|
@@ -212,6 +212,12 @@ async function syncCommitsFromCloud(ownerId, repoName, cwd) {
|
|
|
212
212
|
// Download tree
|
|
213
213
|
const tree = await repoService.getTree(ownerId, repoName, commit.tree_sha);
|
|
214
214
|
|
|
215
|
+
// Store entries for local metadata
|
|
216
|
+
commit.files = tree.entries.map(entry => ({
|
|
217
|
+
path: entry.path,
|
|
218
|
+
hash: entry.sha
|
|
219
|
+
}));
|
|
220
|
+
|
|
215
221
|
// Download blobs from tree entries
|
|
216
222
|
const blobShas = tree.entries.map(entry => entry.sha);
|
|
217
223
|
const blobMap = await downloadBlobs(blobShas, ownerId, repoName);
|
package/src/utils/fileSystem.js
CHANGED
|
@@ -170,7 +170,7 @@ async function getTrackedFiles(gentPath, commitHash) {
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
const repository = await readJSON(path.join(gentPath, 'commits.json'));
|
|
173
|
-
const commit = repository.commits.find(c => c.
|
|
173
|
+
const commit = repository.commits.find(c => c.sha === commitHash);
|
|
174
174
|
|
|
175
175
|
return commit ? commit.files : [];
|
|
176
176
|
}
|