mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-07-18 16:49:41 +03:00
fix(db-load-git): handle non-XML files (Help HTML) in partial load, fix PY encoding
- Remove .xml/.bsl-only filter — now any changed file (HTML, BSL, etc.) maps to parent object XML + pulls entire Ext/ directory - Fix: ru.html changes without Help.xml in same commit range were silently skipped, leaving help text stale in the database - Fix PY: add encoding="utf-8" to subprocess.run in run_git() — Cyrillic paths were garbled on Windows due to default cp1251 decoding - Bump to v1.3 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# db-load-git v1.2 — Load Git changes into 1C database
|
# db-load-git v1.3 — Load Git changes into 1C database
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
@@ -107,8 +107,8 @@ param(
|
|||||||
$OutputEncoding = [System.Text.Encoding]::UTF8
|
$OutputEncoding = [System.Text.Encoding]::UTF8
|
||||||
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
||||||
|
|
||||||
# --- Helper: map BSL path to object XML ---
|
# --- Helper: map sub-file path (BSL, HTML, etc.) to object XML ---
|
||||||
function Get-ObjectXmlFromBsl {
|
function Get-ObjectXmlFromSubFile {
|
||||||
param([string]$RelativePath)
|
param([string]$RelativePath)
|
||||||
|
|
||||||
$parts = $RelativePath -split '[\\/]'
|
$parts = $RelativePath -split '[\\/]'
|
||||||
@@ -224,40 +224,38 @@ foreach ($file in $changedFiles) {
|
|||||||
# Skip service files
|
# Skip service files
|
||||||
if ($file -eq "ConfigDumpInfo.xml") { continue }
|
if ($file -eq "ConfigDumpInfo.xml") { continue }
|
||||||
|
|
||||||
# Only process .xml and .bsl files
|
$fullPath = Join-Path $ConfigDir $file
|
||||||
if ($file -match '\.(xml|bsl)$') {
|
|
||||||
# Check file exists in config dir
|
if ($file -match '\.xml$') {
|
||||||
$fullPath = Join-Path $ConfigDir $file
|
# XML file — add directly if exists
|
||||||
if ($file -match '\.xml$') {
|
if (Test-Path $fullPath) {
|
||||||
if (Test-Path $fullPath) {
|
if ($configFiles -notcontains $file) {
|
||||||
if ($configFiles -notcontains $file) {
|
$configFiles += $file
|
||||||
$configFiles += $file
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($file -match '\.bsl$') {
|
}
|
||||||
# For BSL: add the BSL itself + parent object XML + all Ext/ files
|
else {
|
||||||
$objectXml = Get-ObjectXmlFromBsl -RelativePath $file
|
# Non-XML (BSL, HTML, etc.) — map to parent object XML + include all Ext/ files
|
||||||
if ($objectXml) {
|
$objectXml = Get-ObjectXmlFromSubFile -RelativePath $file
|
||||||
$fullXmlPath = Join-Path $ConfigDir $objectXml
|
if ($objectXml) {
|
||||||
if (Test-Path $fullXmlPath) {
|
$fullXmlPath = Join-Path $ConfigDir $objectXml
|
||||||
if ($configFiles -notcontains $objectXml) {
|
if (Test-Path $fullXmlPath) {
|
||||||
$configFiles += $objectXml
|
if ($configFiles -notcontains $objectXml) {
|
||||||
}
|
$configFiles += $objectXml
|
||||||
if ($configFiles -notcontains $file) {
|
}
|
||||||
$configFiles += $file
|
if ((Test-Path $fullPath) -and $configFiles -notcontains $file) {
|
||||||
}
|
$configFiles += $file
|
||||||
|
}
|
||||||
|
|
||||||
# Add all files from Ext/ directory of the object
|
# Add all files from Ext/ directory of the object
|
||||||
$parts = $file -split '[\\/]'
|
$parts = $file -split '[\\/]'
|
||||||
if ($parts.Count -ge 2) {
|
if ($parts.Count -ge 2) {
|
||||||
$extDir = Join-Path (Join-Path $ConfigDir $parts[0]) "$($parts[1])\Ext"
|
$extDir = Join-Path (Join-Path $ConfigDir $parts[0]) "$($parts[1])\Ext"
|
||||||
if (Test-Path $extDir) {
|
if (Test-Path $extDir) {
|
||||||
Get-ChildItem -Path $extDir -Recurse -File | ForEach-Object {
|
Get-ChildItem -Path $extDir -Recurse -File | ForEach-Object {
|
||||||
$extRelPath = $_.FullName.Replace("$ConfigDir\", '').Replace('\', '/')
|
$extRelPath = $_.FullName.Replace("$ConfigDir\", '').Replace('\', '/')
|
||||||
if ($configFiles -notcontains $extRelPath) {
|
if ($configFiles -notcontains $extRelPath) {
|
||||||
$configFiles += $extRelPath
|
$configFiles += $extRelPath
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# db-load-git v1.2 — Load Git changes into 1C database
|
# db-load-git v1.3 — Load Git changes into 1C database
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
@@ -33,8 +33,8 @@ def resolve_v8path(v8path):
|
|||||||
return v8path
|
return v8path
|
||||||
|
|
||||||
|
|
||||||
def get_object_xml_from_bsl(relative_path):
|
def get_object_xml_from_subfile(relative_path):
|
||||||
"""Map BSL path to object XML path."""
|
"""Map sub-file path (BSL, HTML, etc.) to object XML path."""
|
||||||
parts = re.split(r"[\\/]", relative_path)
|
parts = re.split(r"[\\/]", relative_path)
|
||||||
if len(parts) >= 2:
|
if len(parts) >= 2:
|
||||||
return f"{parts[0]}/{parts[1]}.xml"
|
return f"{parts[0]}/{parts[1]}.xml"
|
||||||
@@ -47,6 +47,7 @@ def run_git(config_dir, git_args):
|
|||||||
["git"] + git_args,
|
["git"] + git_args,
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True,
|
text=True,
|
||||||
|
encoding="utf-8",
|
||||||
cwd=config_dir,
|
cwd=config_dir,
|
||||||
)
|
)
|
||||||
if result.returncode == 0:
|
if result.returncode == 0:
|
||||||
@@ -155,26 +156,22 @@ def main():
|
|||||||
if file == "ConfigDumpInfo.xml":
|
if file == "ConfigDumpInfo.xml":
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Only process .xml and .bsl files
|
|
||||||
if not re.search(r"\.(xml|bsl)$", file):
|
|
||||||
continue
|
|
||||||
|
|
||||||
# Check file exists in config dir
|
|
||||||
full_path = os.path.join(args.ConfigDir, file)
|
full_path = os.path.join(args.ConfigDir, file)
|
||||||
|
|
||||||
if file.endswith(".xml"):
|
if file.endswith(".xml"):
|
||||||
|
# XML file — add directly if exists
|
||||||
if os.path.exists(full_path):
|
if os.path.exists(full_path):
|
||||||
if file not in config_files:
|
if file not in config_files:
|
||||||
config_files.append(file)
|
config_files.append(file)
|
||||||
elif file.endswith(".bsl"):
|
else:
|
||||||
# For BSL: add the BSL itself + parent object XML + all Ext/ files
|
# Non-XML (BSL, HTML, etc.) — map to parent object XML + include all Ext/ files
|
||||||
object_xml = get_object_xml_from_bsl(file)
|
object_xml = get_object_xml_from_subfile(file)
|
||||||
if object_xml:
|
if object_xml:
|
||||||
full_xml_path = os.path.join(args.ConfigDir, object_xml)
|
full_xml_path = os.path.join(args.ConfigDir, object_xml)
|
||||||
if os.path.exists(full_xml_path):
|
if os.path.exists(full_xml_path):
|
||||||
if object_xml not in config_files:
|
if object_xml not in config_files:
|
||||||
config_files.append(object_xml)
|
config_files.append(object_xml)
|
||||||
if file not in config_files:
|
if os.path.exists(full_path) and file not in config_files:
|
||||||
config_files.append(file)
|
config_files.append(file)
|
||||||
|
|
||||||
# Add all files from Ext/ directory of the object
|
# Add all files from Ext/ directory of the object
|
||||||
@@ -185,7 +182,6 @@ def main():
|
|||||||
for root, dirs, files in os.walk(ext_dir):
|
for root, dirs, files in os.walk(ext_dir):
|
||||||
for fname in files:
|
for fname in files:
|
||||||
abs_path = os.path.join(root, fname)
|
abs_path = os.path.join(root, fname)
|
||||||
# Build relative path from ConfigDir
|
|
||||||
rel_path = os.path.relpath(abs_path, args.ConfigDir).replace("\\", "/")
|
rel_path = os.path.relpath(abs_path, args.ConfigDir).replace("\\", "/")
|
||||||
if rel_path not in config_files:
|
if rel_path not in config_files:
|
||||||
config_files.append(rel_path)
|
config_files.append(rel_path)
|
||||||
|
|||||||
Reference in New Issue
Block a user