test
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@kevisual/cnb",
|
"name": "@kevisual/cnb",
|
||||||
"version": "0.0.41",
|
"version": "0.0.43",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"basename": "/root/cnb",
|
"basename": "/root/cnb",
|
||||||
@@ -17,8 +17,8 @@
|
|||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"bin": {
|
"bin": {
|
||||||
"cnb": "./bin/index.js",
|
"cnb": "bin/index.js",
|
||||||
"cloud": "./bin/index.js"
|
"cloud": "bin/index.js"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"dist",
|
"dist",
|
||||||
@@ -74,4 +74,4 @@
|
|||||||
"./src/*": "./src/*",
|
"./src/*": "./src/*",
|
||||||
"./agent/*": "./agent/*"
|
"./agent/*": "./agent/*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# cnb.cool 能做什么
|
# cnb.cool 能做什么
|
||||||
|
|
||||||
|
所有的代码仓库,只基于一个准则 `group/repo`
|
||||||
## 简介
|
## 简介
|
||||||
|
|
||||||
纯粹调用api的模式去使用cnb.cool,自动化方案。
|
纯粹调用api的模式去使用cnb.cool,自动化方案。
|
||||||
|
|||||||
@@ -73,14 +73,14 @@ export class Issue extends CNBCore {
|
|||||||
super(options);
|
super(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
createIssue(repo: string, data: Partial<IssueItem>): Promise<any> {
|
createIssue(repo: string, data: Partial<IssueItem>): Promise<Result<IssueItem>> {
|
||||||
const url = `/${repo}/-/issues`;
|
const url = `/${repo}/-/issues`;
|
||||||
let postData = {
|
let postData = {
|
||||||
...data,
|
...data,
|
||||||
};
|
};
|
||||||
return this.post({ url, data: postData });
|
return this.post({ url, data: postData });
|
||||||
}
|
}
|
||||||
updateIssue(repo: string, issueNumber: string | number, data: Partial<IssueItem>): Promise<any> {
|
updateIssue(repo: string, issueNumber: string | number, data: Partial<IssueItem>): Promise<Result<IssueItem>> {
|
||||||
const url = `/${repo}/-/issues/${issueNumber}`;
|
const url = `/${repo}/-/issues/${issueNumber}`;
|
||||||
let postData = {
|
let postData = {
|
||||||
...data,
|
...data,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { CNBCore, CNBCoreOptions, RequestOptions, Result } from "../cnb-core.ts";
|
import { CNBCore, CNBCoreOptions, RequestOptions, Result } from "../cnb-core.ts";
|
||||||
|
import dayjs from "dayjs";
|
||||||
export class Repo extends CNBCore {
|
export class Repo extends CNBCore {
|
||||||
constructor(options: CNBCoreOptions) {
|
constructor(options: CNBCoreOptions) {
|
||||||
super(options);
|
super(options);
|
||||||
@@ -30,6 +30,12 @@ export class Repo extends CNBCore {
|
|||||||
const url = `/${repo}`;
|
const url = `/${repo}`;
|
||||||
return this.delete({ url });
|
return this.delete({ url });
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 使用cookie创建提交,如果没有指定parent_commit_sha,则会自动获取最新的提交作为父提交
|
||||||
|
* @param repo
|
||||||
|
* @param data
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
async createCommit(repo: string, data: CreateCommitData): Promise<any> {
|
async createCommit(repo: string, data: CreateCommitData): Promise<any> {
|
||||||
const commitList = await this.getCommitList(repo, {
|
const commitList = await this.getCommitList(repo, {
|
||||||
page: 1,
|
page: 1,
|
||||||
@@ -41,6 +47,12 @@ export class Repo extends CNBCore {
|
|||||||
const preCommitSha = commitList.length > 0 ? commitList[0].sha : undefined;
|
const preCommitSha = commitList.length > 0 ? commitList[0].sha : undefined;
|
||||||
if (!data.parent_commit_sha && preCommitSha) {
|
if (!data.parent_commit_sha && preCommitSha) {
|
||||||
data.parent_commit_sha = preCommitSha;
|
data.parent_commit_sha = preCommitSha;
|
||||||
|
} else if (data.parent_commit_sha) {
|
||||||
|
// 如果指定了parent_commi_sha;
|
||||||
|
if (!data.new_branch) {
|
||||||
|
const date = dayjs().format('MMDDHHmm');
|
||||||
|
data.new_branch = `refs/heads/${date}`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const url = `${this.hackURL}/${repo}/-/git/commits`;
|
const url = `${this.hackURL}/${repo}/-/git/commits`;
|
||||||
const postData: CreateCommitData = {
|
const postData: CreateCommitData = {
|
||||||
@@ -52,6 +64,7 @@ export class Repo extends CNBCore {
|
|||||||
new_branch: data.new_branch || 'refs/heads/main',
|
new_branch: data.new_branch || 'refs/heads/main',
|
||||||
};
|
};
|
||||||
if (!postData.parent_commit_sha) {
|
if (!postData.parent_commit_sha) {
|
||||||
|
// 如果没有父提交sha,则说明是第一次提交,可以删除parent_commit_sha和base_branch字段
|
||||||
delete postData.parent_commit_sha;
|
delete postData.parent_commit_sha;
|
||||||
delete postData.base_branch;
|
delete postData.base_branch;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user