forked from PoshCode/PSGit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGet-Version.ps1
29 lines (26 loc) · 1.02 KB
/
Get-Version.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#.Synopsis
# Calculate the build number.
param(
$Module,
# If set, override the module's revision
[Nullable[int]]$RevisionNumber
)
[Version]$Version = if(Test-Path $Module -Type Leaf) {
(Import-LocalizedData -BaseDirectory (Split-Path $Module) -FileName (Split-Path ${Module} -Leaf)).ModuleVersion
} elseif(Test-Path $Module -Type Container) {
(Import-LocalizedData -BaseDirectory $Module -FileName "$(Split-Path ${Module} -Leaf).psd1").ModuleVersion
} else {
Get-Module $Module -List | Select -First 1 -Expand Version
}
if($RevisionNumber) {
# For release builds we don't increment the build number
$Build = if($Version.Build -le 0) { 0 } else { $Version.Build }
} else {
# For dev builds, assume we're working on the NEXT release
$Build = if($Version.Build -le 0) { 1 } else { $Version.Build + 1}
}
if([string]::IsNullOrEmpty($RevisionNumber)) {
New-Object Version $Version.Major, $Version.Minor, $Build
} else {
New-Object Version $Version.Major, $Version.Minor, $Build, $RevisionNumber
}