mirror of
https://github.com/wess09/AzurLaneAutoScript.git
synced 2026-05-14 06:38:38 +08:00
1212312
This commit is contained in:
parent
b49bb215ef
commit
748b669ddf
@ -143,6 +143,10 @@ class GitManager(DeployConfig):
|
||||
else:
|
||||
if not self.git_config.check('http', 'sslVerify', value='false'):
|
||||
self.execute(f'"{self.git}" config --local http.sslVerify false', allow_failure=True)
|
||||
|
||||
logger.hr('Set Git User-Agent', 1)
|
||||
self.execute(f'"{self.git}" config http.userAgent "ALAS/1.5.8 AzurPilot"')
|
||||
|
||||
Progress.GitSetConfig()
|
||||
|
||||
logger.hr('Set Git Repository', 1)
|
||||
@ -210,23 +214,21 @@ class GitManager(DeployConfig):
|
||||
Resolve 307 redirects from git.nanoda.work to get the actual git repository URL.
|
||||
"""
|
||||
if 'git.nanoda.work' in url:
|
||||
import requests
|
||||
logger.info(f'Resolving repository URL: {url}')
|
||||
try:
|
||||
# Catch 307 redirect
|
||||
import requests
|
||||
headers = {'User-Agent': 'alas AzurPilot'}
|
||||
logger.info(f'Resolving repository URL: {url}')
|
||||
# Follow all redirects to get the final destination
|
||||
response = requests.get(
|
||||
url,
|
||||
allow_redirects=False,
|
||||
allow_redirects=True,
|
||||
timeout=10,
|
||||
headers={'User-Agent': 'ALAS/1.5.8 AzurPilot'}
|
||||
headers=headers
|
||||
)
|
||||
if response.status_code in [302, 307]:
|
||||
new_url = response.headers.get('Location')
|
||||
if new_url:
|
||||
# Strip .git suffix for consistency
|
||||
new_url = new_url.replace('.git', '')
|
||||
logger.info(f'Resolved {url} to {new_url}')
|
||||
return new_url
|
||||
if response.status_code == 200:
|
||||
resolved = response.url.rstrip('/')
|
||||
logger.info(f'Resolved {url} to {resolved}')
|
||||
return resolved
|
||||
return url
|
||||
except Exception as e:
|
||||
logger.error(f'Failed to resolve {url}: {e}')
|
||||
@ -243,10 +245,6 @@ class GitManager(DeployConfig):
|
||||
# Resolve repository URL before any git operations
|
||||
repo = self.resolve_repository_url(self.Repository)
|
||||
|
||||
if self.GitOverCdn:
|
||||
if self.goc_client.update(keep_changes=self.KeepLocalChanges):
|
||||
return
|
||||
|
||||
self.git_repository_init(
|
||||
repo=repo,
|
||||
source='origin',
|
||||
|
||||
@ -108,6 +108,9 @@ class GitManager(DeployConfig):
|
||||
else:
|
||||
self.execute(f'"{self.git}" config --local http.sslVerify false', allow_failure=True)
|
||||
|
||||
logger.hr('Set Git User-Agent', 1)
|
||||
self.execute(f'"{self.git}" config http.userAgent "ALAS/1.5.8 AzurPilot"')
|
||||
|
||||
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}"')
|
||||
@ -169,21 +172,19 @@ class GitManager(DeployConfig):
|
||||
if 'git.nanoda.work' in url:
|
||||
try:
|
||||
import requests
|
||||
headers = {'User-Agent': 'alas AzurPilot'}
|
||||
logger.info(f'Resolving repository URL: {url}')
|
||||
# Catch 307 redirect
|
||||
# Follow all redirects to get the final destination
|
||||
response = requests.get(
|
||||
url,
|
||||
allow_redirects=False,
|
||||
allow_redirects=True,
|
||||
timeout=10,
|
||||
headers={'User-Agent': 'ALAS/1.5.8 AzurPilot'}
|
||||
headers=headers
|
||||
)
|
||||
if response.status_code in [302, 307]:
|
||||
new_url = response.headers.get('Location')
|
||||
if new_url:
|
||||
# Strip .git suffix for consistency
|
||||
new_url = new_url.replace('.git', '')
|
||||
logger.info(f'Resolved {url} to {new_url}')
|
||||
return new_url
|
||||
if response.status_code == 200:
|
||||
resolved = response.url.rstrip('/')
|
||||
logger.info(f'Resolved {url} to {resolved}')
|
||||
return resolved
|
||||
return url
|
||||
except Exception as e:
|
||||
logger.error(f'Failed to resolve {url}: {e}')
|
||||
|
||||
@ -86,7 +86,7 @@ class ApiClient:
|
||||
endpoint,
|
||||
params=params,
|
||||
timeout=timeout,
|
||||
headers={'User-Agent': 'ALAS/1.5.8 AzurPilot'}
|
||||
headers={'User-Agent': 'alas AzurPilot'}
|
||||
)
|
||||
else:
|
||||
response = requests.post(
|
||||
@ -95,7 +95,7 @@ class ApiClient:
|
||||
timeout=timeout,
|
||||
headers={
|
||||
'Content-Type': 'application/json',
|
||||
'User-Agent': 'ALAS/1.5.8 AzurPilot'
|
||||
'User-Agent': 'alas AzurPilot'
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user