t-comm
Version:
专业、稳定、纯粹的工具库
72 lines (71 loc) • 1.95 kB
TypeScript
import type { IGitCommitInfo } from './types';
/**
* 获取当前分支
* @returns {string} 分支名称
*
* @example
*
* getGitCurBranch()
*
* // => master
*/
export declare function getGitCurBranch(root?: string): string;
/**
* 获取提交信息
* @param {string} root 根路径
* @param {boolean} mergeCommit 是否包含 merge 的提交
* @param {boolean} splitMessage 是否去掉提交信息的前缀
* @returns {string} 提交信息
*
* @example
* ```ts
* getGitCommitMessage()
* // '优化一部分文档'
* ```
*/
export declare function getGitCommitMessage(root?: string, mergeCommit?: boolean, splitMessage?: boolean): string;
/**
* 获取提交信息
* @param {string} root 根路径
* @param {boolean} mergeCommit 是否包含 merge 的提交
* @param {boolean} splitMessage 是否去掉提交信息的前缀
* @returns {Object} 提交对象
*
* @example
* ```ts
* getGitCommitInfo()
* {
* author: 'novlan1',
* message: ' 优化一部分文档',
* hash: '0cb71f9',
* date: '2022-10-02 10:34:31 +0800',
* timeStamp: '1664678071',
* branch: 'master'
* }
* ```
*/
export declare function getGitCommitInfo(root?: string, mergeCommit?: boolean, splitMessage?: boolean): IGitCommitInfo;
/**
* 获取最新tag
* @returns {string} 最新tag
*/
export declare function getGitLastTag(root?: string): string;
/**
* 获取tag到head的提交数目
* @param {string} tag git标签
* @returns {string} tag至今的提交数目
*/
export declare function getGitCommitsBeforeTag(tag: string, root?: string): string;
/**
* 获取打标签的时间
* @private
* @param {string} tag git标签
* @returns {string} 标签时间
*/
export declare function getGitTagTime(tag: string, root?: string): string;
/**
* 获取当前用户
* @param isPriorGit - 是否优先使用git用户信息
* @returns user
*/
export declare function getGitAuthor(isPriorGit?: boolean, root?: string): string;