代码拉取完成,页面将自动刷新
同步操作将从 LmeSzinc/AzurLaneAutoScript 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
from deploy.config import DeployConfig
from deploy.git_over_cdn.client import GitOverCdnClient
from deploy.logger import logger
from deploy.utils import *
class GitManager(DeployConfig):
@cached_property
def git(self):
exe = self.filepath('GitExecutable')
if os.path.exists(exe):
return exe
logger.warning(f'GitExecutable: {exe} does not exist, use `git` instead')
return 'git'
@staticmethod
def remove(file):
try:
os.remove(file)
logger.info(f'Removed file: {file}')
except FileNotFoundError:
logger.info(f'File not found: {file}')
def git_repository_init(
self, repo, source='origin', branch='master',
proxy='', ssl_verify=True, keep_changes=False
):
logger.hr('Git Init', 1)
if not self.execute(f'"{self.git}" init', allow_failure=True):
self.remove('./.git/config')
self.remove('./.git/index')
self.remove('./.git/HEAD')
self.execute(f'"{self.git}" init')
logger.hr('Set Git Proxy', 1)
if proxy:
self.execute(f'"{self.git}" config --local http.proxy {proxy}')
self.execute(f'"{self.git}" config --local https.proxy {proxy}')
else:
self.execute(f'"{self.git}" config --local --unset http.proxy', allow_failure=True)
self.execute(f'"{self.git}" config --local --unset https.proxy', allow_failure=True)
if ssl_verify:
self.execute(f'"{self.git}" config --local http.sslVerify true', allow_failure=True)
else:
self.execute(f'"{self.git}" config --local http.sslVerify false', allow_failure=True)
logger.hr('Set Git Repository', 1)
if not self.execute(f'"{self.git}" remote set-url {source} {repo}', allow_failure=True):
self.execute(f'"{self.git}" remote add {source} {repo}')
logger.hr('Fetch Repository Branch', 1)
self.execute(f'"{self.git}" fetch {source} {branch}')
logger.hr('Pull Repository Branch', 1)
# Remove git lock
for lock_file in [
'./.git/index.lock',
'./.git/HEAD.lock',
'./.git/refs/heads/master.lock',
]:
if os.path.exists(lock_file):
logger.info(f'Lock file {lock_file} exists, removing')
os.remove(lock_file)
if keep_changes:
if self.execute(f'"{self.git}" stash', allow_failure=True):
self.execute(f'"{self.git}" pull --ff-only {source} {branch}')
if self.execute(f'"{self.git}" stash pop', allow_failure=True):
pass
else:
# No local changes to existing files, untracked files not included
logger.info('Stash pop failed, there seems to be no local changes, skip instead')
else:
logger.info('Stash failed, this may be the first installation, drop changes instead')
self.execute(f'"{self.git}" reset --hard {source}/{branch}')
self.execute(f'"{self.git}" pull --ff-only {source} {branch}')
else:
self.execute(f'"{self.git}" reset --hard {source}/{branch}')
self.execute(f'"{self.git}" pull --ff-only {source} {branch}')
logger.hr('Show Version', 1)
self.execute(f'"{self.git}" --no-pager log --no-merges -1')
@property
def goc_client(self):
client = GitOverCdnClient(
url='https://vip.123pan.cn/1818706573/pack/LmeSzinc_AzurLaneAutoScript_master',
folder=self.root_filepath,
source='origin',
branch='master',
git=self.git,
)
client.logger = logger
return client
def git_install(self):
logger.hr('Update Alas', 0)
if not self.AutoUpdate:
logger.info('AutoUpdate is disabled, skip')
return
if self.GitOverCdn:
if self.goc_client.update(keep_changes=self.KeepLocalChanges):
return
self.git_repository_init(
repo=self.Repository,
source='origin',
branch=self.Branch,
proxy=self.GitProxy,
ssl_verify=self.SSLVerify,
keep_changes=self.KeepLocalChanges,
)
if __name__ == '__main__':
self = GitManager()
self.goc_client.get_status()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。