Skip to content

Commit ca88b1b

Browse files
committed
Merge pull request #13 from neel1996/addremote-enhancement
1 parent 6e49689 commit ca88b1b

File tree

4 files changed

+37
-0
lines changed

4 files changed

+37
-0
lines changed

git/gitAddRemoteApi.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const { exec } = require("child_process");
2+
const util = require("util");
3+
const execPromisified = util.promisify(exec);
4+
5+
const fetchRepopath = require("../global/fetchGitRepoPath");
6+
7+
const gitAddRemoteApi = async (repoId, remoteName, remoteUrl) => {
8+
return await execPromisified(`git remote add ${remoteName} ${remoteUrl}`, {
9+
cwd: fetchRepopath.getRepoPath(repoId),
10+
windowsHide: true,
11+
})
12+
.then((res) => {
13+
console.log(res);
14+
return "REMOTE_ADD_SUCCESS";
15+
})
16+
.catch((err) => {
17+
console.log(err);
18+
return "REMOTE_ADD_FAILED";
19+
});
20+
};
21+
22+
module.exports.gitAddRemoteApi = gitAddRemoteApi;

global/globalAPIHandler.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const {
4848
updateDbFileApi,
4949
settingsGetPortDetails,
5050
settingsUpdatePortDetail,
51+
gitAddRemoteRepoApi,
5152
} = require("./globalFunctionStore");
5253

5354
app.use(
@@ -149,6 +150,10 @@ app.use(
149150
const { newPort } = args;
150151
return settingsUpdatePortDetail(newPort);
151152
},
153+
addRemoteRepo: async (args) => {
154+
const { repoId, remoteName, remoteUrl } = args;
155+
return gitAddRemoteRepoApi(repoId, remoteName, remoteUrl);
156+
},
152157
},
153158
})
154159
);

global/globalFunctionStore.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const { gitStageAllItemsApi } = require("../git/gitStageAllItemsAPI");
1212
const { gitCommitChangesApi } = require("../git/gitCommitChangesAPI");
1313
const { gitPushToRemoteApi } = require("../git/gitPushToRemoteAPI");
1414
const { gitStageItem } = require("../git/gitStageItem");
15+
const { gitAddRemoteApi } = require("../git/gitAddRemoteApi");
1516
const {
1617
fetchDatabaseFile,
1718
fetchRepoDetails,
@@ -252,3 +253,11 @@ module.exports.addBranch = addBranch = async (repoId, branchName) => {
252253
module.exports.updateDbFileApi = updateDbFileApi = async (fileName) => {
253254
return await updateDbFile(fileName);
254255
};
256+
257+
module.exports.gitAddRemoteRepoApi = gitAddRemoteRepoApi = async (
258+
repoId,
259+
remoteName,
260+
remoteUrl
261+
) => {
262+
return await gitAddRemoteApi(repoId, remoteName, remoteUrl);
263+
};

global/gqlGlobalAPISchema.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ const globalAPISchema = new buildSchema(
107107
pullFromRemote(repoId: String!): gitPullStatus!
108108
updateRepoDataFile(newDbFile: String!): String!
109109
deleteRepo(repoId: String!): deleteRepoStatus!
110+
addRemoteRepo(repoId: String!, remoteName: String!, remoteUrl: String!): String!
110111
}
111112
112113
type gitFetchStatus{

0 commit comments

Comments
 (0)