Skip to content

Instantly share code, notes, and snippets.

@StefanMaron
Created June 10, 2021 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StefanMaron/29d58eee05fdf32893066bb5494bde3f to your computer and use it in GitHub Desktop.
Save StefanMaron/29d58eee05fdf32893066bb5494bde3f to your computer and use it in GitHub Desktop.
CheckCommitContraints.ps1
$AppJsonFiles = git diff --staged --name-only
$AppJsonFiles | ForEach-Object {
if ($_ -like "*app.json") {
$appJson = git show :$_
$appJson = $appJson | ConvertFrom-Json
$appJsonVersion = [System.Version]$appJson.Version
if ($appJsonVersion.Build -ne 0) {
Throw ("The build number in the file '{0}' must be 0" -f $_)
}
if ($appJsonVersion.Revision -ne 0) {
Throw ("The revision number in the file '{0}' must be 0" -f $_)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment