diff --git a/scripts/UpdateBuildTools.ps1 b/scripts/UpdateBuildTools.ps1 index 0308041774..6452aca990 100755 --- a/scripts/UpdateBuildTools.ps1 +++ b/scripts/UpdateBuildTools.ps1 @@ -5,6 +5,10 @@ Updates the build tools version and generates a commit message with the list of changes .PARAMETER RepoRoot The directory containing the repo +.PARAMETER GitAuthorName + The author name to use in the commit message. (Optional) +.PARAMETER GitAuthorEmail + The author email to use in the commit message. (Optional) .PARAMETER GitCommitArgs Additional arguments to pass into git-commit .PARAMETER NoCommit @@ -15,6 +19,8 @@ [cmdletbinding(SupportsShouldProcess = $true)] param( [string]$RepoRoot, + [string]$GitAuthorName = $null, + [string]$GitAuthorEmail = $null, [string[]]$GitCommitArgs = @(), [switch]$NoCommit, [switch]$Force @@ -76,7 +82,17 @@ try { $message = "$shortMessage`n`n[auto-updated: buildtools]" if (-not $NoCommit -and ($Force -or ($PSCmdlet.ShouldContinue($shortMessage, 'Create a new commit with these changes?')))) { - Invoke-Block { git commit -m $message @GitCommitArgs } + + $gitConfigArgs = @() + if ($GitAuthorName) { + $gitConfigArgs += '-c',"user.name=$GitAuthorName" + } + + if ($GitAuthorEmail) { + $gitConfigArgs += '-c',"user.email=$GitAuthorEmail" + } + + Invoke-Block { git @gitConfigArgs commit -m $message @GitCommitArgs } } else { # If composing this script with others, return the message that would have been used diff --git a/scripts/UpdateRepos.ps1 b/scripts/UpdateRepos.ps1 index 9fe5ec896a..aa97531925 100755 --- a/scripts/UpdateRepos.ps1 +++ b/scripts/UpdateRepos.ps1 @@ -9,6 +9,10 @@ The ID of the Lineup to determine which versions to use. .PARAMETER LineupVersion The version of the Lineup to be used. +.PARAMETER GitAuthorName + The author name to use in the commit message. (Optional) +.PARAMETER GitAuthorEmail + The author email to use in the commit message. (Optional) .PARAMETER NoPush Make commits without pusing. #> @@ -32,6 +36,15 @@ Import-Module "$PSScriptRoot/common.psm1" -Scope Local -Force $RepoRoot = Resolve-Path "$PSScriptRoot\.." $ModuleDirectory = Join-Path $RepoRoot "modules" +$gitConfigArgs = @() +if ($GitAuthorName) { + $gitConfigArgs += '-c',"user.name=$GitAuthorName" +} + +if ($GitAuthorEmail) { + $gitConfigArgs += '-c',"user.email=$GitAuthorEmail" +} + Push-Location $ModuleDirectory try { # Init all submodules @@ -58,7 +71,7 @@ try { Invoke-Block { & .\run.ps1 -Update upgrade deps --source $Source --id $LineupID --version $LineupVersion --deps-file $depsFile } Invoke-Block { & git add $depsFile } - Invoke-Block { & git commit --quiet -m "Update dependencies.props`n`n[auto-updated: dependencies]" @GitCommitArgs } + Invoke-Block { & git @gitConfigArgs commit --quiet -m "Update dependencies.props`n`n[auto-updated: dependencies]" @GitCommitArgs } $sshUrl = "git@github.com:aspnet/$($submodule.module)" Invoke-Block { & git remote set-url --push origin $sshUrl } $updated_submodules += $submodule @@ -84,7 +97,7 @@ try { { Push-Location $submodule.path try { - Invoke-Block { & git push origin $submodule.branch} + Invoke-Block { & git @gitConfigArgs push origin $submodule.branch} } catch { diff --git a/scripts/UpdateSubmodules.ps1 b/scripts/UpdateSubmodules.ps1 index 5a64ed2006..974d69c66d 100755 --- a/scripts/UpdateSubmodules.ps1 +++ b/scripts/UpdateSubmodules.ps1 @@ -3,6 +3,10 @@ <# .SYNOPSIS Updates git submodules and generates a commit message with the list of changes +.PARAMETER GitAuthorName + The author name to use in the commit message. (Optional) +.PARAMETER GitAuthorEmail + The author email to use in the commit message. (Optional) .PARAMETER GitCommitArgs Additional arguments to pass into git-commit .PARAMETER NoCommit @@ -98,7 +102,17 @@ try { # add this to the commit message to make it possible to filter commit triggers based on message $message = "$shortMessage`n`n[auto-updated: submodules]" if (-not $NoCommit -and ($Force -or ($PSCmdlet.ShouldContinue($shortMessage, 'Create a new commit with these changes?')))) { - Invoke-Block { & git commit -m $message @GitCommitArgs } + + $gitConfigArgs = @() + if ($GitAuthorName) { + $gitConfigArgs += '-c',"user.name=$GitAuthorName" + } + + if ($GitAuthorEmail) { + $gitConfigArgs += '-c',"user.email=$GitAuthorEmail" + } + + Invoke-Block { & git @gitConfigArgs commit -m $message @GitCommitArgs } } else { # If composing this script with others, return the message that would have been used