Explorar o código

sync: 2026-09-30 11:35:19

RuoFeng hai 4 días
pai
achega
6b6589191f
Modificáronse 4 ficheiros con 3 adicións e 1837 borrados
  1. 3 0
      .gitignore
  2. 0 52
      autogit.bat
  3. 0 94
      autogit.json.example
  4. 0 1691
      autogit.py

+ 3 - 0
.gitignore

@@ -1,5 +1,8 @@
 # >>> autogit >>>
 # 由 autogit 自动维护:这些文件含本机路径与访问令牌,绝不能入库。
+autogit.bat
 autogit.json
+autogit.json.example
 autogit.log
+autogit.py
 # <<< autogit <<<

+ 0 - 52
autogit.bat

@@ -1,52 +0,0 @@
-@echo off
-REM ================================================================
-REM  autogit - one-click commit and push (double-click to run)
-REM
-REM  KEEP THIS FILE PURE ASCII. No Chinese, no accents, nothing.
-REM  cmd.exe parses .bat using the OEM code page. A UTF-8 file with
-REM  non-ASCII bytes gets read as mojibake, and a mangled comment line
-REM  can end up being executed as a command.
-REM  Every Chinese message is printed by autogit.py instead.
-REM ================================================================
-
-chcp 65001 >nul 2>nul
-setlocal
-cd /d "%~dp0"
-
-REM Tell python that this .bat owns the final "press any key" pause,
-REM so python does not ask for a key twice.
-set "AUTOGIT_WRAPPED=1"
-
-set "PY="
-
-REM ---- 1) prefer the py launcher, Microsoft's multi-version entry ----
-py -3 -c "import sys;sys.exit(0 if sys.version_info>=(3,8) else 1)" >nul 2>nul
-if not errorlevel 1 set "PY=py -3"
-
-REM ---- 2) fall back to python on PATH ----
-REM WindowsApps\python.exe is the Microsoft Store stub. It exists on
-REM disk but fails unless Python came from the Store, so we must really
-REM run it once instead of just checking that the file is present.
-if not defined PY (
-  python -c "import sys;sys.exit(0 if sys.version_info>=(3,8) else 1)" >nul 2>nul
-  if not errorlevel 1 set "PY=python"
-)
-
-if not defined PY (
-  echo.
-  echo [FAIL] Python 3.8 or newer was not found.
-  echo.
-  echo        Install Python, or make sure "py" or "python" is on PATH.
-  echo        Then run this file again.
-  echo.
-  pause
-  exit /b 9009
-)
-
-%PY% "%~dp0autogit.py" %*
-set "RC=%ERRORLEVEL%"
-
-if not "%RC%"=="0" echo [autogit] exit code %RC%
-echo.
-pause
-exit /b %RC%

+ 0 - 94
autogit.json.example

@@ -1,94 +0,0 @@
-
-{
-  // ==================================================================
-  //  autogit 配置
-  //
-  //  只需要改 repo.url 这一处,其余全都有默认值,不用动。
-  //  (目录里已经配过 remote 的仓库,连 url 都不用填)
-  //
-  //  支持 // 行注释和 /* */ 块注释,写不写都不影响运行。
-  //  ⚠ 文件里可能出现访问令牌,脚本会自动把它写进 .gitignore。
-  // ==================================================================
-
-  "repo": {
-    // 远端仓库地址。留空 = 用仓库现有的 remote 配置
-    // 形如 https://gitee.com/你的用户名/仓库名.git
-    "url": "",
-
-    // 推送到哪条分支。留空 = 跟着仓库当前分支走
-    "branch": "",
-
-    // 远端名。一个仓库挂多个远端才需要改
-    "remote": "origin",
-
-    // 访问令牌(Gitee / GitHub 的私人令牌)
-    // 留空 = 用系统已保存的凭据,首次推送会弹一次登录窗
-    "token": "",
-
-    // 令牌对应的用户名。留空用 oauth2(GitHub 建议填你的用户名)
-    "username": "",
-
-    // 仓库目录。留空 = 脚本所在目录
-    "path": "",
-
-    // 目录还不是 git 仓库时,自动 git init
-    "autoInit": true,
-
-    // 把 url 同步进 git 的 remote 配置
-    "syncRemoteUrl": true
-  },
-
-  "commit": {
-    // 提交信息模板。可用占位符:
-    //   {datetime}  {date}  {time}  {branch}  {remote}  {count}  {dir}
-    "message": "sync: {datetime}",
-
-    // 提交者。留空 = 用 git 的全局配置
-    "name": "",
-    "email": ""
-  },
-
-  "sync": {
-    // 远端有你没有的提交、同时你也有待推送内容时(也就是分叉)怎么办:
-    //   "ask"   问你:y 合并后再推 / n 放弃本次推送     ← 推荐
-    //   "merge" 不问,直接合并
-    //   "abort" 不问,直接放弃
-    "onRemoteAhead": "ask",
-
-    // 合并真的冲突了怎么办:
-    //   "ask"   问你:y 用你本地的文件覆盖 / n 中止合并  ← 推荐
-    //   "ours"  不问,一律用本地文件覆盖
-    //   "abort" 不问,一律中止
-    // 「用本地覆盖」走的是 git merge -s ours:结果文件 100% 是你本地的,
-    // 而远端那几个提交仍然作为历史保留,不会被删。脚本永远不会强推。
-    "onConflict": "ask",
-
-    // 单条 git 网络命令的超时(秒)
-    "timeoutSec": 300,
-
-    // 推送成功后重新问一次远端,确认 SHA 对得上
-    "verifyAfterPush": true
-  },
-
-  "ui": {
-    // 命令行直接跑 python 时,结束是否等回车(双击 .bat 时由 bat 负责)
-    "pauseOnExit": false,
-
-    // 彩色输出:"auto" / "always" / "never"
-    "color": "auto",
-
-    // 日志文件。留空 = 不写日志
-    "logFile": "autogit.log",
-
-    // 日志超过这个大小(KB)就轮转成 .log.1
-    "logSizeKb": 1024
-  },
-
-  "guard": {
-    // 提交前扫描暂存区,这些文件一旦要被提交就中止
-    "blockFiles": ["autogit.json", "autogit.log"],
-
-    // 提交前扫描暂存区内容,发现令牌明文就中止
-    "blockSecret": true
-  }
-}

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 1691
autogit.py