之前已经实现
【已解决】更新generate_md_from_summary:支持git模式
现在遇到问题:
python ../../common/tools/generate_md_from_summary.py -e /Users/xxx/dev/crifan/gitbook/gitbook_template/books/android_app_security_crack/ args.disable_update_existed_md=False args.disable_random_time=False mode=auto entry=/Users/xxx/dev/crifan/gitbook/gitbook_template/books/android_app_security_crack/ isUpdateMdWhenExist=True isRandomUpdateTime=True randomRange=600 mode=git fullGitCmd=cd /Users/xxx/dev/crifan/gitbook/gitbook_template/books/android_app_security_crack/; git status isCheckCmdRunOk=True, cmdResult=位于分支 master 您的分支与上游分支 'origin/master' 一致。 尚未暂存以备提交的变更: (使用 "git add/rm <文件>..." 更新要提交的内容) (使用 "git restore <文件>..." 丢弃工作区的改动) 修改: README.md 修改: README_current.json 修改: book.json 修改: book_current.json 修改: src/README.md 修改: src/SUMMARY.md 修改: src/android_background/related_info/apk_file.md 修改: src/android_background/related_info/dex_file.md 删除: src/android_background/related_info/smali_file.md 修改: src/android_crack_tech/how_remove_shell/check_shell_provider.md 修改: src/android_crack_tool/app_to_dex/README.md 修改: src/android_crack_tool/app_to_dex/dexextractor.md 修改: src/android_crack_tool/app_to_dex/drizzledumper.md 修改: src/android_crack_tool/app_to_dex/fdex2.md 删除: src/android_crack_tool/decompiler/common_decompiler_compare.md 修改: src/android_crack_tool/decompiler/common_decompilers/dare.md 修改: src/android_crack_tool/decompiler/common_decompilers/fernflower.md 修改: src/android_crack_tool/decompiler/common_decompilers/gda.md 修改: src/android_crack_tool/decompiler/common_decompilers/jadx.md 修改: src/android_crack_tool/decompiler/common_decompilers/procyon/README.md 修改: src/android_crack_tool/dex_to_jar/dex2jar.md 修改: src/android_crack_tool/other_assistant_tool/android_debugger/README.md 删除: src/android_crack_tool/other_assistant_tool/android_debugger/andbug.md 删除: src/android_crack_tool/other_assistant_tool/android_debugger/android_opendebug.md 删除: src/android_crack_tool/other_assistant_tool/apk_analyzer.md 删除: src/android_crack_tool/other_assistant_tool/binary_editor/010editor.md 删除: src/android_crack_tool/other_assistant_tool/binary_editor/README.md 删除: src/android_crack_tool/other_assistant_tool/binary_editor/everedit.md 删除: src/android_crack_tool/other_assistant_tool/classshark.md 删除: src/android_crack_tool/other_assistant_tool/fino.md 删除: src/android_crack_tool/other_assistant_tool/introspy_android.md 删除: src/android_crack_tool/other_assistant_tool/redexer.md 删除: src/android_crack_tool/other_assistant_tool/smaliviewer.md 修改: src/android_crack_tool/other_crack_tool/apktool.md 修改: src/android_crack_tool/other_crack_tool/ida.md 修改: src/android_crack_tool/other_crack_tool/radare2.md 删除: src/android_crack_tool/other_crack_tool/smali_baksmali.md 修改: src/android_crack_tool/other_crack_tool/xml_crack/axmlprinter2.md 修改: src/android_crack_tool/other_integrated_tool/README.md 修改: src/android_crack_tool/other_integrated_tool/bytecode_viewer.md 删除: src/android_crack_tool/other_related_tool/android_hook_framework/cydia_substrate.md 修改: src/android_safety_tech/encrypt_overview/harden_method/common_harden_method.md 修改: src/appendix/reference.md 未跟踪的文件: (使用 "git add <文件>..." 以包含要提交的内容) src/android_background/related_info/android_vm/ src/android_background/related_info/smali.md src/android_crack_tool/app_to_dex/dexhunter.md src/android_crack_tool/app_to_dex/fart.md src/android_crack_tool/decompiler/decompiler_cmp/ src/android_crack_tool/other_assistant_tool/apk_analysis/ src/android_crack_tool/other_assistant_tool/binary_edit/ src/android_crack_tool/other_assistant_tool/dynamic_debug/ src/android_crack_tool/other_related_tool/android_hook_framework/cydia_substrate/ src/assets/img/add_shell_tencent_txappentry.jpg src/assets/img/jadx_bin_gui.png src/assets/img/jvm_vs_dvm_compile.png src/assets/img/jvm_vs_dvm_flow.png 修改尚未加入提交(使用 "git add" 和/或 "git commit -a") untrackedFileDictList=[] toUpdatFileDictList=[] toUpdateItemCount=0 Total to update item count: 0
明显是:
不支持。
看来是:git输出的是中文。而不支持。
去加上支持。
common/tools/generate_md_from_summary.py
改动代码:
# for debug
# entry = "/Users/xxx/dev/crifan/gitbook/gitbook_template/books/linux_usage_dev_summary/src/SUMMARY.md"
# entry = "/Users/xxx/dev/crifan/gitbook/gitbook_template/books/android_app_security_crack/"
entry = "/Users/xxx/dev/crifan/gitbook/gitbook_template/books/web_automation_tool_playwright"
(4)中文输出
您的分支与上游分支 'origin/master' 一致。
尚未暂存以备提交的变更:
(使用 "git add/rm <文件>..." 更新要提交的内容)
(使用 "git restore <文件>..." 丢弃工作区的改动)
修改: README.md
修改: README_current.json
修改: book.json
修改: book_current.json
修改: src/README.md
修改: src/SUMMARY.md
修改: src/android_background/related_info/apk_file.md
...
修改: src/android_safety_tech/encrypt_overview/harden_method/common_harden_method.md
修改: src/appendix/reference.md
未跟踪的文件:
(使用 "git add <文件>..." 以包含要提交的内容)
src/android_background/related_info/android_vm/
src/android_background/related_info/smali.md
...
src/assets/img/jvm_vs_dvm_flow.png
修改尚未加入提交(使用 "git add" 和/或 "git commit -a")
(5)中文输出:新git仓库
git status
位于分支 master
尚无提交
未跟踪的文件:
(使用 "git add <文件>..." 以包含要提交的内容)
.gitignore
Makefile
README.md
README_current.json
book.json
book_current.json
node_modules
src/
提交为空,但是存在尚未跟踪的文件(使用 "git add" 建立跟踪)
"""
discardChangeStrEn = "to discard changes in working directory\)"
discardChangeStrZhcn = "丢弃工作区的改动)"
untrackFileStrEn = "Untracked files"
untrackFileStrZhcn = "未跟踪的文件"
addCommitStrEn = "no changes added to commit"
addCommitStrZhcn = "修改尚未加入提交"
# foundNotStagedStr = re.search("to discard changes in working directory\)\s+(?P<notStagedStr>.+?)\s+((Untracked files:)|(no changes added to commit))", cmdResult, flags=re.S)
# notStagePatternStr = "((%s)|(%s))\)\s+(?P<notStagedStr>.+?)\s+((((%s)|(%s)):)|(((%s)|(%s))))" % (discardChangeStrEn, discardChangeStrZhcn, untrackFileStrEn, untrackFileStrZhcn, addCommitStrEn, addCommitStrZhcn)
notStagePatternStr = "((%s)|(%s))\s+(?P<notStagedStr>.+?)\s+((((%s)|(%s)):)|(((%s)|(%s))))" % (discardChangeStrEn, discardChangeStrZhcn, untrackFileStrEn, untrackFileStrZhcn, addCommitStrEn, addCommitStrZhcn)
print("notStagePatternStr=%s" % notStagePatternStr)
foundNotStagedStr = re.search(notStagePatternStr, cmdResult, flags=re.S)
for eachNotStageStr in notStagedLineList:
modifyStrEn = "modified:"
modifyStrZhcn = "修改:"
deletedStrEn = "deleted:"
deletedStrZhcn = "删除:"
# foundFile = re.search("\t(?P<action>(modified)|(deleted)):\s+(?P<filePath>\S+)$", eachNotStageStr)
actionFilePatternStr = "\t?(?P<action>(((%s)|(%s)))|(((%s)|(%s))))\s+(?P<filePath>\S+)$" % (modifyStrEn, modifyStrZhcn, deletedStrEn, deletedStrZhcn)
print("actionFilePatternStr=%s" % actionFilePatternStr)
foundFile = re.search(actionFilePatternStr, eachNotStageStr)
includeCommitedStrEn = "to include in what will be committed\)"
includeCommitedStrZhcn = "以包含要提交的内容)"
commitEmptyStrEn = "nothing added to commit but untracked files present"
commitEmptyStrZhcn = "提交为空,但是存在尚未跟踪的文件"
# foundUntrackedStr = re.search("to include in what will be committed\)\s+(?P<untrackedStr>.+?)\s+no changes added to commit", cmdResult, flags=re.S)
untrackedPatternStr = "((%s)|(%s))\s+(?P<untrackedStr>.+?)\s+((%s)|(%s)|(%s)|(%s))" % (includeCommitedStrEn, includeCommitedStrZhcn, addCommitStrEn, addCommitStrZhcn, commitEmptyStrEn , commitEmptyStrZhcn)
print("untrackedPatternStr=%s" % untrackedPatternStr)
foundUntrackedStr = re.search(untrackedPatternStr, cmdResult, flags=re.S)
# foundUntrackedFile = re.search("\t?(?P<untrackedFile>src/.+)$", eachUntrackedLine)
foundUntrackedFile = re.search("\t?(?P<untrackedFile>src/.*)$", eachUntrackedLine)
# "action": "added",
"action": "added:",
# isModified = curAction == "modified"
# isAdded = curAction == "added"
# isDeleted = curAction == "deleted"
isModified = (curAction == "modified:") or (curAction == "修改:")
isAdded = (curAction == "added:") or (curAction == "新增:")
isDeleted = (curAction == "deleted") or (curAction == "删除:")即可支持:
已提交过的git的,有改动的文件
和
未提交过的,新的git仓库的文件
另外,顺带再去支持:
输入 . 表示当前目录
调试
python ../../common/tools/generate_md_from_summary.py -e .
代码:
entry = os.path.abspath(entry)
print("entry=%s" % entry)可以输出:
entry=/Users/xxx/dev/crifan/gitbook/gitbook_template/books/web_automation_tool_playwright
-》自动就支持了。
最新代码详见: