Skip to content

Commit 5680b54

Browse files
✨ Alpha 4: Added BranchManager with full branch operations and updated command list
1 parent 605480f commit 5680b54

File tree

3 files changed

+430
-131
lines changed

3 files changed

+430
-131
lines changed

src/cli/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ async function showMenu(): Promise<void> {
5353
type: 'list',
5454
name: 'selected',
5555
message: 'Select a Git operation to perform:',
56-
pageSize: 20,
56+
pageSize: 50,
5757
choices: [...choices, new inquirer.Separator(), { name: '❌ Exit', value: 'exit' }],
5858
},
5959
]);

src/config/commandsList.ts

Lines changed: 178 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -17,195 +17,244 @@ export type PlainGitCommand = {
1717
export const COMMANDS_LIST: PlainGitCommand[] = [
1818
// 🏁 Repository Operations
1919
{
20-
category: "Repository",
21-
name: "📦 Initialize a new repository",
22-
command: "git init",
23-
description: "Create a new local Git repository in the current folder.",
24-
handler: "RepositoryManager.initRepo",
20+
category: 'Repository',
21+
name: '📦 Initialize a new repository',
22+
command: 'git init',
23+
description: 'Create a new local Git repository in the current folder.',
24+
handler: 'RepositoryManager.initRepo',
2525
},
2626
{
27-
category: "Repository",
28-
name: "📦 Initialize a bare repository",
29-
command: "git init --bare",
30-
description: "Create a bare Git repository (no working directory).",
31-
handler: "RepositoryManager.initRepo",
27+
category: 'Repository',
28+
name: '📦 Initialize a bare repository',
29+
command: 'git init --bare',
30+
description: 'Create a bare Git repository (no working directory).',
31+
handler: 'RepositoryManager.initRepo',
3232
},
3333
{
34-
category: "Repository",
35-
name: "🌐 Clone a repository from URL",
36-
command: "git clone <url> [folder]",
37-
description: "Clone an existing repository from a remote Git URL.",
38-
handler: "RepositoryManager.cloneRepo",
34+
category: 'Repository',
35+
name: '🌐 Clone a repository from URL',
36+
command: 'git clone <url> [folder]',
37+
description: 'Clone an existing repository from a remote Git URL.',
38+
handler: 'RepositoryManager.cloneRepo',
3939
},
4040
{
41-
category: "Repository",
42-
name: "📂 Check repository status",
43-
command: "git status [-s]",
44-
description: "Display the current working tree status (short or detailed).",
45-
handler: "RepositoryManager.status",
41+
category: 'Repository',
42+
name: '📂 Check repository status',
43+
command: 'git status [-s]',
44+
description: 'Display the current working tree status (short or detailed).',
45+
handler: 'RepositoryManager.status',
4646
},
4747
{
48-
category: "Repository",
49-
name: "⚙️ Show Git configuration",
50-
command: "git config --list [--global | --local | --system]",
51-
description: "Show Git configuration for the selected scope.",
52-
handler: "RepositoryManager.showConfig",
48+
category: 'Repository',
49+
name: '⚙️ Show Git configuration',
50+
command: 'git config --list [--global | --local | --system]',
51+
description: 'Show Git configuration for the selected scope.',
52+
handler: 'RepositoryManager.showConfig',
5353
},
5454
{
55-
category: "Repository",
56-
name: "🧩 Set Git configuration value",
57-
command: "git config [--global] <key> <value>",
58-
description: "Set or update a Git configuration key/value pair.",
59-
handler: "RepositoryManager.setConfig",
55+
category: 'Repository',
56+
name: '🧩 Set Git configuration value',
57+
command: 'git config [--global] <key> <value>',
58+
description: 'Set or update a Git configuration key/value pair.',
59+
handler: 'RepositoryManager.setConfig',
6060
},
6161
{
62-
category: "Repository",
63-
name: "🔗 List remotes",
64-
command: "git remote -v",
65-
description: "List all configured remote repositories.",
66-
handler: "RepositoryManager.listRemotes",
62+
category: 'Repository',
63+
name: '🔗 List remotes',
64+
command: 'git remote -v',
65+
description: 'List all configured remote repositories.',
66+
handler: 'RepositoryManager.listRemotes',
6767
},
6868
{
69-
category: "Repository",
70-
name: "➕ Add a new remote",
71-
command: "git remote add <name> <url>",
72-
description: "Add a new remote repository by name and URL.",
73-
handler: "RepositoryManager.addRemote",
69+
category: 'Repository',
70+
name: '➕ Add a new remote',
71+
command: 'git remote add <name> <url>',
72+
description: 'Add a new remote repository by name and URL.',
73+
handler: 'RepositoryManager.addRemote',
7474
},
7575
{
76-
category: "Repository",
77-
name: "✏️ Update existing remote URL",
78-
command: "git remote set-url <name> <new-url>",
79-
description: "Change the URL for an existing remote repository.",
80-
handler: "RepositoryManager.updateRemote",
76+
category: 'Repository',
77+
name: '✏️ Update existing remote URL',
78+
command: 'git remote set-url <name> <new-url>',
79+
description: 'Change the URL for an existing remote repository.',
80+
handler: 'RepositoryManager.updateRemote',
8181
},
8282
{
83-
category: "Repository",
84-
name: "🗑️ Remove a remote",
85-
command: "git remote remove <name>",
86-
description: "Remove a remote repository from configuration.",
87-
handler: "RepositoryManager.removeRemote",
83+
category: 'Repository',
84+
name: '🗑️ Remove a remote',
85+
command: 'git remote remove <name>',
86+
description: 'Remove a remote repository from configuration.',
87+
handler: 'RepositoryManager.removeRemote',
8888
},
8989
{
90-
category: "Repository",
91-
name: "🔍 Show repository info (HEAD + Root)",
92-
command: "git rev-parse --show-toplevel && git rev-parse --abbrev-ref HEAD",
93-
description: "Show repository root directory and current branch info.",
94-
handler: "RepositoryManager.showRepoInfo",
90+
category: 'Repository',
91+
name: '🔍 Show repository info (HEAD + Root)',
92+
command: 'git rev-parse --show-toplevel && git rev-parse --abbrev-ref HEAD',
93+
description: 'Show repository root directory and current branch info.',
94+
handler: 'RepositoryManager.showRepoInfo',
9595
},
9696
{
97-
category: "Repository",
98-
name: "🧹 Optimize repository (cleanup & GC)",
99-
command: "git gc --prune=now --aggressive",
100-
description: "Run Git garbage collection to optimize repository size.",
101-
handler: "RepositoryManager.optimizeRepo",
97+
category: 'Repository',
98+
name: '🧹 Optimize repository (cleanup & GC)',
99+
command: 'git gc --prune=now --aggressive',
100+
description: 'Run Git garbage collection to optimize repository size.',
101+
handler: 'RepositoryManager.optimizeRepo',
102102
},
103103
{
104-
category: "Repository",
105-
name: "🔎 Verify repository integrity",
106-
command: "git fsck --full",
107-
description: "Check repository for corrupted or missing objects.",
108-
handler: "RepositoryManager.verifyRepo",
104+
category: 'Repository',
105+
name: '🔎 Verify repository integrity',
106+
command: 'git fsck --full',
107+
description: 'Check repository for corrupted or missing objects.',
108+
handler: 'RepositoryManager.verifyRepo',
109109
},
110110

111111
// 🌿 Branch Operations
112112
{
113-
category: "Branch",
114-
name: "🌱 Create a new branch",
115-
command: "git branch <branch-name>",
116-
description: "Create a new branch locally.",
117-
handler: "BranchManager.createBranch",
113+
category: 'Branch',
114+
name: '🌱 Create a new branch',
115+
command: 'git branch <branch-name>',
116+
description: 'Create a new branch locally (does not switch).',
117+
handler: 'BranchManager.createBranch',
118118
},
119119
{
120-
category: "Branch",
121-
name: "🔄 Switch to another branch",
122-
command: "git checkout <branch-name>",
123-
description: "Switch to an existing branch.",
124-
handler: "BranchManager.switchBranch",
120+
category: 'Branch',
121+
name: '🌿 Create and switch to a new branch',
122+
command: 'git switch -c <branch-name> | git checkout -b <branch-name>',
123+
description: 'Create a new branch and immediately switch to it.',
124+
handler: 'BranchManager.createAndSwitch',
125125
},
126126
{
127-
category: "Branch",
128-
name: "🗑️ Delete a branch",
129-
command: "git branch -d <branch-name>",
130-
description: "Delete a local branch safely.",
131-
handler: "BranchManager.deleteBranch",
127+
category: 'Branch',
128+
name: '🔄 Switch to another branch',
129+
command: 'git switch <branch-name> | git checkout <branch-name>',
130+
description: 'Switch to an existing branch interactively.',
131+
handler: 'BranchManager.switchBranch',
132+
},
133+
{
134+
category: 'Branch',
135+
name: '🗑️ Delete a branch (safe delete)',
136+
command: 'git branch -d <branch-name>',
137+
description: 'Delete a local branch that has already been merged.',
138+
handler: 'BranchManager.deleteBranch',
139+
},
140+
{
141+
category: 'Branch',
142+
name: '💣 Force delete a branch',
143+
command: 'git branch -D <branch-name>',
144+
description: 'Force delete a local branch (even if unmerged).',
145+
handler: 'BranchManager.deleteBranch',
146+
},
147+
{
148+
category: 'Branch',
149+
name: '✏️ Rename a branch',
150+
command: 'git branch -m <old-name> <new-name>',
151+
description: 'Rename an existing local branch.',
152+
handler: 'BranchManager.renameBranch',
153+
},
154+
{
155+
category: 'Branch',
156+
name: '📋 List all branches',
157+
command: 'git branch --all --verbose',
158+
description: 'List all local and remote branches with details.',
159+
handler: 'BranchManager.listBranches',
160+
},
161+
{
162+
category: 'Branch',
163+
name: '📍 Show current branch',
164+
command: 'git branch --show-current',
165+
description: 'Display the name of the branch you are currently on.',
166+
handler: 'BranchManager.showCurrentBranch',
167+
},
168+
{
169+
category: 'Branch',
170+
name: '🚀 Push branch to remote and set upstream',
171+
command: 'git push -u <remote> <branch>',
172+
description: 'Push a branch to a remote repository and set upstream tracking.',
173+
handler: 'BranchManager.pushBranch',
174+
},
175+
{
176+
category: 'Branch',
177+
name: '📍 Show and list all branches (summary)',
178+
command: 'git branch --show-current && git branch --all',
179+
description: 'Display the current branch and a list of all branches.',
180+
handler: 'BranchManager.showAndList',
132181
},
133182

134183
// 📝 Commit Operations
135184
{
136-
category: "Commit",
137-
name: "🧩 Stage all changes",
138-
command: "git add .",
139-
description: "Add all modified files to staging.",
140-
handler: "CommitManager.stageAll",
185+
category: 'Commit',
186+
name: '🧩 Stage all changes',
187+
command: 'git add .',
188+
description: 'Add all modified files to staging.',
189+
handler: 'CommitManager.stageAll',
141190
},
142191
{
143-
category: "Commit",
144-
name: "📝 Commit all staged changes",
192+
category: 'Commit',
193+
name: '📝 Commit all staged changes',
145194
command: "git commit -m '<message>'",
146-
description: "Commit staged changes with a message.",
147-
handler: "CommitManager.commitChanges",
195+
description: 'Commit staged changes with a message.',
196+
handler: 'CommitManager.commitChanges',
148197
},
149198
{
150-
category: "Commit",
151-
name: "📜 Show commit history",
152-
command: "git log --oneline",
153-
description: "Show a compact list of previous commits.",
154-
handler: "CommitManager.showLog",
199+
category: 'Commit',
200+
name: '📜 Show commit history',
201+
command: 'git log --oneline',
202+
description: 'Show a compact list of previous commits.',
203+
handler: 'CommitManager.showLog',
155204
},
156205

157206
// 🚀 Remote Operations
158207
{
159-
category: "Remote",
160-
name: "🚀 Push changes to remote",
161-
command: "git push",
162-
description: "Push local commits to the default remote branch.",
163-
handler: "RemoteManager.pushChanges",
208+
category: 'Remote',
209+
name: '🚀 Push changes to remote',
210+
command: 'git push',
211+
description: 'Push local commits to the default remote branch.',
212+
handler: 'RemoteManager.pushChanges',
164213
},
165214
{
166-
category: "Remote",
167-
name: "⬇️ Pull latest changes",
168-
command: "git pull",
169-
description: "Pull changes from the remote branch into your local branch.",
170-
handler: "RemoteManager.pullChanges",
215+
category: 'Remote',
216+
name: '⬇️ Pull latest changes',
217+
command: 'git pull',
218+
description: 'Pull changes from the remote branch into your local branch.',
219+
handler: 'RemoteManager.pullChanges',
171220
},
172221
{
173-
category: "Remote",
174-
name: "🔍 Fetch updates from remote",
175-
command: "git fetch",
176-
description: "Fetch remote changes without merging them.",
177-
handler: "RemoteManager.fetchUpdates",
222+
category: 'Remote',
223+
name: '🔍 Fetch updates from remote',
224+
command: 'git fetch',
225+
description: 'Fetch remote changes without merging them.',
226+
handler: 'RemoteManager.fetchUpdates',
178227
},
179228

180229
// 🕓 History & Diff
181230
{
182-
category: "History",
183-
name: "🕓 View commit history (graph)",
184-
command: "git log --oneline --graph --decorate",
185-
description: "Show commits with visual branch structure.",
186-
handler: "HistoryManager.showHistoryGraph",
231+
category: 'History',
232+
name: '🕓 View commit history (graph)',
233+
command: 'git log --oneline --graph --decorate',
234+
description: 'Show commits with visual branch structure.',
235+
handler: 'HistoryManager.showHistoryGraph',
187236
},
188237
{
189-
category: "History",
190-
name: "🔍 Compare changes (diff)",
191-
command: "git diff",
192-
description: "Compare working directory with last commit.",
193-
handler: "HistoryManager.showDiff",
238+
category: 'History',
239+
name: '🔍 Compare changes (diff)',
240+
command: 'git diff',
241+
description: 'Compare working directory with last commit.',
242+
handler: 'HistoryManager.showDiff',
194243
},
195244

196245
// 🧹 Reset & Cleanup
197246
{
198-
category: "Reset",
199-
name: "↩️ Undo last commit (soft)",
200-
command: "git reset --soft HEAD~1",
201-
description: "Undo last commit but keep changes staged.",
202-
handler: "ResetManager.undoLastCommit",
247+
category: 'Reset',
248+
name: '↩️ Undo last commit (soft)',
249+
command: 'git reset --soft HEAD~1',
250+
description: 'Undo last commit but keep changes staged.',
251+
handler: 'ResetManager.undoLastCommit',
203252
},
204253
{
205-
category: "Reset",
206-
name: "🧹 Clean untracked files",
207-
command: "git clean -fd",
208-
description: "Remove all untracked files and folders.",
209-
handler: "ResetManager.cleanUntracked",
254+
category: 'Reset',
255+
name: '🧹 Clean untracked files',
256+
command: 'git clean -fd',
257+
description: 'Remove all untracked files and folders.',
258+
handler: 'ResetManager.cleanUntracked',
210259
},
211260
];

0 commit comments

Comments
 (0)