@@ -48,6 +48,8 @@ Begin {
48
48
# name of GPO that will be used for connecting computers to this solution
49
49
$GPOname = ' PS_env_set_up'
50
50
51
+ $userRepositoryWasntEmpty = $false
52
+
51
53
# hardcoded PATHs for TEST installation
52
54
$remoteRepository = " $env: SystemDrive \myCompanyRepository_remote"
53
55
# endregion Variables
@@ -1398,6 +1400,9 @@ Your input will be stored to '$iniFile'. So next time you start this script, its
1398
1400
_unsetVariable userRepository
1399
1401
_setVariable userRepository " path to ROOT of your locally cloned repository '$repositoryURL '"
1400
1402
}
1403
+
1404
+ # make a note whether cloned repository is brand new or was already set up
1405
+ $userRepositoryWasntEmpty = Test-Path " $userRepository \Custom\Repo_Sync\Repo_Sync.ps1" - ErrorAction SilentlyContinue
1401
1406
} else {
1402
1407
$userRepository = " $env: SystemDrive \myCompanyRepository"
1403
1408
@@ -1442,7 +1447,7 @@ Your input will be stored to '$iniFile'. So next time you start this script, its
1442
1447
$userDomain = " $env: COMPUTERNAME .com"
1443
1448
}
1444
1449
Write-Host " - Configuring repository '$userRepository '" - ForegroundColor Green
1445
- " - activating GIT Hooks, creating symlink for PowerShell snippets, commiting&pushing changes, etc"
1450
+ " - activating GIT Hooks, creating symlink for PowerShell snippets, commiting&pushing changes (if new repository) , etc"
1446
1451
1447
1452
if ($testInstallation -or (! $noEnvModification -and ! (_skip))) {
1448
1453
$currPath = Get-Location
@@ -1475,9 +1480,16 @@ Your input will be stored to '$iniFile'. So next time you start this script, its
1475
1480
1476
1481
# commit without using hooks, to avoid possible problem with checks (because of wrong encoding, missing PSScriptAnalyzer etc), that could stop it
1477
1482
" - commiting & pushing changes to repository $repositoryURL "
1478
- $null = git add .
1479
- $null = _startProcess git " commit --no-verify -m initial" - outputErr2Std - dontWait
1480
- $null = _startProcess git " push --no-verify" - outputErr2Std
1483
+ if ($testInstallation -or ! $userRepositoryWasntEmpty ) {
1484
+ # user repo was empty before my customized content was copied to it or this is TEST installation
1485
+ # it is safe to automatically do commit&push
1486
+ $null = git add .
1487
+ $null = _startProcess git " commit --no-verify -m initial" - outputErr2Std - dontWait
1488
+ $null = _startProcess git " push --no-verify" - outputErr2Std
1489
+ } else {
1490
+ Write-Warning " Skipped.`n`n Your repository wasn't empty before customized content was copied a.k.a. some of your content could be lost. Check manually changed files (in VSC 'Source Control' tab) and commit&push just safe changes before continue!"
1491
+ _pressKeyToContinue
1492
+ }
1481
1493
1482
1494
" - activating GIT hooks for automation of checks, git push etc"
1483
1495
$null = _startProcess git ' config core.hooksPath ".\.githooks"'
0 commit comments