fitlog.fastgit package¶
fastgit(简称 fit) 是 fitlog 的一部分,用于帮助用户进行自动 commit。自动 commit 的文件在 .fitlog 文件夹中,与 .git 文件夹类似。 用户需要使用 fitlog 命令行工具初始化项目,项目默认会生成一个名为 .fitconfig 的配置文件,可以配置监控文件的规则等参数。
fitlog.fastgit.committer module¶
-
class
fitlog.fastgit.committer.
Commit
(commit_id: str, msg: str)[源代码]¶ 基类:
list
Commit 是一个有两个元素的 list,第一个元素是commit-id,第二个元素是commit-message
- 参数
commit_id -- 本次 commit 的 commit-id
msg -- 本次 commit 的 commit-message
- 返回
-
class
fitlog.fastgit.committer.
Info
(status: int, msg: Union[str, fitlog.fastgit.committer.Commit, List[str], List[fitlog.fastgit.committer.Commit]])[源代码]¶ 基类:
dict
Info 是一个dict,有 status 和 msg 两个字段, 用于给返回信息加上状态码
- 参数
status -- 状态码,0表示没有错误
msg -- 返回信息
- 返回
-
class
fitlog.fastgit.committer.
Committer
[源代码]¶ 基类:
object
用于自动 commit 的类,fastgit子模块使用此类实现单例模式。实例化后的对象会记录工作目录,配置文件路径等信息。 对外只暴露有用的接口,内部处理函数的文档请在代码中查看。
-
commit
(file: str, commit_message: str = None) → fitlog.fastgit.committer.Info[源代码]¶ 用户用该方法进行 commit
- 参数
file -- 执行文件路径,期望传入用户程序中的 __file__
commit_message -- 自动 commit 的 commit-message
- 返回
返回带状态码的信息。如果成功,信息为 commit-id
-
get_config
(run_file_path: str = None) → fitlog.fastgit.committer.Info[源代码]¶ 通过执行文件的路径获取配置信息
- 参数
run_file_path -- 执行文件的路径
- 返回
返回带状态码的信息。如果成功,信息为工作目录的路径
-
fitlog_last_commit
() → fitlog.fastgit.committer.Commit[源代码]¶ 返回 self.last_commit 中记录的上一次的commit
- 返回
Commit是一个元组,第一个参数为 commit-id,第二个参数为 commit-message
-
fitlog_commits
() → List[fitlog.fastgit.committer.Commit][源代码]¶ 返回 self.commits 中记录的所有的commit
- 返回
返回一个 Commit 类型的数组
-
static
git_last_commit_info
(work_dir: str) → fitlog.fastgit.committer.Info[源代码]¶ 获取 work_dir 或其祖其先目录上标准 git 的上一次 commit 的信息
- 参数
work_dir -- 工作目录的路径
- 返回
返回带状态码的信息。如果成功,信息为一个 Commit 类型的 commit 信息
-
static
fit_last_commit_info
(work_dir: str) → fitlog.fastgit.committer.Info[源代码]¶ 获取 work_dir 或其祖其先目录上 fitlog 的上一次 commit 信息
- 参数
work_dir -- 工作目录的路径
- 返回
返回带状态码的信息。如果成功,信息为一个 Commit 类型的 commit 信息
-
revert_to_directory
(commit_id: str, path: str, id_suffix: bool)[源代码]¶ 命令行用来回退 fastgit 的一个目标版本到指定放置路径
- 参数
commit_id -- 回退版本的 commit-id
path -- 回退版本的指定放置路径
id_suffix -- 回退版本的放置文件夹是否包含 commit-id 做为后缀
- 返回
-
init_project
(pj_name: str, version: str = 'normal', hide: bool = False, git: bool = True) → int[源代码]¶ 命令行用来初始化一个 fitlog 项目
- 参数
pj_name -- 项目名称
version -- 项目初始化文件夹的版本,目前只有 normal 这一种
hide -- 是否隐藏 .fitconfig 文件到 .fitlog 文件夹中
git -- 是否在初始化 fitlog 的同时为项目初始化 git
- 返回
状态码。0表示正常完成,其它错误码与系统相关
-
short_logs
(show_now: bool = False, last_num: int = None)[源代码]¶ 在命令行用来查看 fastgit 的自带 logs
- 参数
show_now -- 是否显示当前版本在 logs 中的位置
last_num -- 显示最近的 {last_num} 条记录
- 返回
-
fitlog_revert
(commit_id: str, run_file_path: str = None, id_suffix: bool = False) → fitlog.fastgit.committer.Info[源代码]¶ fitlog 调用此接口进行版本回退
- 参数
commit_id -- 需要回退版本的 commit-id
run_file_path -- 执行文件的路径
id_suffix -- 回退版本的放置文件夹是否包含 commit-id 做为后缀
- 返回
返回带状态码的信息。如果成功,信息为回退版本的放置路径
-