Last active
November 9, 2021 23:49
-
-
Save MichalBrylka/cc6c007ee6950b2e23aaf7d600f17f2e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Create WIP commit message | |
.EXAMPLE | |
.\PutCommitDrivenDevelopmentMessage.ps1 "Implement new important feature" | |
Example output | |
[feature/New-12345 b0d2215] New-12345 Implement new important feature | |
#> | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory = $True)] [ValidateNotNullOrEmpty()] [Alias("m")] [string]$message | |
) | |
$branchName = git branch --show-current | |
if (($LASTEXITCODE -eq 0) -and ($branchName -match '.*?\/?(?<Issue>\w+-\d+)')) { | |
$issue = $Matches. Issue | |
$message = $message.Replace("\`"", "") | |
$commitMessage = "${issue} ${message}" | |
git commit --allow-empty -m "$commitMessage" | |
} | |
else { | |
Write-Error "Not a git repo or invalid branch name" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment