Compare commits

..

No commits in common. "67d31513c850cd21af21c7d8eba9708d695b60cf" and "84f2cff0a94c99529c5601149b4676869519e0e4" have entirely different histories.

3 changed files with 28 additions and 25 deletions

View File

@ -23,8 +23,8 @@ def run(context: Context):
ProjectInterface(context), ProjectInterface(context),
ProjectProguard(context), ProjectProguard(context),
ProjectBuild(context), ProjectBuild(context),
ProjectUpload(context), # ProjectUpload(context),
ProjectEnd(context), # ProjectEnd(context),
] ]
for task in tasks: for task in tasks:

View File

@ -12,6 +12,8 @@ def progress(op_code, cur_count, max_count=None, message=''):
class ProjectInit(Task): class ProjectInit(Task):
def execute(self): def execute(self):
print("111")
self.context.project_original_path = "/Users/luojian/Documents/project/zicp/Android/GameLauncher"
try: try:
repo = Repo(self.context.project_original_path) repo = Repo(self.context.project_original_path)
except Exception: except Exception:
@ -19,6 +21,7 @@ class ProjectInit(Task):
recursive=True, recursive=True,
progress=progress) progress=progress)
print("112")
# for submodule in repo.submodules: # for submodule in repo.submodules:
# print(f"子模块 '{submodule.name}' 路径: {submodule.path}") # print(f"子模块 '{submodule.name}' 路径: {submodule.path}")
# # print(f"Commit ID: {submodule.module().head.commit}") # # print(f"Commit ID: {submodule.module().head.commit}")
@ -31,37 +34,37 @@ class ProjectInit(Task):
remote_name = "origin" # 远程仓库默认名称 remote_name = "origin" # 远程仓库默认名称
repo.git.fetch(remote_name) # repo.git.fetch(remote_name)
if repo.active_branch.name != branch_name: # if repo.active_branch.name != branch_name:
# 检查本地是否已存在该分支 # # 检查本地是否已存在该分支
if branch_name in repo.heads: # if branch_name in repo.heads:
# 本地分支已存在,直接切换 # # 本地分支已存在,直接切换
repo.heads[branch_name].checkout() # repo.heads[branch_name].checkout()
else: # else:
# 2. 创建本地分支并跟踪远程分支 # # 2. 创建本地分支并跟踪远程分支
remote_branch_ref = f"{remote_name}/{branch_name}" # remote_branch_ref = f"{remote_name}/{branch_name}"
local_branch = repo.create_head(branch_name, remote_branch_ref) # 创建本地分支指向远程 # local_branch = repo.create_head(branch_name, remote_branch_ref) # 创建本地分支指向远程
local_branch.set_tracking_branch(repo.remotes[remote_name].refs[branch_name]) # 设置跟踪 # local_branch.set_tracking_branch(repo.remotes[remote_name].refs[branch_name]) # 设置跟踪
local_branch.checkout() # 切换到该分支 # local_branch.checkout() # 切换到该分支
self.context.local_repo_branch = repo.active_branch.name self.context.local_repo_branch = repo.active_branch.name
self.context.local_repo_commit = repo.head.commit.hexsha[:10] self.context.local_repo_commit = repo.head.commit.hexsha[:10]
# 拉取最新代码 # 拉取最新代码
repo.remotes.origin.pull() # repo.remotes.origin.pull()
print("当前分支:" + repo.active_branch.name) print("当前分支:" + repo.active_branch.name)
pass pass
else: else:
raise Exception(f"No commit to {self.context.repo_commit}") raise Exception(f"No commit to {self.context.repo_commit}")
repo.git.submodule('update', '--init', '--recursive') # repo.git.submodule('update', '--init', '--recursive')
#
for submodule in repo.submodules: # for submodule in repo.submodules:
print(submodule.url) # print(submodule.url)
print(submodule.name) # print(submodule.name)
print(submodule.hexsha) # print(submodule.hexsha)
print(submodule.path) # print(submodule.path)
sub_repo = submodule.module() # sub_repo = submodule.module()
sub_repo.git.reset("--hard", submodule.hexsha) # sub_repo.git.reset("--hard", submodule.hexsha)
print(f"Reset {submodule.name} to {submodule.hexsha[:7]}") # print(f"Reset {submodule.name} to {submodule.hexsha[:7]}")