Skip to content

Commit 2d9ccd1

Browse files
SyncFileContentsSyncFileContents
authored andcommitted
Sync scripts\PSBuild.psm1
1 parent a0ba3cd commit 2d9ccd1

1 file changed

Lines changed: 20 additions & 10 deletions

File tree

scripts/PSBuild.psm1

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,9 +1214,13 @@ function Update-ProjectMetadata {
12141214
.DESCRIPTION
12151215
Generates and updates version information, license, changelog, and other metadata files for a project.
12161216
This function centralizes all metadata generation to ensure consistency across project documentation.
1217+
1218+
Metadata files are always generated, but commits and pushes are only performed in official repositories
1219+
(not forks). This is controlled by the BuildConfiguration.IsOfficial flag.
12171220
.PARAMETER BuildConfiguration
12181221
The build configuration object containing paths, version info, and GitHub details.
1219-
Should be obtained from Get-BuildConfiguration.
1222+
Should be obtained from Get-BuildConfiguration. The IsOfficial property determines whether
1223+
metadata changes will be committed and pushed.
12201224
.PARAMETER Authors
12211225
Optional array of author names to include in the AUTHORS.md file.
12221226
.PARAMETER CommitMessage
@@ -1315,18 +1319,24 @@ function Update-ProjectMetadata {
13151319
Write-Information "Current commit hash: $currentHash" -Tags "Update-ProjectMetadata"
13161320

13171321
if (-not [string]::IsNullOrWhiteSpace($postStatus)) {
1318-
# Configure git user before committing
1319-
Set-GitIdentity | Write-InformationStream -Tags "Update-ProjectMetadata"
1322+
# Only commit and push metadata changes in official repositories
1323+
if ($BuildConfiguration.IsOfficial) {
1324+
# Configure git user before committing
1325+
Set-GitIdentity | Write-InformationStream -Tags "Update-ProjectMetadata"
13201326

1321-
Write-Information "Committing changes..." -Tags "Update-ProjectMetadata"
1322-
"git commit -m `"$CommitMessage`"" | Invoke-ExpressionWithLogging | Write-InformationStream -Tags "Update-ProjectMetadata"
1327+
Write-Information "Committing changes..." -Tags "Update-ProjectMetadata"
1328+
"git commit -m `"$CommitMessage`"" | Invoke-ExpressionWithLogging | Write-InformationStream -Tags "Update-ProjectMetadata"
13231329

1324-
Write-Information "Pushing changes..." -Tags "Update-ProjectMetadata"
1325-
"git push" | Invoke-ExpressionWithLogging | Write-InformationStream -Tags "Update-ProjectMetadata"
1330+
Write-Information "Pushing changes..." -Tags "Update-ProjectMetadata"
1331+
"git push" | Invoke-ExpressionWithLogging | Write-InformationStream -Tags "Update-ProjectMetadata"
13261332

1327-
Write-Information "Getting release hash..." -Tags "Update-ProjectMetadata"
1328-
$releaseHash = "git rev-parse HEAD" | Invoke-ExpressionWithLogging
1329-
Write-Information "Metadata committed as $releaseHash" -Tags "Update-ProjectMetadata"
1333+
Write-Information "Getting release hash..." -Tags "Update-ProjectMetadata"
1334+
$releaseHash = "git rev-parse HEAD" | Invoke-ExpressionWithLogging
1335+
Write-Information "Metadata committed as $releaseHash" -Tags "Update-ProjectMetadata"
1336+
} else {
1337+
Write-Information "Skipping metadata commit/push (not an official repository)" -Tags "Update-ProjectMetadata"
1338+
$releaseHash = $currentHash
1339+
}
13301340

13311341
Write-Information "Metadata update completed successfully with changes" -Tags "Update-ProjectMetadata"
13321342
Write-Information "Version: $version" -Tags "Update-ProjectMetadata"

0 commit comments

Comments
 (0)