2021-02-09 19:30:45 +01:00
|
|
|
#!/bin/powershell
|
2020-12-29 15:14:21 +01:00
|
|
|
<#
|
2021-03-22 20:10:18 +01:00
|
|
|
.SYNTAX ./configure-git.ps1 [<full-name>] [<email-address>] [<favorite-editor>]
|
|
|
|
.DESCRIPTION sets up the Git user configuration
|
|
|
|
.LINK https://github.com/fleschutz/PowerShell
|
|
|
|
.NOTES Author: Markus Fleschutz / License: CC0
|
2020-12-29 15:14:21 +01:00
|
|
|
#>
|
2020-09-29 20:05:52 +02:00
|
|
|
|
2021-02-07 17:31:23 +01:00
|
|
|
param($FullName = "", $EmailAddress = "", $FavoriteEditor = "")
|
|
|
|
|
2021-02-18 20:17:55 +01:00
|
|
|
if ($FullName -eq "") {
|
|
|
|
$FullName = read-host "Enter your full name"
|
|
|
|
}
|
|
|
|
if ($EmailAddress -eq "") {
|
|
|
|
$EmailAddress = read-host "Enter your e-mail address"
|
|
|
|
}
|
|
|
|
if ($FavoriteEditor -eq "") {
|
|
|
|
$FavoriteEditor = read-host "Enter your favorite text editor (emacs,nano,vi,vim,...)"
|
|
|
|
}
|
|
|
|
|
2021-02-02 10:27:54 +01:00
|
|
|
try {
|
2021-02-13 10:26:14 +01:00
|
|
|
& git --version
|
2021-02-02 10:27:54 +01:00
|
|
|
} catch {
|
2021-02-13 10:26:14 +01:00
|
|
|
write-error "Can't execute 'git' - make sure Git is installed and available"
|
2021-02-02 10:27:54 +01:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2020-10-05 13:12:12 +02:00
|
|
|
try {
|
2021-02-13 10:26:14 +01:00
|
|
|
& git config --global user.name $FullName
|
|
|
|
& git config --global user.email $EmailAddress
|
|
|
|
& git config --global core.editor $FavoriteEditor
|
|
|
|
& git config --global http.sslVerify false
|
|
|
|
& git config --global core.autocrlf false
|
|
|
|
& git config --global core.symlinks true
|
2021-02-24 14:13:12 +01:00
|
|
|
& git config --global core.longpaths true
|
2021-02-13 10:26:14 +01:00
|
|
|
& git config --global init.defaultBranch main
|
2021-02-10 19:25:48 +01:00
|
|
|
write-host -foregroundColor green "Done - your Git user configuration is now:"
|
2021-02-13 10:26:14 +01:00
|
|
|
& git config --list
|
2020-10-05 13:12:12 +02:00
|
|
|
exit 0
|
2020-12-09 10:30:55 +01:00
|
|
|
} catch {
|
2021-02-16 10:03:20 +01:00
|
|
|
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
2020-12-09 10:30:55 +01:00
|
|
|
exit 1
|
|
|
|
}
|