@taole/deploy-helper 1.0.2 → 1.0.3
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/README.md +1 -4
- package/lib/pipelineApi.mjs +17 -16
- package/lib/yunxiaoFlowApi.mjs +115 -0
- package/package.json +4 -5
- package/modules/alibabacloud-devops-mcp-server/dist/common/errors.js +0 -69
- package/modules/alibabacloud-devops-mcp-server/dist/common/modularTemplates.js +0 -483
- package/modules/alibabacloud-devops-mcp-server/dist/common/pipelineTemplates.js +0 -19
- package/modules/alibabacloud-devops-mcp-server/dist/common/types.js +0 -1119
- package/modules/alibabacloud-devops-mcp-server/dist/common/utils.js +0 -353
- package/modules/alibabacloud-devops-mcp-server/dist/common/version.js +0 -1
- package/modules/alibabacloud-devops-mcp-server/dist/index.js +0 -1067
- package/modules/alibabacloud-devops-mcp-server/dist/operations/codeup/branches.js +0 -144
- package/modules/alibabacloud-devops-mcp-server/dist/operations/codeup/changeRequestComments.js +0 -89
- package/modules/alibabacloud-devops-mcp-server/dist/operations/codeup/changeRequests.js +0 -203
- package/modules/alibabacloud-devops-mcp-server/dist/operations/codeup/compare.js +0 -26
- package/modules/alibabacloud-devops-mcp-server/dist/operations/codeup/files.js +0 -233
- package/modules/alibabacloud-devops-mcp-server/dist/operations/codeup/repositories.js +0 -64
- package/modules/alibabacloud-devops-mcp-server/dist/operations/flow/hostGroup.js +0 -48
- package/modules/alibabacloud-devops-mcp-server/dist/operations/flow/pipeline.js +0 -514
- package/modules/alibabacloud-devops-mcp-server/dist/operations/flow/pipelineJob.js +0 -113
- package/modules/alibabacloud-devops-mcp-server/dist/operations/flow/serviceConnection.js +0 -23
- package/modules/alibabacloud-devops-mcp-server/dist/operations/organization/members.js +0 -94
- package/modules/alibabacloud-devops-mcp-server/dist/operations/organization/organization.js +0 -73
- package/modules/alibabacloud-devops-mcp-server/dist/operations/packages/artifacts.js +0 -64
- package/modules/alibabacloud-devops-mcp-server/dist/operations/packages/repositories.js +0 -35
- package/modules/alibabacloud-devops-mcp-server/dist/operations/projex/project.js +0 -206
- package/modules/alibabacloud-devops-mcp-server/dist/operations/projex/sprint.js +0 -30
- package/modules/alibabacloud-devops-mcp-server/dist/operations/projex/workitem.js +0 -264
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { buildUrl, yunxiaoRequest } from "../../common/utils.js";
|
|
2
|
-
import { CodeupBranchSchema } from "../../common/types.js";
|
|
3
|
-
/**
|
|
4
|
-
* 创建分支
|
|
5
|
-
* @param organizationId
|
|
6
|
-
* @param repositoryId
|
|
7
|
-
* @param branch
|
|
8
|
-
* @param ref
|
|
9
|
-
*/
|
|
10
|
-
export async function createBranchFunc(organizationId, repositoryId, branch, ref = "master") {
|
|
11
|
-
// Automatically handle unencoded slashes in repositoryId
|
|
12
|
-
if (repositoryId.includes("/")) {
|
|
13
|
-
// Found unencoded slash, automatically URL encode it
|
|
14
|
-
const parts = repositoryId.split("/", 2);
|
|
15
|
-
if (parts.length === 2) {
|
|
16
|
-
const encodedRepoName = encodeURIComponent(parts[1]);
|
|
17
|
-
// Remove + signs from encoding (spaces are encoded as +, but we need %20)
|
|
18
|
-
const formattedEncodedName = encodedRepoName.replace(/\+/g, "%20");
|
|
19
|
-
repositoryId = `${parts[0]}%2F${formattedEncodedName}`;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
const baseUrl = `/oapi/v1/codeup/organizations/${organizationId}/repositories/${repositoryId}/branches`;
|
|
23
|
-
// Build query parameters
|
|
24
|
-
const queryParams = {
|
|
25
|
-
branch: branch,
|
|
26
|
-
ref: ref
|
|
27
|
-
};
|
|
28
|
-
const url = buildUrl(baseUrl, queryParams);
|
|
29
|
-
console.error("createBranchFunc url:" + url);
|
|
30
|
-
const response = await yunxiaoRequest(url, {
|
|
31
|
-
method: "POST",
|
|
32
|
-
});
|
|
33
|
-
return CodeupBranchSchema.parse(response);
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* 获取分支详情
|
|
37
|
-
* @param organizationId
|
|
38
|
-
* @param repositoryId
|
|
39
|
-
* @param branchName
|
|
40
|
-
*/
|
|
41
|
-
export async function getBranchFunc(organizationId, repositoryId, branchName) {
|
|
42
|
-
// Automatically handle unencoded slashes in repositoryId
|
|
43
|
-
if (repositoryId.includes("/")) {
|
|
44
|
-
// Found unencoded slash, automatically URL encode it
|
|
45
|
-
const parts = repositoryId.split("/", 2);
|
|
46
|
-
if (parts.length === 2) {
|
|
47
|
-
const encodedRepoName = encodeURIComponent(parts[1]);
|
|
48
|
-
// Remove + signs from encoding (spaces are encoded as +, but we need %20)
|
|
49
|
-
const formattedEncodedName = encodedRepoName.replace(/\+/g, "%20");
|
|
50
|
-
repositoryId = `${parts[0]}%2F${formattedEncodedName}`;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
// Automatically handle unencoded slashes in branchName
|
|
54
|
-
if (branchName.includes("/")) {
|
|
55
|
-
branchName = encodeURIComponent(branchName);
|
|
56
|
-
}
|
|
57
|
-
const url = `/oapi/v1/codeup/organizations/${organizationId}/repositories/${repositoryId}/branches/${branchName}`;
|
|
58
|
-
const response = await yunxiaoRequest(url, {
|
|
59
|
-
method: "GET",
|
|
60
|
-
});
|
|
61
|
-
return CodeupBranchSchema.parse(response);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* 删除分支
|
|
65
|
-
* @param organizationId
|
|
66
|
-
* @param repositoryId
|
|
67
|
-
* @param branchName
|
|
68
|
-
*/
|
|
69
|
-
export async function deleteBranchFunc(organizationId, repositoryId, branchName) {
|
|
70
|
-
// Automatically handle unencoded slashes in repositoryId
|
|
71
|
-
if (repositoryId.includes("/")) {
|
|
72
|
-
// Found unencoded slash, automatically URL encode it
|
|
73
|
-
const parts = repositoryId.split("/", 2);
|
|
74
|
-
if (parts.length === 2) {
|
|
75
|
-
const encodedRepoName = encodeURIComponent(parts[1]);
|
|
76
|
-
// Remove + signs from encoding (spaces are encoded as +, but we need %20)
|
|
77
|
-
const formattedEncodedName = encodedRepoName.replace(/\+/g, "%20");
|
|
78
|
-
repositoryId = `${parts[0]}%2F${formattedEncodedName}`;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
// Automatically handle unencoded slashes in branchName
|
|
82
|
-
if (branchName.includes("/")) {
|
|
83
|
-
branchName = encodeURIComponent(branchName);
|
|
84
|
-
}
|
|
85
|
-
const url = `/oapi/v1/codeup/organizations/${organizationId}/repositories/${repositoryId}/branches/${branchName}`;
|
|
86
|
-
const response = await yunxiaoRequest(url, {
|
|
87
|
-
method: "DELETE",
|
|
88
|
-
});
|
|
89
|
-
return {
|
|
90
|
-
branchName: branchName
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* 查询分支列表
|
|
95
|
-
* @param organizationId
|
|
96
|
-
* @param repositoryId
|
|
97
|
-
* @param page
|
|
98
|
-
* @param perPage
|
|
99
|
-
* @param sort
|
|
100
|
-
* @param search
|
|
101
|
-
*/
|
|
102
|
-
export async function listBranchesFunc(organizationId, repositoryId, page, perPage, sort, // Possible values: name_asc, name_desc, updated_asc, updated_desc
|
|
103
|
-
search) {
|
|
104
|
-
console.error("listBranchesFunc page:" + page + " perPage:" + perPage + " sort:" + sort + " search:" + search);
|
|
105
|
-
// Automatically handle unencoded slashes in repositoryId
|
|
106
|
-
if (repositoryId.includes("/")) {
|
|
107
|
-
// Found unencoded slash, automatically URL encode it
|
|
108
|
-
const parts = repositoryId.split("/", 2);
|
|
109
|
-
if (parts.length === 2) {
|
|
110
|
-
const encodedRepoName = encodeURIComponent(parts[1]);
|
|
111
|
-
// Remove + signs from encoding (spaces are encoded as +, but we need %20)
|
|
112
|
-
const formattedEncodedName = encodedRepoName.replace(/\+/g, "%20");
|
|
113
|
-
repositoryId = `${parts[0]}%2F${formattedEncodedName}`;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
const baseUrl = `/oapi/v1/codeup/organizations/${organizationId}/repositories/${repositoryId}/branches`;
|
|
117
|
-
// Build query parameters - use lowercase parameter names as expected by the API
|
|
118
|
-
const queryParams = {};
|
|
119
|
-
if (page !== undefined && page !== null) {
|
|
120
|
-
queryParams.page = page;
|
|
121
|
-
}
|
|
122
|
-
if (perPage !== undefined && perPage !== null) {
|
|
123
|
-
queryParams.perPage = perPage;
|
|
124
|
-
}
|
|
125
|
-
if (sort !== undefined && sort !== null) {
|
|
126
|
-
queryParams.sort = sort;
|
|
127
|
-
}
|
|
128
|
-
if (search !== undefined && search !== null) {
|
|
129
|
-
queryParams.search = search;
|
|
130
|
-
}
|
|
131
|
-
const url = buildUrl(baseUrl, queryParams);
|
|
132
|
-
const response = await yunxiaoRequest(url, {
|
|
133
|
-
method: "GET",
|
|
134
|
-
});
|
|
135
|
-
if (!Array.isArray(response)) {
|
|
136
|
-
return [];
|
|
137
|
-
}
|
|
138
|
-
// Map each branch object and handle null values
|
|
139
|
-
return response.map(branchData => {
|
|
140
|
-
// Filter out null values that would cause parsing errors
|
|
141
|
-
// This is a defensive approach until we update all schemas properly
|
|
142
|
-
return CodeupBranchSchema.parse(branchData);
|
|
143
|
-
});
|
|
144
|
-
}
|
package/modules/alibabacloud-devops-mcp-server/dist/operations/codeup/changeRequestComments.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { yunxiaoRequest, handleRepositoryIdEncoding } from "../../common/utils.js";
|
|
2
|
-
import { ChangeRequestCommentSchema } from "../../common/types.js";
|
|
3
|
-
/**
|
|
4
|
-
* 创建合并请求评论
|
|
5
|
-
* @param organizationId
|
|
6
|
-
* @param repositoryId
|
|
7
|
-
* @param localId
|
|
8
|
-
* @param comment_type
|
|
9
|
-
* @param content
|
|
10
|
-
* @param draft
|
|
11
|
-
* @param resolved
|
|
12
|
-
* @param patchset_biz_id
|
|
13
|
-
* @param file_path
|
|
14
|
-
* @param line_number
|
|
15
|
-
* @param from_patchset_biz_id
|
|
16
|
-
* @param to_patchset_biz_id
|
|
17
|
-
* @param parent_comment_biz_id
|
|
18
|
-
*/
|
|
19
|
-
export async function createChangeRequestCommentFunc(organizationId, repositoryId, localId, comment_type, // Possible values: GLOBAL_COMMENT, INLINE_COMMENT
|
|
20
|
-
content, draft, resolved, patchset_biz_id, file_path, line_number, from_patchset_biz_id, to_patchset_biz_id, parent_comment_biz_id) {
|
|
21
|
-
const encodedRepoId = handleRepositoryIdEncoding(repositoryId);
|
|
22
|
-
const url = `/oapi/v1/codeup/organizations/${organizationId}/repositories/${encodedRepoId}/changeRequests/${localId}/comments`;
|
|
23
|
-
// 准备payload
|
|
24
|
-
const payload = {
|
|
25
|
-
comment_type: comment_type,
|
|
26
|
-
content: content,
|
|
27
|
-
draft: draft,
|
|
28
|
-
resolved: resolved,
|
|
29
|
-
patchset_biz_id: patchset_biz_id,
|
|
30
|
-
};
|
|
31
|
-
// 根据评论类型添加必要参数
|
|
32
|
-
if (comment_type === "INLINE_COMMENT") {
|
|
33
|
-
// 检查INLINE_COMMENT必需的参数
|
|
34
|
-
if (!file_path || line_number === undefined || !from_patchset_biz_id || !to_patchset_biz_id) {
|
|
35
|
-
throw new Error("For INLINE_COMMENT, file_path, line_number, from_patchset_biz_id, and to_patchset_biz_id are required");
|
|
36
|
-
}
|
|
37
|
-
payload.file_path = file_path;
|
|
38
|
-
payload.line_number = line_number;
|
|
39
|
-
payload.from_patchset_biz_id = from_patchset_biz_id;
|
|
40
|
-
payload.to_patchset_biz_id = to_patchset_biz_id;
|
|
41
|
-
}
|
|
42
|
-
// 添加可选参数
|
|
43
|
-
if (parent_comment_biz_id) {
|
|
44
|
-
payload.parent_comment_biz_id = parent_comment_biz_id;
|
|
45
|
-
}
|
|
46
|
-
const response = await yunxiaoRequest(url, {
|
|
47
|
-
method: "POST",
|
|
48
|
-
body: payload,
|
|
49
|
-
});
|
|
50
|
-
return ChangeRequestCommentSchema.parse(response);
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* 获取合并请求评论列表
|
|
54
|
-
* @param organizationId
|
|
55
|
-
* @param repositoryId
|
|
56
|
-
* @param localId
|
|
57
|
-
* @param patchSetBizIds
|
|
58
|
-
* @param commentType
|
|
59
|
-
* @param state
|
|
60
|
-
* @param resolved
|
|
61
|
-
* @param filePath
|
|
62
|
-
*/
|
|
63
|
-
export async function listChangeRequestCommentsFunc(organizationId, repositoryId, localId, patchSetBizIds, commentType = "GLOBAL_COMMENT", // Possible values: GLOBAL_COMMENT, INLINE_COMMENT
|
|
64
|
-
state = "OPENED", // Possible values: OPENED, DRAFT
|
|
65
|
-
resolved = false, filePath) {
|
|
66
|
-
const encodedRepoId = handleRepositoryIdEncoding(repositoryId);
|
|
67
|
-
const url = `/oapi/v1/codeup/organizations/${organizationId}/repositories/${encodedRepoId}/changeRequests/${localId}/comments/list`;
|
|
68
|
-
// 准备payload
|
|
69
|
-
const payload = {
|
|
70
|
-
patchSetBizIds: patchSetBizIds || [],
|
|
71
|
-
commentType: commentType,
|
|
72
|
-
state: state,
|
|
73
|
-
resolved: resolved,
|
|
74
|
-
};
|
|
75
|
-
// 添加可选参数
|
|
76
|
-
if (filePath) {
|
|
77
|
-
payload.filePath = filePath;
|
|
78
|
-
}
|
|
79
|
-
const response = await yunxiaoRequest(url, {
|
|
80
|
-
method: "POST",
|
|
81
|
-
body: payload,
|
|
82
|
-
});
|
|
83
|
-
// 确保响应是数组
|
|
84
|
-
if (!Array.isArray(response)) {
|
|
85
|
-
return [];
|
|
86
|
-
}
|
|
87
|
-
// 解析每个评论对象
|
|
88
|
-
return response.map(comment => ChangeRequestCommentSchema.parse(comment));
|
|
89
|
-
}
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import { yunxiaoRequest, buildUrl, handleRepositoryIdEncoding, floatToIntString } from "../../common/utils.js";
|
|
2
|
-
import { ChangeRequestSchema, PatchSetSchema } from "../../common/types.js";
|
|
3
|
-
// 通过API获取仓库的数字ID
|
|
4
|
-
async function getRepositoryNumericId(organizationId, repositoryId) {
|
|
5
|
-
const url = `/oapi/v1/codeup/organizations/${organizationId}/repositories/${repositoryId}`;
|
|
6
|
-
const response = await yunxiaoRequest(url, {
|
|
7
|
-
method: "GET",
|
|
8
|
-
});
|
|
9
|
-
if (!response || typeof response !== 'object' || !('id' in response)) {
|
|
10
|
-
throw new Error("Failed to get repository ID");
|
|
11
|
-
}
|
|
12
|
-
const repoId = response.id;
|
|
13
|
-
if (!repoId) {
|
|
14
|
-
throw new Error("Could not get repository ID");
|
|
15
|
-
}
|
|
16
|
-
return repoId.toString();
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* 查询合并请求
|
|
20
|
-
* @param organizationId
|
|
21
|
-
* @param repositoryId
|
|
22
|
-
* @param localId
|
|
23
|
-
*/
|
|
24
|
-
export async function getChangeRequestFunc(organizationId, repositoryId, localId) {
|
|
25
|
-
const encodedRepoId = handleRepositoryIdEncoding(repositoryId);
|
|
26
|
-
const url = `/oapi/v1/codeup/organizations/${organizationId}/repositories/${encodedRepoId}/changeRequests/${localId}`;
|
|
27
|
-
const response = await yunxiaoRequest(url, {
|
|
28
|
-
method: "GET",
|
|
29
|
-
});
|
|
30
|
-
return ChangeRequestSchema.parse(response);
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* 查询合并请求列表
|
|
34
|
-
* @param organizationId
|
|
35
|
-
* @param page
|
|
36
|
-
* @param perPage
|
|
37
|
-
* @param projectIds
|
|
38
|
-
* @param authorIds
|
|
39
|
-
* @param reviewerIds
|
|
40
|
-
* @param state
|
|
41
|
-
* @param search
|
|
42
|
-
* @param orderBy
|
|
43
|
-
* @param sort
|
|
44
|
-
* @param createdBefore
|
|
45
|
-
* @param createdAfter
|
|
46
|
-
*/
|
|
47
|
-
export async function listChangeRequestsFunc(organizationId, page, perPage, projectIds, authorIds, reviewerIds, state, // Possible values: opened, merged, closed
|
|
48
|
-
search, orderBy, // Possible values: created_at, updated_at
|
|
49
|
-
sort, // Possible values: asc, desc
|
|
50
|
-
createdBefore, createdAfter) {
|
|
51
|
-
const baseUrl = `/oapi/v1/codeup/organizations/${organizationId}/changeRequests`;
|
|
52
|
-
// 构建查询参数
|
|
53
|
-
const queryParams = {};
|
|
54
|
-
if (page !== undefined) {
|
|
55
|
-
queryParams.page = page;
|
|
56
|
-
}
|
|
57
|
-
if (perPage !== undefined) {
|
|
58
|
-
queryParams.perPage = perPage;
|
|
59
|
-
}
|
|
60
|
-
if (projectIds !== undefined) {
|
|
61
|
-
queryParams.projectIds = projectIds;
|
|
62
|
-
}
|
|
63
|
-
if (authorIds !== undefined) {
|
|
64
|
-
queryParams.authorIds = authorIds;
|
|
65
|
-
}
|
|
66
|
-
if (reviewerIds !== undefined) {
|
|
67
|
-
queryParams.reviewerIds = reviewerIds;
|
|
68
|
-
}
|
|
69
|
-
if (state !== undefined) {
|
|
70
|
-
queryParams.state = state;
|
|
71
|
-
}
|
|
72
|
-
if (search !== undefined) {
|
|
73
|
-
queryParams.search = search;
|
|
74
|
-
}
|
|
75
|
-
if (orderBy !== undefined) {
|
|
76
|
-
queryParams.orderBy = orderBy;
|
|
77
|
-
}
|
|
78
|
-
if (sort !== undefined) {
|
|
79
|
-
queryParams.sort = sort;
|
|
80
|
-
}
|
|
81
|
-
if (createdBefore !== undefined) {
|
|
82
|
-
queryParams.createdBefore = createdBefore;
|
|
83
|
-
}
|
|
84
|
-
if (createdAfter !== undefined) {
|
|
85
|
-
queryParams.createdAfter = createdAfter;
|
|
86
|
-
}
|
|
87
|
-
// 使用buildUrl函数构建包含查询参数的URL
|
|
88
|
-
const url = buildUrl(baseUrl, queryParams);
|
|
89
|
-
const response = await yunxiaoRequest(url, {
|
|
90
|
-
method: "GET",
|
|
91
|
-
});
|
|
92
|
-
// 确保响应是数组
|
|
93
|
-
if (!Array.isArray(response)) {
|
|
94
|
-
return [];
|
|
95
|
-
}
|
|
96
|
-
// 解析每个变更请求对象
|
|
97
|
-
return response.map(changeRequest => ChangeRequestSchema.parse(changeRequest));
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* 查询合并请求的版本列表
|
|
101
|
-
* @param organizationId
|
|
102
|
-
* @param repositoryId
|
|
103
|
-
* @param localId
|
|
104
|
-
*/
|
|
105
|
-
export async function listChangeRequestPatchSetsFunc(organizationId, repositoryId, localId) {
|
|
106
|
-
const encodedRepoId = handleRepositoryIdEncoding(repositoryId);
|
|
107
|
-
const url = `/oapi/v1/codeup/organizations/${organizationId}/repositories/${encodedRepoId}/changeRequests/${localId}/diffs/patches`;
|
|
108
|
-
const response = await yunxiaoRequest(url, {
|
|
109
|
-
method: "GET",
|
|
110
|
-
});
|
|
111
|
-
// 确保响应是数组
|
|
112
|
-
if (!Array.isArray(response)) {
|
|
113
|
-
return [];
|
|
114
|
-
}
|
|
115
|
-
// 解析每个版本对象
|
|
116
|
-
return response.map(patchSet => PatchSetSchema.parse(patchSet));
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* 创建合并请求
|
|
120
|
-
* @param organizationId
|
|
121
|
-
* @param repositoryId
|
|
122
|
-
* @param title
|
|
123
|
-
* @param sourceBranch
|
|
124
|
-
* @param targetBranch
|
|
125
|
-
* @param description
|
|
126
|
-
* @param sourceProjectId
|
|
127
|
-
* @param targetProjectId
|
|
128
|
-
* @param reviewerUserIds
|
|
129
|
-
* @param workItemIds
|
|
130
|
-
* @param createFrom
|
|
131
|
-
*/
|
|
132
|
-
export async function createChangeRequestFunc(organizationId, repositoryId, title, sourceBranch, targetBranch, description, sourceProjectId, targetProjectId, reviewerUserIds, workItemIds, createFrom = "WEB" // Possible values: WEB, COMMAND_LINE
|
|
133
|
-
) {
|
|
134
|
-
const encodedRepoId = handleRepositoryIdEncoding(repositoryId);
|
|
135
|
-
// 检查和获取sourceProjectId和targetProjectId
|
|
136
|
-
let sourceIdString;
|
|
137
|
-
let targetIdString;
|
|
138
|
-
if (sourceProjectId !== undefined) {
|
|
139
|
-
sourceIdString = floatToIntString(sourceProjectId);
|
|
140
|
-
}
|
|
141
|
-
if (targetProjectId !== undefined) {
|
|
142
|
-
targetIdString = floatToIntString(targetProjectId);
|
|
143
|
-
}
|
|
144
|
-
// 如果repositoryId是纯数字,且sourceProjectId或targetProjectId未提供,直接使用repositoryId的值
|
|
145
|
-
if (!isNaN(Number(repositoryId))) {
|
|
146
|
-
// 是数字ID,可以直接使用
|
|
147
|
-
if (sourceIdString === undefined) {
|
|
148
|
-
sourceIdString = repositoryId;
|
|
149
|
-
}
|
|
150
|
-
if (targetIdString === undefined) {
|
|
151
|
-
targetIdString = repositoryId;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
else if (repositoryId.includes("%2F") || repositoryId.includes("/")) {
|
|
155
|
-
// 如果是组织ID与仓库名称的组合,调用API获取数字ID
|
|
156
|
-
if (sourceIdString === undefined || targetIdString === undefined) {
|
|
157
|
-
try {
|
|
158
|
-
const numericId = await getRepositoryNumericId(organizationId, encodedRepoId);
|
|
159
|
-
if (sourceIdString === undefined) {
|
|
160
|
-
sourceIdString = numericId;
|
|
161
|
-
}
|
|
162
|
-
if (targetIdString === undefined) {
|
|
163
|
-
targetIdString = numericId;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
catch (error) {
|
|
167
|
-
throw new Error(`When using 'organizationId%2Frepo-name' format, you must first get the numeric ID of the repository and use it for sourceProjectId and targetProjectId parameters. Please use get_repository tool to get the numeric ID of '${repositoryId}' and then use that ID as the value for sourceProjectId and targetProjectId.`);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
// 确保sourceProjectId和targetProjectId已设置
|
|
172
|
-
if (sourceIdString === undefined) {
|
|
173
|
-
throw new Error("Could not get sourceProjectId, please provide this parameter manually");
|
|
174
|
-
}
|
|
175
|
-
if (targetIdString === undefined) {
|
|
176
|
-
throw new Error("Could not get targetProjectId, please provide this parameter manually");
|
|
177
|
-
}
|
|
178
|
-
const url = `/oapi/v1/codeup/organizations/${organizationId}/repositories/${encodedRepoId}/changeRequests`;
|
|
179
|
-
// 准备payload
|
|
180
|
-
const payload = {
|
|
181
|
-
title: title,
|
|
182
|
-
sourceBranch: sourceBranch,
|
|
183
|
-
targetBranch: targetBranch,
|
|
184
|
-
sourceProjectId: sourceIdString,
|
|
185
|
-
targetProjectId: targetIdString,
|
|
186
|
-
createFrom: createFrom,
|
|
187
|
-
};
|
|
188
|
-
// 添加可选参数
|
|
189
|
-
if (description !== undefined) {
|
|
190
|
-
payload.description = description;
|
|
191
|
-
}
|
|
192
|
-
if (reviewerUserIds !== undefined) {
|
|
193
|
-
payload.reviewerUserIds = reviewerUserIds;
|
|
194
|
-
}
|
|
195
|
-
if (workItemIds !== undefined) {
|
|
196
|
-
payload.workItemIds = workItemIds;
|
|
197
|
-
}
|
|
198
|
-
const response = await yunxiaoRequest(url, {
|
|
199
|
-
method: "POST",
|
|
200
|
-
body: payload,
|
|
201
|
-
});
|
|
202
|
-
return ChangeRequestSchema.parse(response);
|
|
203
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { yunxiaoRequest, buildUrl, handleRepositoryIdEncoding } from "../../common/utils.js";
|
|
2
|
-
import { CompareSchema } from "../../common/types.js";
|
|
3
|
-
export async function getCompareFunc(organizationId, repositoryId, from, to, sourceType, // Possible values: branch, tag
|
|
4
|
-
targetType, // Possible values: branch, tag
|
|
5
|
-
straight) {
|
|
6
|
-
const encodedRepoId = handleRepositoryIdEncoding(repositoryId);
|
|
7
|
-
const baseUrl = `/oapi/v1/codeup/organizations/${organizationId}/repositories/${encodedRepoId}/compares`;
|
|
8
|
-
const queryParams = {
|
|
9
|
-
from,
|
|
10
|
-
to
|
|
11
|
-
};
|
|
12
|
-
if (sourceType !== undefined) {
|
|
13
|
-
queryParams.sourceType = sourceType;
|
|
14
|
-
}
|
|
15
|
-
if (targetType !== undefined) {
|
|
16
|
-
queryParams.targetType = targetType;
|
|
17
|
-
}
|
|
18
|
-
if (straight !== undefined) {
|
|
19
|
-
queryParams.straight = straight;
|
|
20
|
-
}
|
|
21
|
-
const url = buildUrl(baseUrl, queryParams);
|
|
22
|
-
const response = await yunxiaoRequest(url, {
|
|
23
|
-
method: "GET",
|
|
24
|
-
});
|
|
25
|
-
return CompareSchema.parse(response);
|
|
26
|
-
}
|