@myrialabs/clopen 0.4.4 → 0.4.5
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.
- package/backend/auth/permissions.ts +1 -0
- package/backend/engine/adapters/codex/credential.ts +6 -0
- package/backend/git/git-service.ts +40 -0
- package/backend/mcp/external/parse.test.ts +190 -0
- package/backend/mcp/external/parse.ts +293 -0
- package/backend/mcp/index.ts +2 -0
- package/backend/snapshot/gitignore.ts +230 -7
- package/backend/snapshot/helpers.ts +34 -10
- package/backend/ws/files/read.ts +10 -1
- package/backend/ws/git/branch-name.ts +20 -4
- package/backend/ws/git/branch.ts +66 -11
- package/backend/ws/git/commit-message.ts +18 -3
- package/backend/ws/git/commit.ts +50 -16
- package/backend/ws/git/conflict.ts +47 -5
- package/backend/ws/git/diff.ts +38 -4
- package/backend/ws/git/log.ts +22 -2
- package/backend/ws/git/remote.ts +82 -33
- package/backend/ws/git/staging.ts +39 -9
- package/backend/ws/git/status.ts +52 -0
- package/backend/ws/mcp/crud.ts +30 -1
- package/backend/ws/snapshot/timeline.ts +1 -1
- package/dist/assets/main-gNUEJAC5.css +1 -0
- package/dist/assets/{main-AqTMkV9D.js → main-zXKH_C5O.js} +317 -295
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/shared/types/git.ts +20 -0
- package/dist/assets/main-DJf71Zum.css +0 -1
package/backend/ws/git/commit.ts
CHANGED
|
@@ -3,55 +3,80 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { t } from 'elysia';
|
|
6
|
+
import path from 'node:path';
|
|
6
7
|
import { createRouter } from '$shared/utils/ws-server';
|
|
7
8
|
import { gitService } from '../../git/git-service';
|
|
8
9
|
import { requireProjectAccess } from '../access';
|
|
10
|
+
import { debug } from '$shared/utils/logger';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Resolve the working directory for a git operation. Defaults to the project
|
|
14
|
+
* root; when `repoPath` is provided it must already be inside the project.
|
|
15
|
+
*/
|
|
16
|
+
function resolveRepoCwd(projectPath: string, repoPath: string | undefined): string {
|
|
17
|
+
if (!repoPath) return projectPath;
|
|
18
|
+
const resolved = path.resolve(repoPath);
|
|
19
|
+
const projectRoot = path.resolve(projectPath);
|
|
20
|
+
const sep = path.sep;
|
|
21
|
+
if (resolved !== projectRoot && !resolved.startsWith(projectRoot + sep)) {
|
|
22
|
+
debug.warn('git', `Rejected nested repoPath outside project: ${resolved}`);
|
|
23
|
+
return projectPath;
|
|
24
|
+
}
|
|
25
|
+
return resolved;
|
|
26
|
+
}
|
|
9
27
|
|
|
10
28
|
export const commitHandler = createRouter()
|
|
11
29
|
.http('git:commit', {
|
|
12
30
|
data: t.Object({
|
|
13
31
|
projectId: t.String(),
|
|
14
|
-
message: t.String({ minLength: 1 })
|
|
32
|
+
message: t.String({ minLength: 1 }),
|
|
33
|
+
repoPath: t.Optional(t.String())
|
|
15
34
|
}),
|
|
16
35
|
response: t.Object({
|
|
17
36
|
hash: t.String()
|
|
18
37
|
})
|
|
19
38
|
}, async ({ data, conn }) => {
|
|
20
39
|
const project = requireProjectAccess(conn, data.projectId);
|
|
21
|
-
const
|
|
40
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
41
|
+
const hash = await gitService.commit(cwd, data.message);
|
|
22
42
|
return { hash };
|
|
23
43
|
})
|
|
24
44
|
|
|
25
45
|
.http('git:amend', {
|
|
26
46
|
data: t.Object({
|
|
27
47
|
projectId: t.String(),
|
|
28
|
-
message: t.Optional(t.String())
|
|
48
|
+
message: t.Optional(t.String()),
|
|
49
|
+
repoPath: t.Optional(t.String())
|
|
29
50
|
}),
|
|
30
51
|
response: t.Object({
|
|
31
52
|
hash: t.String()
|
|
32
53
|
})
|
|
33
54
|
}, async ({ data, conn }) => {
|
|
34
55
|
const project = requireProjectAccess(conn, data.projectId);
|
|
35
|
-
const
|
|
56
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
57
|
+
const hash = await gitService.amendCommit(cwd, data.message);
|
|
36
58
|
return { hash };
|
|
37
59
|
})
|
|
38
60
|
|
|
39
61
|
.http('git:undo-commit', {
|
|
40
62
|
data: t.Object({
|
|
41
63
|
projectId: t.String(),
|
|
42
|
-
mode: t.Union([t.Literal('soft'), t.Literal('mixed'), t.Literal('hard')])
|
|
64
|
+
mode: t.Union([t.Literal('soft'), t.Literal('mixed'), t.Literal('hard')]),
|
|
65
|
+
repoPath: t.Optional(t.String())
|
|
43
66
|
}),
|
|
44
67
|
response: t.Object({ ok: t.Boolean() })
|
|
45
68
|
}, async ({ data, conn }) => {
|
|
46
69
|
const project = requireProjectAccess(conn, data.projectId);
|
|
47
|
-
|
|
70
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
71
|
+
await gitService.undoLastCommit(cwd, data.mode);
|
|
48
72
|
return { ok: true };
|
|
49
73
|
})
|
|
50
74
|
|
|
51
75
|
.http('git:revert', {
|
|
52
76
|
data: t.Object({
|
|
53
77
|
projectId: t.String(),
|
|
54
|
-
ref: t.Optional(t.String())
|
|
78
|
+
ref: t.Optional(t.String()),
|
|
79
|
+
repoPath: t.Optional(t.String())
|
|
55
80
|
}),
|
|
56
81
|
response: t.Object({
|
|
57
82
|
success: t.Boolean(),
|
|
@@ -59,13 +84,15 @@ export const commitHandler = createRouter()
|
|
|
59
84
|
})
|
|
60
85
|
}, async ({ data, conn }) => {
|
|
61
86
|
const project = requireProjectAccess(conn, data.projectId);
|
|
62
|
-
|
|
87
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
88
|
+
return await gitService.revertCommit(cwd, data.ref);
|
|
63
89
|
})
|
|
64
90
|
|
|
65
91
|
.http('git:cherry-pick', {
|
|
66
92
|
data: t.Object({
|
|
67
93
|
projectId: t.String(),
|
|
68
|
-
hashes: t.Array(t.String(), { minItems: 1 })
|
|
94
|
+
hashes: t.Array(t.String(), { minItems: 1 }),
|
|
95
|
+
repoPath: t.Optional(t.String())
|
|
69
96
|
}),
|
|
70
97
|
response: t.Object({
|
|
71
98
|
success: t.Boolean(),
|
|
@@ -73,35 +100,41 @@ export const commitHandler = createRouter()
|
|
|
73
100
|
})
|
|
74
101
|
}, async ({ data, conn }) => {
|
|
75
102
|
const project = requireProjectAccess(conn, data.projectId);
|
|
76
|
-
|
|
103
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
104
|
+
return await gitService.cherryPick(cwd, data.hashes);
|
|
77
105
|
})
|
|
78
106
|
|
|
79
107
|
.http('git:clean', {
|
|
80
108
|
data: t.Object({
|
|
81
|
-
projectId: t.String()
|
|
109
|
+
projectId: t.String(),
|
|
110
|
+
repoPath: t.Optional(t.String())
|
|
82
111
|
}),
|
|
83
112
|
response: t.Object({ message: t.String() })
|
|
84
113
|
}, async ({ data, conn }) => {
|
|
85
114
|
const project = requireProjectAccess(conn, data.projectId);
|
|
86
|
-
const
|
|
115
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
116
|
+
const message = await gitService.cleanUntracked(cwd);
|
|
87
117
|
return { message };
|
|
88
118
|
})
|
|
89
119
|
|
|
90
120
|
.http('git:gc', {
|
|
91
121
|
data: t.Object({
|
|
92
|
-
projectId: t.String()
|
|
122
|
+
projectId: t.String(),
|
|
123
|
+
repoPath: t.Optional(t.String())
|
|
93
124
|
}),
|
|
94
125
|
response: t.Object({ message: t.String() })
|
|
95
126
|
}, async ({ data, conn }) => {
|
|
96
127
|
const project = requireProjectAccess(conn, data.projectId);
|
|
97
|
-
const
|
|
128
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
129
|
+
const message = await gitService.optimize(cwd);
|
|
98
130
|
return { message };
|
|
99
131
|
})
|
|
100
132
|
|
|
101
133
|
.http('git:npm-version', {
|
|
102
134
|
data: t.Object({
|
|
103
135
|
projectId: t.String(),
|
|
104
|
-
bump: t.Union([t.Literal('patch'), t.Literal('minor'), t.Literal('major')])
|
|
136
|
+
bump: t.Union([t.Literal('patch'), t.Literal('minor'), t.Literal('major')]),
|
|
137
|
+
repoPath: t.Optional(t.String())
|
|
105
138
|
}),
|
|
106
139
|
response: t.Object({
|
|
107
140
|
success: t.Boolean(),
|
|
@@ -110,5 +143,6 @@ export const commitHandler = createRouter()
|
|
|
110
143
|
})
|
|
111
144
|
}, async ({ data, conn }) => {
|
|
112
145
|
const project = requireProjectAccess(conn, data.projectId);
|
|
113
|
-
|
|
146
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
147
|
+
return await gitService.npmVersion(cwd, data.bump);
|
|
114
148
|
});
|
|
@@ -3,9 +3,24 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { t } from 'elysia';
|
|
6
|
+
import path from 'node:path';
|
|
6
7
|
import { createRouter } from '$shared/utils/ws-server';
|
|
7
8
|
import { gitService } from '../../git/git-service';
|
|
9
|
+
import { findNestedRepoPaths, findRepoForFile } from '../../snapshot/gitignore';
|
|
8
10
|
import { requireProjectAccess } from '../access';
|
|
11
|
+
import { debug } from '$shared/utils/logger';
|
|
12
|
+
|
|
13
|
+
function resolveRepoCwd(projectPath: string, repoPath: string | undefined): string | null {
|
|
14
|
+
if (!repoPath) return null;
|
|
15
|
+
const resolved = path.resolve(repoPath);
|
|
16
|
+
const projectRoot = path.resolve(projectPath);
|
|
17
|
+
const sep = path.sep;
|
|
18
|
+
if (resolved !== projectRoot && !resolved.startsWith(projectRoot + sep)) {
|
|
19
|
+
debug.warn('git', `Rejected nested repoPath outside project: ${resolved}`);
|
|
20
|
+
return projectRoot;
|
|
21
|
+
}
|
|
22
|
+
return resolved;
|
|
23
|
+
}
|
|
9
24
|
|
|
10
25
|
const ConflictMarkerSchema = t.Object({
|
|
11
26
|
ourStart: t.Number(),
|
|
@@ -31,7 +46,29 @@ export const conflictHandler = createRouter()
|
|
|
31
46
|
}))
|
|
32
47
|
}, async ({ data, conn }) => {
|
|
33
48
|
const project = requireProjectAccess(conn, data.projectId);
|
|
34
|
-
|
|
49
|
+
const conflicts = await gitService.getConflictFiles(project.path);
|
|
50
|
+
|
|
51
|
+
try {
|
|
52
|
+
const nestedRepoPaths = await findNestedRepoPaths(project.path);
|
|
53
|
+
for (const repoPath of nestedRepoPaths) {
|
|
54
|
+
try {
|
|
55
|
+
const nestedConflicts = await gitService.getConflictFiles(repoPath);
|
|
56
|
+
const prefix = path.relative(project.path, repoPath).replace(/\\/g, '/') + '/';
|
|
57
|
+
for (const conflict of nestedConflicts) {
|
|
58
|
+
conflicts.push({
|
|
59
|
+
...conflict,
|
|
60
|
+
path: prefix + conflict.path
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
} catch {
|
|
64
|
+
// Skip nested repos whose conflict status fails
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
} catch {
|
|
68
|
+
// Skip finding nested repos if it fails
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return conflicts;
|
|
35
72
|
})
|
|
36
73
|
|
|
37
74
|
.http('git:resolve-conflict', {
|
|
@@ -44,9 +81,12 @@ export const conflictHandler = createRouter()
|
|
|
44
81
|
response: t.Object({ ok: t.Boolean() })
|
|
45
82
|
}, async ({ data, conn }) => {
|
|
46
83
|
const project = requireProjectAccess(conn, data.projectId);
|
|
84
|
+
const repo = await findRepoForFile(project.path, data.filePath);
|
|
85
|
+
const cwd = repo?.repoPath ?? project.path;
|
|
86
|
+
const filePath = repo?.relativeFilePath ?? data.filePath;
|
|
47
87
|
await gitService.resolveConflict(
|
|
48
|
-
|
|
49
|
-
|
|
88
|
+
cwd,
|
|
89
|
+
filePath,
|
|
50
90
|
data.resolution,
|
|
51
91
|
data.customContent
|
|
52
92
|
);
|
|
@@ -55,11 +95,13 @@ export const conflictHandler = createRouter()
|
|
|
55
95
|
|
|
56
96
|
.http('git:abort-merge', {
|
|
57
97
|
data: t.Object({
|
|
58
|
-
projectId: t.String()
|
|
98
|
+
projectId: t.String(),
|
|
99
|
+
repoPath: t.Optional(t.String())
|
|
59
100
|
}),
|
|
60
101
|
response: t.Object({ ok: t.Boolean() })
|
|
61
102
|
}, async ({ data, conn }) => {
|
|
62
103
|
const project = requireProjectAccess(conn, data.projectId);
|
|
63
|
-
|
|
104
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath) ?? project.path;
|
|
105
|
+
await gitService.abortMerge(cwd);
|
|
64
106
|
return { ok: true };
|
|
65
107
|
});
|
package/backend/ws/git/diff.ts
CHANGED
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { t } from 'elysia';
|
|
6
|
+
import path from 'node:path';
|
|
6
7
|
import { createRouter } from '$shared/utils/ws-server';
|
|
7
8
|
import { gitService } from '../../git/git-service';
|
|
9
|
+
import { findRepoForFile } from '../../snapshot/gitignore';
|
|
8
10
|
import { requireProjectAccess } from '../access';
|
|
11
|
+
import { debug } from '$shared/utils/logger';
|
|
9
12
|
|
|
10
13
|
const DiffHunkLineSchema = t.Object({
|
|
11
14
|
type: t.Union([t.Literal('add'), t.Literal('delete'), t.Literal('context'), t.Literal('header')]),
|
|
@@ -31,6 +34,22 @@ const FileDiffSchema = t.Object({
|
|
|
31
34
|
isBinary: t.Boolean()
|
|
32
35
|
});
|
|
33
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Resolve the working directory for a git operation. Defaults to the project
|
|
39
|
+
* root; when `repoPath` is provided it must already be inside the project.
|
|
40
|
+
*/
|
|
41
|
+
function resolveRepoCwd(projectPath: string, repoPath: string | undefined): string {
|
|
42
|
+
if (!repoPath) return projectPath;
|
|
43
|
+
const resolved = path.resolve(repoPath);
|
|
44
|
+
const projectRoot = path.resolve(projectPath);
|
|
45
|
+
const sep = path.sep;
|
|
46
|
+
if (resolved !== projectRoot && !resolved.startsWith(projectRoot + sep)) {
|
|
47
|
+
debug.warn('git', `Rejected nested repoPath outside project: ${resolved}`);
|
|
48
|
+
return projectPath;
|
|
49
|
+
}
|
|
50
|
+
return resolved;
|
|
51
|
+
}
|
|
52
|
+
|
|
34
53
|
export const diffHandler = createRouter()
|
|
35
54
|
.http('git:diff-unstaged', {
|
|
36
55
|
data: t.Object({
|
|
@@ -40,7 +59,15 @@ export const diffHandler = createRouter()
|
|
|
40
59
|
response: t.Array(FileDiffSchema)
|
|
41
60
|
}, async ({ data, conn }) => {
|
|
42
61
|
const project = requireProjectAccess(conn, data.projectId);
|
|
43
|
-
|
|
62
|
+
// Route the diff to the nested repo that owns the file (if any) —
|
|
63
|
+
// the outer repo's `git diff` returns nothing for files that are
|
|
64
|
+
// tracked inside a nested repo and gitignored by the parent.
|
|
65
|
+
const repo = data.filePath
|
|
66
|
+
? await findRepoForFile(project.path, data.filePath)
|
|
67
|
+
: null;
|
|
68
|
+
const cwd = repo?.repoPath ?? project.path;
|
|
69
|
+
const filePath = repo?.relativeFilePath ?? data.filePath;
|
|
70
|
+
return await gitService.getDiffUnstaged(cwd, filePath);
|
|
44
71
|
})
|
|
45
72
|
|
|
46
73
|
.http('git:diff-staged', {
|
|
@@ -51,16 +78,23 @@ export const diffHandler = createRouter()
|
|
|
51
78
|
response: t.Array(FileDiffSchema)
|
|
52
79
|
}, async ({ data, conn }) => {
|
|
53
80
|
const project = requireProjectAccess(conn, data.projectId);
|
|
54
|
-
|
|
81
|
+
const repo = data.filePath
|
|
82
|
+
? await findRepoForFile(project.path, data.filePath)
|
|
83
|
+
: null;
|
|
84
|
+
const cwd = repo?.repoPath ?? project.path;
|
|
85
|
+
const filePath = repo?.relativeFilePath ?? data.filePath;
|
|
86
|
+
return await gitService.getDiffStaged(cwd, filePath);
|
|
55
87
|
})
|
|
56
88
|
|
|
57
89
|
.http('git:diff-commit', {
|
|
58
90
|
data: t.Object({
|
|
59
91
|
projectId: t.String(),
|
|
60
|
-
commitHash: t.String()
|
|
92
|
+
commitHash: t.String(),
|
|
93
|
+
repoPath: t.Optional(t.String())
|
|
61
94
|
}),
|
|
62
95
|
response: t.Array(FileDiffSchema)
|
|
63
96
|
}, async ({ data, conn }) => {
|
|
64
97
|
const project = requireProjectAccess(conn, data.projectId);
|
|
65
|
-
|
|
98
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
99
|
+
return await gitService.getDiffCommit(cwd, data.commitHash);
|
|
66
100
|
});
|
package/backend/ws/git/log.ts
CHANGED
|
@@ -3,9 +3,27 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { t } from 'elysia';
|
|
6
|
+
import path from 'node:path';
|
|
6
7
|
import { createRouter } from '$shared/utils/ws-server';
|
|
7
8
|
import { gitService } from '../../git/git-service';
|
|
8
9
|
import { requireProjectAccess } from '../access';
|
|
10
|
+
import { debug } from '$shared/utils/logger';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Resolve the working directory for a git operation. Defaults to the project
|
|
14
|
+
* root; when `repoPath` is provided it must already be inside the project.
|
|
15
|
+
*/
|
|
16
|
+
function resolveRepoCwd(projectPath: string, repoPath: string | undefined): string {
|
|
17
|
+
if (!repoPath) return projectPath;
|
|
18
|
+
const resolved = path.resolve(repoPath);
|
|
19
|
+
const projectRoot = path.resolve(projectPath);
|
|
20
|
+
const sep = path.sep;
|
|
21
|
+
if (resolved !== projectRoot && !resolved.startsWith(projectRoot + sep)) {
|
|
22
|
+
debug.warn('git', `Rejected nested repoPath outside project: ${resolved}`);
|
|
23
|
+
return projectPath;
|
|
24
|
+
}
|
|
25
|
+
return resolved;
|
|
26
|
+
}
|
|
9
27
|
|
|
10
28
|
export const logHandler = createRouter()
|
|
11
29
|
.http('git:log', {
|
|
@@ -13,7 +31,8 @@ export const logHandler = createRouter()
|
|
|
13
31
|
projectId: t.String(),
|
|
14
32
|
limit: t.Optional(t.Number()),
|
|
15
33
|
skip: t.Optional(t.Number()),
|
|
16
|
-
branch: t.Optional(t.String())
|
|
34
|
+
branch: t.Optional(t.String()),
|
|
35
|
+
repoPath: t.Optional(t.String())
|
|
17
36
|
}),
|
|
18
37
|
response: t.Object({
|
|
19
38
|
commits: t.Array(t.Object({
|
|
@@ -31,8 +50,9 @@ export const logHandler = createRouter()
|
|
|
31
50
|
})
|
|
32
51
|
}, async ({ data, conn }) => {
|
|
33
52
|
const project = requireProjectAccess(conn, data.projectId);
|
|
53
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
34
54
|
return await gitService.getLog(
|
|
35
|
-
|
|
55
|
+
cwd,
|
|
36
56
|
data.limit ?? 50,
|
|
37
57
|
data.skip ?? 0,
|
|
38
58
|
data.branch
|
package/backend/ws/git/remote.ts
CHANGED
|
@@ -3,14 +3,33 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { t } from 'elysia';
|
|
6
|
+
import path from 'node:path';
|
|
6
7
|
import { createRouter } from '$shared/utils/ws-server';
|
|
7
8
|
import { gitService } from '../../git/git-service';
|
|
8
9
|
import { requireProjectAccess } from '../access';
|
|
10
|
+
import { debug } from '$shared/utils/logger';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Resolve the working directory for a git operation. Defaults to the project
|
|
14
|
+
* root; when `repoPath` is provided it must already be inside the project.
|
|
15
|
+
*/
|
|
16
|
+
function resolveRepoCwd(projectPath: string, repoPath: string | undefined): string {
|
|
17
|
+
if (!repoPath) return projectPath;
|
|
18
|
+
const resolved = path.resolve(repoPath);
|
|
19
|
+
const projectRoot = path.resolve(projectPath);
|
|
20
|
+
const sep = path.sep;
|
|
21
|
+
if (resolved !== projectRoot && !resolved.startsWith(projectRoot + sep)) {
|
|
22
|
+
debug.warn('git', `Rejected nested repoPath outside project: ${resolved}`);
|
|
23
|
+
return projectPath;
|
|
24
|
+
}
|
|
25
|
+
return resolved;
|
|
26
|
+
}
|
|
9
27
|
|
|
10
28
|
export const remoteHandler = createRouter()
|
|
11
29
|
.http('git:remotes', {
|
|
12
30
|
data: t.Object({
|
|
13
|
-
projectId: t.String()
|
|
31
|
+
projectId: t.String(),
|
|
32
|
+
repoPath: t.Optional(t.String())
|
|
14
33
|
}),
|
|
15
34
|
response: t.Array(t.Object({
|
|
16
35
|
name: t.String(),
|
|
@@ -19,20 +38,23 @@ export const remoteHandler = createRouter()
|
|
|
19
38
|
}))
|
|
20
39
|
}, async ({ data, conn }) => {
|
|
21
40
|
const project = requireProjectAccess(conn, data.projectId);
|
|
22
|
-
|
|
41
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
42
|
+
return await gitService.getRemotes(cwd);
|
|
23
43
|
})
|
|
24
44
|
|
|
25
45
|
.http('git:fetch', {
|
|
26
46
|
data: t.Object({
|
|
27
47
|
projectId: t.String(),
|
|
28
|
-
remote: t.Optional(t.String())
|
|
48
|
+
remote: t.Optional(t.String()),
|
|
49
|
+
repoPath: t.Optional(t.String())
|
|
29
50
|
}),
|
|
30
51
|
response: t.Object({
|
|
31
52
|
message: t.String()
|
|
32
53
|
})
|
|
33
54
|
}, async ({ data, conn }) => {
|
|
34
55
|
const project = requireProjectAccess(conn, data.projectId);
|
|
35
|
-
const
|
|
56
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
57
|
+
const message = await gitService.fetch(cwd, data.remote);
|
|
36
58
|
return { message };
|
|
37
59
|
})
|
|
38
60
|
|
|
@@ -41,7 +63,8 @@ export const remoteHandler = createRouter()
|
|
|
41
63
|
projectId: t.String(),
|
|
42
64
|
remote: t.Optional(t.String()),
|
|
43
65
|
branch: t.Optional(t.String()),
|
|
44
|
-
rebase: t.Optional(t.Boolean())
|
|
66
|
+
rebase: t.Optional(t.Boolean()),
|
|
67
|
+
repoPath: t.Optional(t.String())
|
|
45
68
|
}),
|
|
46
69
|
response: t.Object({
|
|
47
70
|
success: t.Boolean(),
|
|
@@ -49,7 +72,8 @@ export const remoteHandler = createRouter()
|
|
|
49
72
|
})
|
|
50
73
|
}, async ({ data, conn }) => {
|
|
51
74
|
const project = requireProjectAccess(conn, data.projectId);
|
|
52
|
-
|
|
75
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
76
|
+
return await gitService.pull(cwd, data.remote, data.branch, data.rebase);
|
|
53
77
|
})
|
|
54
78
|
|
|
55
79
|
.http('git:push-advanced', {
|
|
@@ -62,7 +86,8 @@ export const remoteHandler = createRouter()
|
|
|
62
86
|
t.Literal('force')
|
|
63
87
|
]),
|
|
64
88
|
remote: t.Optional(t.String()),
|
|
65
|
-
branch: t.Optional(t.String())
|
|
89
|
+
branch: t.Optional(t.String()),
|
|
90
|
+
repoPath: t.Optional(t.String())
|
|
66
91
|
}),
|
|
67
92
|
response: t.Object({
|
|
68
93
|
success: t.Boolean(),
|
|
@@ -70,19 +95,22 @@ export const remoteHandler = createRouter()
|
|
|
70
95
|
})
|
|
71
96
|
}, async ({ data, conn }) => {
|
|
72
97
|
const project = requireProjectAccess(conn, data.projectId);
|
|
73
|
-
|
|
98
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
99
|
+
return await gitService.pushAdvanced(cwd, data.mode, data.remote, data.branch);
|
|
74
100
|
})
|
|
75
101
|
|
|
76
102
|
.http('git:fetch-all', {
|
|
77
103
|
data: t.Object({
|
|
78
|
-
projectId: t.String()
|
|
104
|
+
projectId: t.String(),
|
|
105
|
+
repoPath: t.Optional(t.String())
|
|
79
106
|
}),
|
|
80
107
|
response: t.Object({
|
|
81
108
|
message: t.String()
|
|
82
109
|
})
|
|
83
110
|
}, async ({ data, conn }) => {
|
|
84
111
|
const project = requireProjectAccess(conn, data.projectId);
|
|
85
|
-
const
|
|
112
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
113
|
+
const message = await gitService.fetchAll(cwd);
|
|
86
114
|
return { message };
|
|
87
115
|
})
|
|
88
116
|
|
|
@@ -91,7 +119,8 @@ export const remoteHandler = createRouter()
|
|
|
91
119
|
projectId: t.String(),
|
|
92
120
|
remote: t.Optional(t.String()),
|
|
93
121
|
branch: t.Optional(t.String()),
|
|
94
|
-
force: t.Optional(t.Boolean())
|
|
122
|
+
force: t.Optional(t.Boolean()),
|
|
123
|
+
repoPath: t.Optional(t.String())
|
|
95
124
|
}),
|
|
96
125
|
response: t.Object({
|
|
97
126
|
success: t.Boolean(),
|
|
@@ -99,7 +128,8 @@ export const remoteHandler = createRouter()
|
|
|
99
128
|
})
|
|
100
129
|
}, async ({ data, conn }) => {
|
|
101
130
|
const project = requireProjectAccess(conn, data.projectId);
|
|
102
|
-
|
|
131
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
132
|
+
return await gitService.push(cwd, data.remote, data.branch, data.force);
|
|
103
133
|
})
|
|
104
134
|
|
|
105
135
|
.http('git:add-remote', {
|
|
@@ -174,18 +204,21 @@ export const remoteHandler = createRouter()
|
|
|
174
204
|
data: t.Object({
|
|
175
205
|
projectId: t.String(),
|
|
176
206
|
remote: t.String(),
|
|
177
|
-
branch: t.String()
|
|
207
|
+
branch: t.String(),
|
|
208
|
+
repoPath: t.Optional(t.String())
|
|
178
209
|
}),
|
|
179
210
|
response: t.Object({ ok: t.Boolean() })
|
|
180
211
|
}, async ({ data, conn }) => {
|
|
181
212
|
const project = requireProjectAccess(conn, data.projectId);
|
|
182
|
-
|
|
213
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
214
|
+
await gitService.deleteRemoteBranch(cwd, data.remote, data.branch);
|
|
183
215
|
return { ok: true };
|
|
184
216
|
})
|
|
185
217
|
|
|
186
218
|
.http('git:stash-list', {
|
|
187
219
|
data: t.Object({
|
|
188
|
-
projectId: t.String()
|
|
220
|
+
projectId: t.String(),
|
|
221
|
+
repoPath: t.Optional(t.String())
|
|
189
222
|
}),
|
|
190
223
|
response: t.Array(t.Object({
|
|
191
224
|
index: t.Number(),
|
|
@@ -194,26 +227,30 @@ export const remoteHandler = createRouter()
|
|
|
194
227
|
}))
|
|
195
228
|
}, async ({ data, conn }) => {
|
|
196
229
|
const project = requireProjectAccess(conn, data.projectId);
|
|
197
|
-
|
|
230
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
231
|
+
return await gitService.stashList(cwd);
|
|
198
232
|
})
|
|
199
233
|
|
|
200
234
|
.http('git:stash-save', {
|
|
201
235
|
data: t.Object({
|
|
202
236
|
projectId: t.String(),
|
|
203
237
|
message: t.Optional(t.String()),
|
|
204
|
-
staged: t.Optional(t.Boolean())
|
|
238
|
+
staged: t.Optional(t.Boolean()),
|
|
239
|
+
repoPath: t.Optional(t.String())
|
|
205
240
|
}),
|
|
206
241
|
response: t.Object({ ok: t.Boolean() })
|
|
207
242
|
}, async ({ data, conn }) => {
|
|
208
243
|
const project = requireProjectAccess(conn, data.projectId);
|
|
209
|
-
|
|
244
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
245
|
+
await gitService.stashSave(cwd, data.message, data.staged);
|
|
210
246
|
return { ok: true };
|
|
211
247
|
})
|
|
212
248
|
|
|
213
249
|
.http('git:stash-pop', {
|
|
214
250
|
data: t.Object({
|
|
215
251
|
projectId: t.String(),
|
|
216
|
-
index: t.Optional(t.Number())
|
|
252
|
+
index: t.Optional(t.Number()),
|
|
253
|
+
repoPath: t.Optional(t.String())
|
|
217
254
|
}),
|
|
218
255
|
response: t.Object({
|
|
219
256
|
success: t.Boolean(),
|
|
@@ -222,25 +259,29 @@ export const remoteHandler = createRouter()
|
|
|
222
259
|
})
|
|
223
260
|
}, async ({ data, conn }) => {
|
|
224
261
|
const project = requireProjectAccess(conn, data.projectId);
|
|
225
|
-
|
|
262
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
263
|
+
return await gitService.stashPop(cwd, data.index);
|
|
226
264
|
})
|
|
227
265
|
|
|
228
266
|
.http('git:stash-drop', {
|
|
229
267
|
data: t.Object({
|
|
230
268
|
projectId: t.String(),
|
|
231
|
-
index: t.Optional(t.Number())
|
|
269
|
+
index: t.Optional(t.Number()),
|
|
270
|
+
repoPath: t.Optional(t.String())
|
|
232
271
|
}),
|
|
233
272
|
response: t.Object({ ok: t.Boolean() })
|
|
234
273
|
}, async ({ data, conn }) => {
|
|
235
274
|
const project = requireProjectAccess(conn, data.projectId);
|
|
236
|
-
|
|
275
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
276
|
+
await gitService.stashDrop(cwd, data.index);
|
|
237
277
|
return { ok: true };
|
|
238
278
|
})
|
|
239
279
|
|
|
240
280
|
.http('git:stash-diff', {
|
|
241
281
|
data: t.Object({
|
|
242
282
|
projectId: t.String(),
|
|
243
|
-
index: t.Optional(t.Number())
|
|
283
|
+
index: t.Optional(t.Number()),
|
|
284
|
+
repoPath: t.Optional(t.String())
|
|
244
285
|
}),
|
|
245
286
|
response: t.Array(t.Object({
|
|
246
287
|
oldPath: t.String(),
|
|
@@ -263,12 +304,14 @@ export const remoteHandler = createRouter()
|
|
|
263
304
|
}))
|
|
264
305
|
}, async ({ data, conn }) => {
|
|
265
306
|
const project = requireProjectAccess(conn, data.projectId);
|
|
266
|
-
|
|
307
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
308
|
+
return await gitService.stashDiff(cwd, data.index);
|
|
267
309
|
})
|
|
268
310
|
|
|
269
311
|
.http('git:tags', {
|
|
270
312
|
data: t.Object({
|
|
271
|
-
projectId: t.String()
|
|
313
|
+
projectId: t.String(),
|
|
314
|
+
repoPath: t.Optional(t.String())
|
|
272
315
|
}),
|
|
273
316
|
response: t.Array(t.Object({
|
|
274
317
|
name: t.String(),
|
|
@@ -279,7 +322,8 @@ export const remoteHandler = createRouter()
|
|
|
279
322
|
}))
|
|
280
323
|
}, async ({ data, conn }) => {
|
|
281
324
|
const project = requireProjectAccess(conn, data.projectId);
|
|
282
|
-
|
|
325
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
326
|
+
return await gitService.getTags(cwd);
|
|
283
327
|
})
|
|
284
328
|
|
|
285
329
|
.http('git:create-tag', {
|
|
@@ -287,24 +331,28 @@ export const remoteHandler = createRouter()
|
|
|
287
331
|
projectId: t.String(),
|
|
288
332
|
name: t.String({ minLength: 1 }),
|
|
289
333
|
message: t.Optional(t.String()),
|
|
290
|
-
commitHash: t.Optional(t.String())
|
|
334
|
+
commitHash: t.Optional(t.String()),
|
|
335
|
+
repoPath: t.Optional(t.String())
|
|
291
336
|
}),
|
|
292
337
|
response: t.Object({ ok: t.Boolean() })
|
|
293
338
|
}, async ({ data, conn }) => {
|
|
294
339
|
const project = requireProjectAccess(conn, data.projectId);
|
|
295
|
-
|
|
340
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
341
|
+
await gitService.createTag(cwd, data.name, data.message, data.commitHash);
|
|
296
342
|
return { ok: true };
|
|
297
343
|
})
|
|
298
344
|
|
|
299
345
|
.http('git:delete-tag', {
|
|
300
346
|
data: t.Object({
|
|
301
347
|
projectId: t.String(),
|
|
302
|
-
name: t.String()
|
|
348
|
+
name: t.String(),
|
|
349
|
+
repoPath: t.Optional(t.String())
|
|
303
350
|
}),
|
|
304
351
|
response: t.Object({ ok: t.Boolean() })
|
|
305
352
|
}, async ({ data, conn }) => {
|
|
306
353
|
const project = requireProjectAccess(conn, data.projectId);
|
|
307
|
-
|
|
354
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
355
|
+
await gitService.deleteTag(cwd, data.name);
|
|
308
356
|
return { ok: true };
|
|
309
357
|
})
|
|
310
358
|
|
|
@@ -312,7 +360,8 @@ export const remoteHandler = createRouter()
|
|
|
312
360
|
data: t.Object({
|
|
313
361
|
projectId: t.String(),
|
|
314
362
|
name: t.String(),
|
|
315
|
-
remote: t.Optional(t.String())
|
|
363
|
+
remote: t.Optional(t.String()),
|
|
364
|
+
repoPath: t.Optional(t.String())
|
|
316
365
|
}),
|
|
317
366
|
response: t.Object({
|
|
318
367
|
success: t.Boolean(),
|
|
@@ -320,6 +369,6 @@ export const remoteHandler = createRouter()
|
|
|
320
369
|
})
|
|
321
370
|
}, async ({ data, conn }) => {
|
|
322
371
|
const project = requireProjectAccess(conn, data.projectId);
|
|
323
|
-
|
|
372
|
+
const cwd = resolveRepoCwd(project.path, data.repoPath);
|
|
373
|
+
return await gitService.pushTag(cwd, data.name, data.remote);
|
|
324
374
|
});
|
|
325
|
-
|