Explorar o código

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

Nate McMaster %!s(int64=8) %!d(string=hai) anos
pai
achega
7e97adc1c0
Modificáronse 3 ficheiros con 47 adicións e 4 borrados
  1. 17 1
      scripts/UpdateBuildTools.ps1
  2. 15 2
      scripts/UpdateRepos.ps1
  3. 15 1
      scripts/UpdateSubmodules.ps1

+ 17 - 1
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

+ 15 - 2
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 = "[email protected]: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
             {

+ 15 - 1
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