fix: 修复PowerShell脚本中的编码问题,确保中文正确显示,并优化输出信息
This commit is contained in:
parent
b874ca43f0
commit
4ac309e732
15
自动同步仓库.ps1
15
自动同步仓库.ps1
@ -6,6 +6,13 @@ param(
|
||||
[switch]$DryRun = $false
|
||||
)
|
||||
|
||||
# 设置控制台编码以正确显示中文
|
||||
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
||||
$OutputEncoding = [System.Text.Encoding]::UTF8
|
||||
|
||||
# 设置Git配置以正确处理中文
|
||||
$env:LC_ALL = "zh_CN.UTF-8"
|
||||
|
||||
function Write-ColorOutput {
|
||||
param(
|
||||
[string]$Message,
|
||||
@ -47,10 +54,10 @@ function Sync-Repositories {
|
||||
}
|
||||
|
||||
# 检查是否有新的提交
|
||||
$upstreamCommits = git log HEAD..upstream/master --oneline
|
||||
$upstreamCommits = & git log HEAD..upstream/master --oneline | ForEach-Object { [System.Text.Encoding]::UTF8.GetString([System.Text.Encoding]::Default.GetBytes($_)) }
|
||||
if ($upstreamCommits) {
|
||||
Write-ColorOutput "发现镜像仓库有新的提交:" "Yellow"
|
||||
Write-ColorOutput $upstreamCommits "Gray"
|
||||
$upstreamCommits | ForEach-Object { Write-ColorOutput $_ "Gray" }
|
||||
|
||||
if ($UseRebase) {
|
||||
Write-ColorOutput "正在使用rebase合并代码..." "Green"
|
||||
@ -90,10 +97,10 @@ function Sync-Repositories {
|
||||
Write-ColorOutput "镜像仓库没有新的提交,检查本地是否有未推送的修改..." "Blue"
|
||||
|
||||
# 检查是否有本地修改需要推送
|
||||
$localCommits = git log origin/master..HEAD --oneline
|
||||
$localCommits = & git log origin/master..HEAD --oneline | ForEach-Object { [System.Text.Encoding]::UTF8.GetString([System.Text.Encoding]::Default.GetBytes($_)) }
|
||||
if ($localCommits) {
|
||||
Write-ColorOutput "发现本地有未推送的修改:" "Yellow"
|
||||
Write-ColorOutput $localCommits "Gray"
|
||||
$localCommits | ForEach-Object { Write-ColorOutput $_ "Gray" }
|
||||
|
||||
Write-ColorOutput ""
|
||||
Write-ColorOutput "下一步操作提示:" "Cyan"
|
||||
|
Loading…
x
Reference in New Issue
Block a user