Upload 1.py
Browse files
1.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
|
| 3 |
+
# 定义要克隆的仓库列表和相应的目录名
|
| 4 |
+
repositories = [
|
| 5 |
+
("https://gitcode.net/overbill1683/stablediffusion", "stable-diffusion-stability-ai"),
|
| 6 |
+
("https://gitcode.net/overbill1683/taming-transformers", "taming-transformers"),
|
| 7 |
+
("https://gitcode.net/overbill1683/k-diffusion", "k-diffusion"),
|
| 8 |
+
("https://gitcode.net/overbill1683/CodeFormer", "CodeFormer"),
|
| 9 |
+
("https://gitcode.net/overbill1683/BLIP", "BLIP")
|
| 10 |
+
]
|
| 11 |
+
|
| 12 |
+
def update_repositories():
|
| 13 |
+
workspace_path = "/mnt/workspace/stable-diffusion-webui"
|
| 14 |
+
|
| 15 |
+
# 切换到工作目录
|
| 16 |
+
os.chdir(workspace_path)
|
| 17 |
+
|
| 18 |
+
# 更新主仓库
|
| 19 |
+
os.system("git pull")
|
| 20 |
+
|
| 21 |
+
# 检查并更新子仓库
|
| 22 |
+
os.chdir(os.path.join(workspace_path, "repositories"))
|
| 23 |
+
for repo_url, repo_dir in repositories:
|
| 24 |
+
repo_path = os.path.join(workspace_path, "repositories", repo_dir)
|
| 25 |
+
|
| 26 |
+
if os.path.exists(repo_path):
|
| 27 |
+
# 切换到子仓库目录
|
| 28 |
+
os.chdir(repo_path)
|
| 29 |
+
|
| 30 |
+
# 获取远程仓库的最新信息
|
| 31 |
+
os.system("git fetch")
|
| 32 |
+
|
| 33 |
+
# 检查本地和远程仓库的差异
|
| 34 |
+
diff_output = os.popen("git diff HEAD..origin/master").read().strip()
|
| 35 |
+
|
| 36 |
+
if diff_output:
|
| 37 |
+
# 有更新,拉取最新代码
|
| 38 |
+
os.system("git pull")
|
| 39 |
+
print(f"子仓库 {repo_dir} 更新成功!")
|
| 40 |
+
else:
|
| 41 |
+
print(f"子仓库 {repo_dir} 已经是最新的,无需更新。")
|
| 42 |
+
else:
|
| 43 |
+
# 子仓库不存在,克隆仓库
|
| 44 |
+
os.chdir(workspace_path)
|
| 45 |
+
os.system(f"git clone {repo_url} {repo_dir}")
|
| 46 |
+
print(f"成功克隆子仓库 {repo_dir}!")
|
| 47 |
+
|
| 48 |
+
# 下载配置文件
|
| 49 |
+
os.system("wget -O config.json https://gitcode.net/Akegarasu/sd-webui-configs/-/raw/master/config.json")
|
| 50 |
+
print("配置文件下载成功!")
|
| 51 |
+
|
| 52 |
+
if __name__ == "__main__":
|
| 53 |
+
update_repositories()
|
| 54 |
+
print("主仓库和子仓库更新完成。")
|