Skip to content

Commit 69b0382

Browse files
changes
1 parent b92a17a commit 69b0382

File tree

2 files changed

+17
-39
lines changed

2 files changed

+17
-39
lines changed

src/modules/git.ts

Lines changed: 15 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,34 +19,17 @@ const gitService = {
1919
"gitInitResponse"
2020
);
2121
},
22-
/**
23-
* Clones a Git repository from the given URL to the specified path.
24-
* @param {string} url - The URL of the Git repository to clone.
25-
* @param {string} path - The file system path where the repository should be cloned to.
26-
* @returns {Promise<any>} A promise that resolves with the response from the clone event.
27-
*/
28-
clone: async (url: string, path: string): Promise<any> => {
29-
return cbws.messageManager.sendAndWaitForResponse(
30-
{
31-
"type": "gitEvent",
32-
"action": "Clone",
33-
"url": url,
34-
"path": path
35-
},
36-
"CloneResponse"
37-
);
38-
},
22+
3923
/**
4024
* Pulls the latest changes from the remote repository to the local repository at the given path.
4125
* @param {string} path - The file system path of the local Git repository.
4226
* @returns {Promise<any>} A promise that resolves with the response from the pull event.
4327
*/
44-
pull: async (path: string): Promise<any> => {
28+
pull: async (): Promise<any> => {
4529
return cbws.messageManager.sendAndWaitForResponse(
4630
{
4731
"type": "gitEvent",
48-
"action": "Pull",
49-
"path": path
32+
"action": "Pull"
5033
},
5134
"PullResponse"
5235
);
@@ -56,12 +39,12 @@ const gitService = {
5639
* @param {string} path - The file system path of the local Git repository.
5740
* @returns {Promise<any>} A promise that resolves with the response from the push event.
5841
*/
59-
push: async (path: string): Promise<any> => {
42+
push: async (): Promise<any> => {
6043
return cbws.messageManager.sendAndWaitForResponse(
6144
{
6245
"type": "gitEvent",
6346
"action": "Push",
64-
"path": path
47+
6548
},
6649
"PushResponse"
6750
);
@@ -71,12 +54,11 @@ const gitService = {
7154
* @param {string} path - The file system path of the local Git repository.
7255
* @returns {Promise<any>} A promise that resolves with the response from the status event.
7356
*/
74-
status: async (path: string): Promise<any> => {
57+
status: async (): Promise<any> => {
7558
return cbws.messageManager.sendAndWaitForResponse(
7659
{
7760
"type": "gitEvent",
7861
"action": "Status",
79-
"path": path
8062
},
8163
"gitStatusResponse"
8264
);
@@ -86,12 +68,11 @@ const gitService = {
8668
* @param {string} path - The file system path of the local Git repository.
8769
* @returns {Promise<any>} A promise that resolves with the response from the add event.
8870
*/
89-
add: async (path: string): Promise<any> => {
71+
addAll: async (): Promise<any> => {
9072
return cbws.messageManager.sendAndWaitForResponse(
9173
{
9274
"type": "gitEvent",
9375
"action": "Add",
94-
"path": path
9576
},
9677
"AddResponse"
9778
);
@@ -117,15 +98,14 @@ const gitService = {
11798
* @param {string} branch - The name of the branch or commit to check out.
11899
* @returns {Promise<any>} A promise that resolves with the response from the checkout event.
119100
*/
120-
checkout: async (path: string, branch: string): Promise<any> => {
101+
checkout: async ( branch: string): Promise<any> => {
121102
return cbws.messageManager.sendAndWaitForResponse(
122103
{
123104
"type": "gitEvent",
124105
"action": "Checkout",
125-
"path": path,
126106
"branch": branch
127107
},
128-
"CheckoutResponse"
108+
"gitCheckoutResponse"
129109
);
130110
},
131111
/**
@@ -134,15 +114,14 @@ const gitService = {
134114
* @param {string} branch - The name of the new branch to create.
135115
* @returns {Promise<any>} A promise that resolves with the response from the branch event.
136116
*/
137-
branch: async (path: string, branch: string): Promise<any> => {
117+
branch: async (branch: string): Promise<any> => {
138118
return cbws.messageManager.sendAndWaitForResponse(
139119
{
140120
"type": "gitEvent",
141-
"action": "Branch",
142-
"path": path,
143-
"branch": branch
121+
"action": "gitBranch",
122+
"branch": branch,
144123
},
145-
"BranchResponse"
124+
"gitBranchResponse"
146125
);
147126
},
148127
/**
@@ -154,7 +133,7 @@ const gitService = {
154133
return cbws.messageManager.sendAndWaitForResponse(
155134
{
156135
"type": "gitEvent",
157-
"action": "Logs",
136+
"action": "gitLogs",
158137
"path": path
159138
},
160139
"gitLogsResponse"
@@ -166,12 +145,11 @@ const gitService = {
166145
* @param {string} path - The file system path of the local Git repository.
167146
* @returns {Promise<any>} A promise that resolves with the response from the diff event.
168147
*/
169-
diff: async (commitHash: string, path: string): Promise<any> => {
148+
diff: async (commitHash: string): Promise<any> => {
170149
return cbws.messageManager.sendAndWaitForResponse(
171150
{
172151
"type": "gitEvent",
173152
"action": "Diff",
174-
"path": path,
175153
"commitHash": commitHash
176154
},
177155
"DiffResponse"

testcases/tests/git-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ async function testGitOperations() {
2828
console.log('✅ Git status after file creation:', statusAfterFileResult);
2929

3030
console.log('\n5. Testing git add...');
31-
const addResult = await codebolt.git.add();
31+
const addResult = await codebolt.git.addAll();
3232
console.log('✅ Git add result:', addResult);
3333

3434
console.log('\n6. Testing git status after add...');
@@ -57,7 +57,7 @@ async function testGitOperations() {
5757
console.log('✅ Test file created in branch');
5858

5959
console.log('\n12. Testing git add and commit in new branch...');
60-
await codebolt.git.add();
60+
await codebolt.git.addAll();
6161
const branchCommitResult = await codebolt.git.commit('Add test file in test branch');
6262
console.log('✅ Branch commit result:', branchCommitResult);
6363

0 commit comments

Comments
 (0)