@weshare/crd
Version:
50 lines (49 loc) • 1.74 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
// import NodeGit from 'nodegit'
// const GIT_COMMIT_PATH = path.join(process.cwd(), './.git/')
// let repo: NodeGit.Repository
// async function getRepo() {
// if(!repo) {
// repo = await NodeGit.Repository.open(GIT_COMMIT_PATH)
// }
// return repo
// }
// export const getFullSha = async (repo: NodeGit.Repository, commitId: string) => {
// const annotatedCommit = await NodeGit.AnnotatedCommit.fromRevspec(repo, commitId)
// return annotatedCommit.id();
// }
// export const getCurrentBranch = async () => {
// const repo = await getRepo()
// const currentBranch = await repo.getCurrentBranch()
// return currentBranch.shorthand()
// }
// export const getCommitDetail = async (commitId?: string) => {
// const repo = await getRepo()
// const walker = NodeGit.Revwalk.create(repo)
// let commit: NodeGit.Commit
// if(commitId) {
// const fullId = await getFullSha(repo, commitId)
// commit = await repo.getCommit(fullId)
// } else {
// const branch = await repo.getCurrentBranch()
// walker.pushRef(branch.name())
// commit = (await walker.getCommits(1))[0]
// }
// return {
// commitId: commit.id().tostrS(),
// commitMsg: commit.message().trim(),
// time: commit.date(),
// submitter: commit.author().name(),
// }
// }
// export const getCommitDetail = async (commitId?: string) => {
// // const repo =
// if(commitId) {
// commitId = await getLongShaByShort(commitId)
// } else {
// const branch = await repo.getCurrentBranch()
// walker.pushRef(branch.name())
// commit = (await walker.getCommits(1))[0]
// }
// }