mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-10-01 17:29:29 +05:30
feat(git): add diff, branch, checkout, push, pull to Git sidebar panel
Extends GitOperations.js with diff/branches/checkoutBranch/push/pull, wires the 5 new IPC handlers in main.js (reusing the existing dir resolution), whitelists the new channels in preload.js, and fixes the Git sidebar panel's previously dead _gitDiff callback by wiring up a diff view, branch list/create/checkout UI, and push/pull buttons. Resolves Task 5, which deferred this work to this task. Amit Haridas
This commit is contained in:
@@ -41,4 +41,49 @@ async function log(dir, maxCount = 20) {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { getStatus, stage, commit, log };
|
||||
async function diff(dir, file) {
|
||||
try {
|
||||
const git = getGitInstance(dir);
|
||||
return file ? await git.diff([file]) : await git.diff();
|
||||
} catch (err) {
|
||||
return { error: err.message };
|
||||
}
|
||||
}
|
||||
|
||||
async function branches(dir) {
|
||||
try {
|
||||
const git = getGitInstance(dir);
|
||||
return await git.branchLocal();
|
||||
} catch (err) {
|
||||
return { error: err.message };
|
||||
}
|
||||
}
|
||||
|
||||
async function checkoutBranch(dir, name, isNew) {
|
||||
try {
|
||||
const git = getGitInstance(dir);
|
||||
return isNew ? await git.checkoutLocalBranch(name) : await git.checkout(name);
|
||||
} catch (err) {
|
||||
return { error: err.message };
|
||||
}
|
||||
}
|
||||
|
||||
async function push(dir) {
|
||||
try {
|
||||
const git = getGitInstance(dir);
|
||||
return await git.push();
|
||||
} catch (err) {
|
||||
return { error: err.message };
|
||||
}
|
||||
}
|
||||
|
||||
async function pull(dir) {
|
||||
try {
|
||||
const git = getGitInstance(dir);
|
||||
return await git.pull();
|
||||
} catch (err) {
|
||||
return { error: err.message };
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { getStatus, stage, commit, log, diff, branches, checkoutBranch, push, pull };
|
||||
|
||||
Reference in New Issue
Block a user