引入
ts
import {
getBranchLifeCycle,
getProjectDefaultBranch,
getBranchesByProjectName,
getOneBranchDetail,
getOneCommitDetail,
createMR,
getMrList,
getOneMrComments,
getOneProjectDetail,
getOneProjectBySearch,
getAllProjects,
deleteTGitProject
} from 't-comm';
// 不支持 tree-shaking 的项目
import {
getBranchLifeCycle,
getProjectDefaultBranch,
getBranchesByProjectName,
getOneBranchDetail,
getOneCommitDetail,
createMR,
getMrList,
getOneMrComments,
getOneProjectDetail,
getOneProjectBySearch,
getAllProjects,
deleteTGitProject
} from 't-comm/lib/tgit/index';
// 只支持 ESM 的项目
import {
getBranchLifeCycle,
getProjectDefaultBranch,
getBranchesByProjectName,
getOneBranchDetail,
getOneCommitDetail,
createMR,
getMrList,
getOneMrComments,
getOneProjectDetail,
getOneProjectBySearch,
getAllProjects,
deleteTGitProject
} from 't-comm/es/tgit/index';getBranchLifeCycle(options)
描述:
获取tGit上某分支生命周期
参数:
| 参数名 | 类型 | 描述 |
|---|---|---|
| options | object | 输入配置 |
| options.projectName | string | 项目名称 |
| options.branchName | string | 分支名称 |
| options.privateToken | string | 密钥 |
返回: Promise.<object>
请求Promise
示例
typescript
getBranchLifeCycle({
projectName: 't-comm',
branchName: 'master',
privateToken: 'xxxxx',
}).then((resp) => {
})getProjectDefaultBranch(options)
描述:
获取默认分支
参数:
| 参数名 | 类型 | 描述 |
|---|---|---|
| options | object | 输入配置 |
| options.projectName | string | 项目名称 |
| options.privateToken | string | 密钥 |
返回: Promise.<string>
请求Promise
示例
typescript
getProjectDefaultBranch({
projectName: 't-comm',
privateToken: 'xxxxx',
}).then((branch) => {
console.log('branch: ', branch)
})getBranchesByProjectName(options)
描述:
获取仓库的分支列表
参数:
| 参数名 | 类型 | 描述 |
|---|---|---|
| options | object | 输入配置 |
| options.projectName | string | 项目名称 |
| options.privateToken | string | 密钥 |
| options.baseUrl | string | baseUrl |
返回: Promise.<Array<object>>
请求Promise
示例
typescript
getBranchesByProjectName({
projectName: 't-comm',
privateToken: 'xxxxx',
}).then((resp) => {
})getOneBranchDetail(options)
描述:
获取分支详情
参数:
| 参数名 | 类型 | 描述 |
|---|---|---|
| options | object | 输入配置 |
| options.projectName | string | 项目名称 |
| options.branchName | string | 分支名称 |
| options.privateToken | string | 密钥 |
返回: Promise.<object>
请求Promise
示例
typescript
getOneBranchDetail({
projectName: 't-comm',
branchName: 'master',
privateToken: 'xxxxx',
}).then((resp) => {
})getOneCommitDetail(options)
描述:
获取commit详情
参数:
| 参数名 | 类型 | 描述 |
|---|---|---|
| options | object | 输入配置 |
| options.projectName | string | 项目名称 |
| options.commitId | string | 提交hash |
| options.privateToken | string | 密钥 |
返回: Promise.<object>
请求Promise
示例
typescript
getOneCommitDetail({
projectName: 't-comm',
commitId: 'aaaa',
privateToken: 'xxxxx',
}).then((resp) => {
})createMR(options)
描述:
创建MR
参数:
| 参数名 | 类型 | 描述 |
|---|---|---|
| options | object | 输入配置 |
| options.projectName | string | 项目名称 |
| options.privateToken | string | 密钥 |
| options.sourceBranch | string | 源分支 |
| options.targetBranch | string | 目标分支 |
返回: Promise.<object>
请求Promise
示例
typescript
createMR({
projectName: 't-comm',
privateToken: 'xxxxx',
sourceBranch: 'master',
targetBranch: 'release',
}).then((resp) => {
})getMrList(options)
描述:
获取MR列表
参数:
| 参数名 | 类型 | 描述 |
|---|---|---|
| options | object | 输入配置 |
| options.projectName | string | 项目名称 |
| options.privateToken | string | 密钥 |
返回: Promise.<object>
请求Promise
示例
typescript
getMrList({
projectName: 't-comm',
privateToken: 'xxxxx',
}).then((resp) => {
})getOneMrComments(options)
描述:
获取MR的一条评论
参数:
| 参数名 | 类型 | 描述 |
|---|---|---|
| options | object | 输入配置 |
| options.projectName | string | 项目名称 |
| options.privateToken | string | 密钥 |
| options.mrId | string | 某次MR的Id |
返回: Promise.<object>
请求Promise
示例
typescript
getOneMrComments({
projectName: 't-comm',
privateToken: 'xxxxx',
mrId: '1'
}).then((resp) => {
})getOneProjectDetail(options)
描述:
获取仓库详情
参数:
| 参数名 | 类型 | 描述 |
|---|---|---|
| options | object | 输入配置 |
| options.projectName | string | 项目名称 |
| options.privateToken | string | 密钥 |
返回: Promise.<object>
请求Promise
示例
typescript
getOneProjectDetail({
projectName: 't-comm',
privateToken: 'xxxxx',
}).then((resp) => {
})getOneProjectBySearch(options)
描述:
通过搜索获取一个项目信息
参数:
| 参数名 | 类型 | 描述 |
|---|---|---|
| options | object | 输入配置 |
| options.search | string | 搜索内容 |
| options.page | string | 起始页码 |
| options.privateToken | string | 密钥 |
返回: Promise.<Array<object>>
请求Promise
示例
typescript
getOneProjectBySearch({
search: 't-comm',
page: 1,
privateToken: 'xxxxx',
}).then((resp) => {
})getAllProjects(privateToken, search)
描述:
获取某个token名下所有项目
参数:
| 参数名 | 类型 | 描述 |
|---|---|---|
| privateToken | string | 密钥 |
| search | string | 搜索内容 |
返回: Array<object>
项目列表
示例
typescript
const projects = await getAllProjects('xxxxx');
console.log(projects)deleteTGitProject(options)
描述:
删除一个项目
参数:
| 参数名 | 类型 | 描述 |
|---|---|---|
| options | object | 输入配置 |
| options.id | string | 项目id |
| options.privateToken | string | 密钥 |
返回: Promise.<Array<object>>
请求Promise
示例
typescript
deleteTGitProject({
id: '123'
privateToken: 'xxxxx',
}).then((resp) => {
})