init: 博特维采购订单系统 v1.0 源码
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Init local git repo + commit source (respecting .gitignore) using dulwich.
|
||||
No network/credentials needed. Push happens separately once remote URL+token are known.
|
||||
"""
|
||||
import os, sys
|
||||
from dulwich import porcelain
|
||||
from dulwich.repo import Repo
|
||||
|
||||
ROOT = r"D:\2026-09-09-task-18"
|
||||
GITDIR = os.path.join(ROOT, ".git")
|
||||
|
||||
# 1) init (skip if already a repo)
|
||||
if os.path.exists(GITDIR):
|
||||
print("repo already exists, reusing")
|
||||
repo = Repo(GITDIR)
|
||||
else:
|
||||
repo = porcelain.init(ROOT)
|
||||
print("repo initialized at", GITDIR)
|
||||
|
||||
# 2) stage everything; dulwich add honors .gitignore via ignore manager
|
||||
porcelain.add(repo, [ROOT])
|
||||
print("staged files (count):", len(repo.open_index()))
|
||||
|
||||
# 3) show what got staged (verify no db / dist / backups)
|
||||
staged = list(repo.open_index())
|
||||
bad = [p for p in staged if
|
||||
p.endswith(b".db") or b"\\dist\\" in p or p.startswith(b"dist/") or
|
||||
b"dist_backup" in p or b"\\instance\\" in p or b"/instance/" in p or
|
||||
p.startswith(b".workbuddy")]
|
||||
print("SUSPECT_STAGED:", [p.decode("utf-8","replace") for p in bad])
|
||||
|
||||
if bad:
|
||||
print("ABORT: ignored files would be committed; fix .gitignore")
|
||||
sys.exit(2)
|
||||
|
||||
# 4) commit (with identity)
|
||||
porcelain.commit(repo,
|
||||
message=b"init: \xe5\x8d\x9a\xe7\x89\xb9\xe7\xbb\xb4\xe9\x87\x87\xe8\xb4\xad\xe8\xae\xa2\xe5\x8d\x95\xe7\xb3\xbb\xe7\xbb\x9f v1.0 \xe6\xba\x90\xe7\xa0\x81",
|
||||
author=b"star <star@btw-ocr.com>",
|
||||
committer=b"star <star@btw-ocr.com>")
|
||||
print("COMMITTED. HEAD:", repo.head().decode())
|
||||
|
||||
# 5) report tracked file list
|
||||
tracked = []
|
||||
for e in repo.open_index().iteritems():
|
||||
tracked.append(e[0].decode("utf-8","replace"))
|
||||
print("TRACKED_FILES:")
|
||||
for f in sorted(tracked):
|
||||
print(" ", f)
|
||||
Reference in New Issue
Block a user