Add arguments to configure the git username and email to the updater scripts

This commit is contained in:
Nate McMaster 2017-11-02 09:31:09 -07:00
parent bb8e030aab
commit 7e97adc1c0
3 changed files with 47 additions and 4 deletions

View File

@ -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

View File

@ -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
{

View File

@ -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