diffstalker 0.2.2 → 0.2.3

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.
@@ -180,6 +180,30 @@ export function unstageHunk(repoPath, patch) {
180
180
  encoding: 'utf-8',
181
181
  });
182
182
  }
183
+ export async function push(repoPath) {
184
+ const git = simpleGit(repoPath);
185
+ const result = await git.push();
186
+ // Build a summary string from the push result
187
+ const pushed = result.pushed;
188
+ if (pushed.length === 0)
189
+ return 'Everything up-to-date';
190
+ return pushed.map((p) => `${p.local} → ${p.remote}`).join(', ');
191
+ }
192
+ export async function fetchRemote(repoPath) {
193
+ const git = simpleGit(repoPath);
194
+ await git.fetch();
195
+ return 'Fetch complete';
196
+ }
197
+ export async function pullRebase(repoPath) {
198
+ const git = simpleGit(repoPath);
199
+ const result = await git.pull(['--rebase']);
200
+ if (result.summary.changes === 0 &&
201
+ result.summary.insertions === 0 &&
202
+ result.summary.deletions === 0) {
203
+ return 'Already up-to-date';
204
+ }
205
+ return `${result.summary.changes} file(s) changed`;
206
+ }
183
207
  export async function getCommitHistory(repoPath, count = 50) {
184
208
  const git = simpleGit(repoPath);
185
209
  try {
@@ -197,3 +221,74 @@ export async function getCommitHistory(repoPath, count = 50) {
197
221
  return [];
198
222
  }
199
223
  }
224
+ export async function getStashList(repoPath) {
225
+ const git = simpleGit(repoPath);
226
+ try {
227
+ const result = await git.stashList();
228
+ return result.all.map((entry, i) => ({
229
+ index: i,
230
+ message: entry.message,
231
+ }));
232
+ }
233
+ catch {
234
+ return [];
235
+ }
236
+ }
237
+ export async function stashSave(repoPath, message) {
238
+ const git = simpleGit(repoPath);
239
+ const args = ['push'];
240
+ if (message)
241
+ args.push('-m', message);
242
+ await git.stash(args);
243
+ return 'Stashed';
244
+ }
245
+ export async function stashPop(repoPath, index = 0) {
246
+ const git = simpleGit(repoPath);
247
+ await git.stash(['pop', `stash@{${index}}`]);
248
+ return 'Stash popped';
249
+ }
250
+ export async function getLocalBranches(repoPath) {
251
+ const git = simpleGit(repoPath);
252
+ const result = await git.branchLocal();
253
+ return result.all.map((name) => ({
254
+ name,
255
+ current: name === result.current,
256
+ tracking: result.branches[name]?.label || undefined,
257
+ }));
258
+ }
259
+ export async function switchBranch(repoPath, name) {
260
+ const git = simpleGit(repoPath);
261
+ await git.checkout(name);
262
+ return `Switched to ${name}`;
263
+ }
264
+ export async function createBranch(repoPath, name) {
265
+ const git = simpleGit(repoPath);
266
+ await git.checkoutLocalBranch(name);
267
+ return `Created ${name}`;
268
+ }
269
+ // Undo operations
270
+ export async function softResetHead(repoPath, count = 1) {
271
+ const git = simpleGit(repoPath);
272
+ await git.reset(['--soft', `HEAD~${count}`]);
273
+ return 'Reset done';
274
+ }
275
+ // History actions
276
+ export async function cherryPick(repoPath, hash) {
277
+ const git = simpleGit(repoPath);
278
+ await git.raw(['cherry-pick', hash]);
279
+ return 'Cherry-picked';
280
+ }
281
+ export async function revertCommit(repoPath, hash) {
282
+ const git = simpleGit(repoPath);
283
+ await git.revert(hash);
284
+ return 'Reverted';
285
+ }
286
+ /**
287
+ * List all files in the repo: tracked files + untracked (not ignored) files.
288
+ * Uses git ls-files which is fast (git already has the index in memory).
289
+ */
290
+ export async function listAllFiles(repoPath) {
291
+ const git = simpleGit(repoPath);
292
+ const result = await git.raw(['ls-files', '-z', '--cached', '--others', '--exclude-standard']);
293
+ return result.split('\0').filter((f) => f.length > 0);
294
+ }