mirror of
https://github.com/actions/versions-package-tools.git
synced 2025-12-10 19:50:24 +00:00
Move helpers to the separate repository
This commit is contained in:
81
github/git.psm1
Normal file
81
github/git.psm1
Normal file
@@ -0,0 +1,81 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Configure git credentials to use with commits
|
||||
#>
|
||||
function Git-ConfigureUser {
|
||||
Param (
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string] $Name,
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string] $Email
|
||||
)
|
||||
|
||||
git config --global user.name $Name | Out-Host
|
||||
git config --global user.email $Email | Out-Host
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "##vso[task.logissue type=error;] Unexpected failure occurs while configuring git preferences."
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Create new branch
|
||||
#>
|
||||
function Git-CreateBranch {
|
||||
Param (
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string] $Name
|
||||
)
|
||||
|
||||
git checkout -b $Name | Out-Host
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "##vso[task.logissue type=error;] Unexpected failure occurs while creating new branch: $Name."
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Commit all staged and unstaged changes
|
||||
#>
|
||||
function Git-CommitAllChanges {
|
||||
Param (
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string] $Message
|
||||
)
|
||||
|
||||
git add -A | Out-Host
|
||||
git commit -m "$Message" | Out-Host
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "##vso[task.logissue type=error;] Unexpected failure occurs while commiting changes."
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Push branch to remote repository
|
||||
#>
|
||||
function Git-PushBranch {
|
||||
Param (
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string] $Name,
|
||||
[Parameter(Mandatory=$true)]
|
||||
[boolean] $Force
|
||||
)
|
||||
|
||||
if ($Force) {
|
||||
git push --set-upstream origin $Name --force | Out-Host
|
||||
} else {
|
||||
git push --set-upstream origin $Name | Out-Host
|
||||
}
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "##vso[task.logissue type=error;] Unexpected failure occurs while pushing changes."
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user