t-comm
Version:
专业、稳定、纯粹的工具库
221 lines (220 loc) • 6.96 kB
TypeScript
/**
* 获取tGit上某分支生命周期
* @param {object} options 输入配置
* @param {string} options.projectName 项目名称
* @param {string} options.branchName 分支名称
* @param {string} options.privateToken 密钥
* @returns {Promise<object>} 请求Promise
* @example
*
* getBranchLifeCycle({
* projectName: 't-comm',
* branchName: 'master',
* privateToken: 'xxxxx',
* }).then((resp) => {
*
* })
*/
export declare function getBranchLifeCycle({ projectName, branchName, privateToken, baseUrl, }: {
projectName: string;
branchName: string;
privateToken: string;
baseUrl?: string;
}): Promise<object>;
/**
* 获取默认分支
* @param {object} options 输入配置
* @param {string} options.projectName 项目名称
* @param {string} options.privateToken 密钥
* @returns {Promise<string>} 请求Promise
* @example
*
* getProjectDefaultBranch({
* projectName: 't-comm',
* privateToken: 'xxxxx',
* }).then((branch) => {
* console.log('branch: ', branch)
* })
*/
export declare function getProjectDefaultBranch({ projectName, privateToken, baseUrl, }: {
projectName: string;
privateToken: string;
baseUrl?: string;
}): Promise<string>;
/**
* 获取仓库的分支列表
* @param {object} options 输入配置
* @param {string} options.projectName 项目名称
* @param {string} options.privateToken 密钥
* @param {string} options.baseUrl baseUrl
* @returns {Promise<Array<object>>} 请求Promise
* @example
*
* getBranchesByProjectName({
* projectName: 't-comm',
* privateToken: 'xxxxx',
* }).then((resp) => {
*
* })
*/
export declare function getBranchesByProjectName({ projectName, privateToken, baseUrl, }: {
projectName: string;
privateToken: string;
baseUrl?: string;
}): Promise<Array<object>>;
/**
* 获取分支详情
* @param {object} options 输入配置
* @param {string} options.projectName 项目名称
* @param {string} options.branchName 分支名称
* @param {string} options.privateToken 密钥
* @returns {Promise<object>} 请求Promise
* @example
*
* getOneBranchDetail({
* projectName: 't-comm',
* branchName: 'master',
* privateToken: 'xxxxx',
* }).then((resp) => {
*
* })
*/
export declare function getOneBranchDetail({ projectName, branchName, privateToken, baseUrl }: {
projectName: string;
branchName: string;
privateToken: string;
baseUrl?: string;
}): Promise<object>;
/**
* 合并分支:将分支或者 commit 合并到指定分支
*
* 对应工蜂 API:PUT /api/v3/projects/:id/repository/branches/merge
*
* @param {object} options 输入配置
* @param {number | string} options.id 项目 ID 或 项目全路径 project_full_path
* @param {string} options.sourceObjectId 源分支名或者 commit
* @param {string} options.targetBranch 目标分支名
* @param {number} [options.sourceProjectId] 源项目 ID,默认为 id 的值
* @param {'merge' | 'rebase' | 'squash'} [options.mergeType] 合并方式,默认为普通合并 merge
* @param {string} [options.commitMessage] 合并点提交信息(mergeType=rebase 时必填)
* @param {string} options.privateToken 密钥
* @param {string} [options.baseUrl] baseUrl
* @returns {Promise<unknown>} 请求 Promise
* @example
*
* mergeBranches({
* id: 12345,
* sourceObjectId: 'feature/xxx',
* targetBranch: 'master',
* mergeType: 'merge',
* privateToken: 'xxxxx',
* }).then((resp) => {
*
* })
*/
export declare function mergeBranches({ id, sourceObjectId, targetBranch, sourceProjectId, mergeType, commitMessage, privateToken, baseUrl, }: {
id: number | string;
sourceObjectId: string;
targetBranch: string;
sourceProjectId?: number;
mergeType?: 'merge' | 'rebase' | 'squash';
commitMessage?: string;
privateToken: string;
baseUrl?: string;
}): Promise<unknown>;
/**
* 创建新分支
*
* 对应工蜂 API:POST /api/v3/projects/:id/repository/branches
*
* @param {object} options 输入配置
* @param {string | number} options.projectName 项目名称或项目 ID
* @param {string} options.branchName 新分支名
* @param {string} options.ref 基于哪个分支/commit/tag 创建
* @param {string} options.privateToken 密钥
* @param {string} [options.baseUrl] baseUrl
* @returns {Promise<{ name: string } & Record<string, unknown>>} 新建分支信息
* @example
*
* createBranch({
* projectName: 'group/sub/repo',
* branchName: 'feature/x',
* ref: 'master',
* privateToken: 'xxxxx',
* }).then((resp) => {
*
* })
*/
export declare function createBranch({ projectName, branchName, ref, privateToken, baseUrl, }: {
projectName: string | number;
branchName: string;
ref: string;
privateToken: string;
baseUrl?: string;
}): Promise<{
name: string;
} & Record<string, unknown>>;
/**
* 删除分支
*
* 对应工蜂 API:DELETE /api/v3/projects/:id/repository/branches/:branch
*
* @param {object} options 输入配置
* @param {string | number} options.projectName 项目名称或项目 ID
* @param {string} options.branchName 要删除的分支名
* @param {string} options.privateToken 密钥
* @param {string} [options.baseUrl] baseUrl
* @returns {Promise<unknown>} 请求 Promise
* @example
*
* deleteBranch({
* projectName: 'group/sub/repo',
* branchName: 'feature/x',
* privateToken: 'xxxxx',
* }).then((resp) => {
*
* })
*/
export declare function deleteBranch({ projectName, branchName, privateToken, baseUrl, }: {
projectName: string | number;
branchName: string;
privateToken: string;
baseUrl?: string;
}): Promise<unknown>;
/**
* 修改分支
*
* 编辑给定项目的某个分支。注意:如果项目内已存在 Mainline 分支,则不允许将其他分支设置成 Mainline 类别。
*
* 对应工蜂 API:PUT /api/v3/projects/:id/repository/branches/:branch
*
* @param {object} options 输入配置
* @param {string | number} options.projectName 项目 ID 或项目全路径 project_full_path
* @param {string} options.branchName 分支名
* @param {string} [options.description] 分支描述
* @param {string} [options.branchType] 分支类别,比如 Mainline、Feature、Others 等
* @param {string} options.privateToken 密钥
* @param {string} [options.baseUrl] baseUrl
* @returns {Promise<{ name: string } & Record<string, unknown>>} 修改后的分支信息
* @example
*
* editBranch({
* projectName: 'group/sub/repo',
* branchName: 'feature/x',
* branchType: 'Feature',
* description: 'feature 分支',
* privateToken: 'xxxxx',
* }).then((resp) => {
*
* })
*/
export declare function editBranch({ projectName, branchName, description, branchType, privateToken, baseUrl, }: {
projectName: string | number;
branchName: string;
description?: string;
branchType?: string;
privateToken: string;
baseUrl?: string;
}): Promise<{
name: string;
} & Record<string, unknown>>;