Modificato script set user e nuovo switch branch:

- Aggiunti input username ed email nella UI di setup-conf.ps1 e salvataggio automatico nel file di configurazione JSON
- Modificato script di settaggio Git user per leggere username/email dal file di configurazione centralizzato (pdca0-config.json)
- Aggiornato switch-branch.bat: ora effettua stash delle modifiche locali prima dello switch, esegue il checkout, fa pull e riapplica lo stash se necessario
- Rinominato set-git-config.ps1 in pdca0-set-git-user.ps1 per maggiore chiarezza
This commit is contained in:
Alessandro Seravalli 2025-07-29 19:16:53 +02:00
parent 8bad382371
commit f93e9eaf69
4 changed files with 75 additions and 9 deletions

View File

@ -14,13 +14,23 @@
.\set-git-config-new.ps1 -Username "Mario Rossi" -Email "mario.rossi@intesasanpaolo.com" -RootDir "C:\Users\MarioRossi\progetti"
#>
# Carica username/email dal file di configurazione se non specificati
$ConfigPath = Resolve-Path (Join-Path $PSScriptRoot '../resources/pdca0-config.json')
if (Test-Path $ConfigPath) {
$configJson = Get-Content $ConfigPath -Raw | ConvertFrom-Json
if (-not $PSBoundParameters.ContainsKey('Username') -and $configJson.PSObject.Properties['username']) {
$Username = $configJson.username
}
if (-not $PSBoundParameters.ContainsKey('Email') -and $configJson.PSObject.Properties['email']) {
$Email = $configJson.email
}
}
param (
[Parameter(Mandatory=$true)]
[Parameter(Mandatory=$false)]
[string]$Username,
[Parameter(Mandatory=$true)]
[Parameter(Mandatory=$false)]
[string]$Email,
[Parameter(Mandatory=$true)]
[string]$RootDir
)
@ -91,7 +101,7 @@ foreach ($dir in $directories) {
Write-Host "Repository trovato: $dirPath" -ForegroundColor Blue
# Imposta la configurazione Git
Set-GitConfig -RepoPath $dirPath -Username $Username -Email $Email
Set-GitConfig -RepoPath $dirPath
$successfulRepos++
}
}

20
cmd/switch-branch.bat Normal file
View File

@ -0,0 +1,20 @@
@echo off
REM Verifica se ci sono modifiche locali
call git diff-index --quiet HEAD --
if %errorlevel% neq 0 (
set STASHED=1
echo Modifiche locali trovate, eseguo stash...
call git stash
) else (
set STASHED=0
)
call git checkout %~1
call git pull
if %STASHED%==1 (
echo Riapplico lo stash...
call git stash pop
)

View File

@ -1,13 +1,15 @@
{
"username": "SERAVALLI ALESSANDRO",
"email": "aseravalli@consulenti.fideuram.it",
"xdce_modules": [
"pdca0-ui",
"xdce-module-arc-v1",
"xdce-module-sost-esg-v1",
"xdce-module-widget-fideuram-v1"
],
"backend_modules": [
"pdca0-arc-v1",
"pdca0-sessionmanager-v1"
"pdca0-sessionmanager-v1",
"pdca0-sost-esg-v1"
],
"core_module": "core-arc-v1",
"core_module": "core-sost-esg-v1",
"deploy_module": "pdca0-deploy-arch"
}

View File

@ -54,6 +54,36 @@ function Show-ConfigForm {
$dictPanel.Anchor = [System.Windows.Forms.AnchorStyles]::Top -bor [System.Windows.Forms.AnchorStyles]::Bottom -bor [System.Windows.Forms.AnchorStyles]::Left -bor [System.Windows.Forms.AnchorStyles]::Right
$mainPanel.Controls.Add($dictPanel, 0, 0)
# --- Input Username ---
$lblUsername = New-Object Windows.Forms.Label
$lblUsername.Text = "Username:"
$lblUsername.Location = New-Object Drawing.Point(10, $y)
$lblUsername.Size = New-Object Drawing.Size(80, 20)
$dictPanel.Controls.Add($lblUsername)
$txtUsername = New-Object Windows.Forms.TextBox
$txtUsername.Location = New-Object Drawing.Point(100, $y)
$txtUsername.Size = New-Object Drawing.Size(200, 20)
if ($json.PSObject.Properties["username"]) { $txtUsername.Text = $json.username }
$dictPanel.Controls.Add($txtUsername)
$controls["username"] = $txtUsername
$y += 28
# --- Input Email ---
$lblEmail = New-Object Windows.Forms.Label
$lblEmail.Text = "Email:"
$lblEmail.Location = New-Object Drawing.Point(10, $y)
$lblEmail.Size = New-Object Drawing.Size(80, 20)
$dictPanel.Controls.Add($lblEmail)
$txtEmail = New-Object Windows.Forms.TextBox
$txtEmail.Location = New-Object Drawing.Point(100, $y)
$txtEmail.Size = New-Object Drawing.Size(200, 20)
if ($json.PSObject.Properties["email"]) { $txtEmail.Text = $json.email }
$dictPanel.Controls.Add($txtEmail)
$controls["email"] = $txtEmail
$y += 28
foreach ($key in $modulesDict.Keys) {
$label = New-Object Windows.Forms.Label
$label.Text = $key
@ -135,6 +165,10 @@ function Show-ConfigForm {
$btnSave.Size = New-Object Drawing.Size(80, 25)
$btnSave.Anchor = [System.Windows.Forms.AnchorStyles]::Bottom -bor [System.Windows.Forms.AnchorStyles]::Right
$btnSave.Add_Click({
# Salva username ed email
$json | Add-Member -MemberType NoteProperty -Name 'username' -Value $controls['username'].Text -Force
$json | Add-Member -MemberType NoteProperty -Name 'email' -Value $controls['email'].Text -Force
foreach ($key in $modulesDict.Keys) {
$controlsForKey = $controls[$key]
if ($controlsForKey[0] -is [Windows.Forms.CheckBox]) {