Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 61 additions & 52 deletions .github/workflows/upd-xna-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,75 +98,84 @@ jobs:
$deletedFiles = git diff --diff-filter=D --name-status HEAD~1 HEAD | Where-Object { $_.StartsWith('D') } | ForEach-Object { $_.Substring(1).Trim().Replace('/', '\') }
$deletedFiles += [Environment]::NewLine
$deletedFiles += git diff --diff-filter=R --name-status --diff-filter=R HEAD~1 HEAD | Where-Object { $_.StartsWith('R100') } | ForEach-Object { $_.Substring(4).Trim().Split(' ')[0].Replace('/', '\') }
$deletedFiles = $deletedFiles.Trim().Trim([Environment]::NewLine)

# If exclude is empty, ignore
if ($exclude.Length -ne 0)
# Skip update if there is no deleted files
if ($deletedFiles -eq [String]::Empty)
{
# Clearing delete files from exclude path
$tmp = ""
foreach($delete_file in $deletedFiles)
echo "Delete files list is empty. Skip updating 'updateexec'."
}
else
{
# If exclude is empty, ignore
if ($exclude.Length -ne 0)
{
if ($delete_file.StartsWith($exclude + '\'))
# Clearing delete files from exclude path
$tmp = ""
foreach($delete_file in $deletedFiles)
{
$tmp += ($delete_file.Remove(0, ($exclude.Length + 1)))
$tmp += [Environment]::NewLine
}
else
{
$tmp += $delete_file
$tmp += [Environment]::NewLine
if ($delete_file.StartsWith($exclude + '\'))
{
$tmp += ($delete_file.Remove(0, ($exclude.Length + 1)))
$tmp += [Environment]::NewLine
}
else
{
$tmp += $delete_file
$tmp += [Environment]::NewLine
}
}
$deletedFiles = $tmp
}
$deletedFiles = $tmp
}

# Check if there are any deleted files
if ($deletedFiles.Count -eq 0)
{
echo "No deleted files found in the git diff. Skip updating [Delete] section."
}
else
{
# Read the content of the updateexec file
$updateexecContent_old = Get-Content -Path $updateExecPath
$updateexecContent_new = ""

# Find the [Delete] section and its position
$deleteSectionIndex = $updateexecContent_old.IndexOf("[Delete]")

# If not exist, create
if ($deleteSectionIndex -eq -1)
# Check if there are any deleted files
if ($deletedFiles.Count -eq 0)
{
$updateexecContent_old += [Environment]::NewLine
$updateexecContent_old += "[Delete]"
$deleteSectionIndex = $updateexecContent_old.IndexOf("[Delete]")
echo "No deleted files found in the git diff. Skip updating [Delete] section."
}
else
{
# Read the content of the updateexec file
$updateexecContent_old = Get-Content -Path $updateExecPath
$updateexecContent_new = ""

# Exclude path from string for config
$exclude = "${{ env.CLIENT_PATH }}"
# Find the [Delete] section and its position
$deleteSectionIndex = $updateexecContent_old.IndexOf("[Delete]")

# Iterate all content of old updateexec
foreach($old_line in $updateexecContent_old)
{
$index = $updateexecContent_old.IndexOf($old_line)
$updateexecContent_new += $old_line + [Environment]::NewLine
# If not exist, create
if ($deleteSectionIndex -eq -1)
{
$updateexecContent_old += [Environment]::NewLine
$updateexecContent_old += "[Delete]"
$deleteSectionIndex = $updateexecContent_old.IndexOf("[Delete]")
}

# Exclude path from string for config
$exclude = "${{ env.CLIENT_PATH }}"

# If we find section [Delete], add new deleted files
if ($deleteSectionIndex -eq $index)
# Iterate all content of old updateexec
foreach($old_line in $updateexecContent_old)
{
$updateexecContent_new += "; ${{ steps.download.outputs.tag_name }} (auto-generated entries for removed/renamed files)" + [Environment]::NewLine

foreach($new_delete in $deletedFiles)
$index = $updateexecContent_old.IndexOf($old_line)
$updateexecContent_new += $old_line + [Environment]::NewLine

# If we find section [Delete], add new deleted files
if ($deleteSectionIndex -eq $index)
{
$updateexecContent_new += $new_delete + [Environment]::NewLine
$updateexecContent_new += "; ${{ steps.download.outputs.tag_name }} (auto-generated entries for removed/renamed files)" + [Environment]::NewLine

foreach($new_delete in $deletedFiles)
{
$updateexecContent_new += $new_delete + [Environment]::NewLine
}

$updateexecContent_new += "; end entries" + [Environment]::NewLine + [Environment]::NewLine
}

$updateexecContent_new += "; end entries" + [Environment]::NewLine + [Environment]::NewLine
}
}

# Save the modified content back to the file
$updateexecContent_new | Set-Content -Path $updateExecPath
# Save the modified content back to the file
$updateexecContent_new | Set-Content -Path $updateExecPath
}
}
}

Expand Down