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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gent-cli",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "A modern, Git-like version control CLI with built-in cloud authentication and global user identity management.",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -82,21 +82,22 @@ async function commit(options) {
82
82
 
83
83
  // Create commit object
84
84
  const commit = {
85
- hash: generateCommitHash(),
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] || null,
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 parentCommit = repository.commits.find(c => c.hash === commit.parent);
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.hash;
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.hash.substring(0, 7)}] ${message}`));
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`));
@@ -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.hash === currentCommitHash;
58
+ const isHead = commit.sha === currentCommitHash;
59
59
  const headLabel = isHead ? chalk.yellow.bold(' (HEAD)') : '';
60
60
 
61
- console.log(chalk.yellow(`commit ${commit.hash}`) + headLabel);
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.hash === currentCommitHash;
82
+ const isHead = commit.sha === currentCommitHash;
83
83
  const headLabel = isHead ? chalk.yellow(' (HEAD)') : '';
84
- const shortHash = chalk.yellow(commit.hash.substring(0, 7));
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
 
@@ -92,7 +92,7 @@ async function pull(remoteName, branchName, options) {
92
92
  },
93
93
  timestamp: cloudCommit.committed_at,
94
94
  parent: cloudCommit.parent_shas || [],
95
- files: {} // Files are stored in objects directory
95
+ files: cloudCommit.files || []
96
96
  });
97
97
  }
98
98
  }
@@ -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);
@@ -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.hash === commitHash);
173
+ const commit = repository.commits.find(c => c.sha === commitHash);
174
174
 
175
175
  return commit ? commit.files : [];
176
176
  }