Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
auto-tx
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vamp
auto-tx
Commits
818db607
Commit
818db607
authored
7 years ago
by
Niko Ehrenfeuchter
Browse files
Options
Downloads
Patches
Plain Diff
Parse version numbers from "git describe" output.
parent
d93d8a85
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Scripts/Prepare-Build.ps1
+32
-10
32 additions, 10 deletions
Scripts/Prepare-Build.ps1
with
32 additions
and
10 deletions
Scripts/Prepare-Build.ps1
+
32
−
10
View file @
818db607
...
...
@@ -9,7 +9,7 @@ function Write-BuildDetails {
[
String
]
$Target
,
[
Parameter
(
Mandatory
=
$True
)]
[
String
]
$CommitName
,
[
Array
]
$Desc
,
[
Parameter
(
Mandatory
=
$True
)]
[
String
]
$Branch
,
...
...
@@ -18,37 +18,59 @@ function Write-BuildDetails {
[
String
]
$Date
)
$CommitName
=
"
$(
$Desc
[
0
]
)
.
$(
$Desc
[
1
]
)
-
$(
$Desc
[
2
]
)
-
$(
$Desc
[
3
]
)
"
Write-Output
"Generating [
$(
$Target
)
]..."
Write-Output
$
(
"
Write-Output
" >
$(
$CommitName
)
"
$CSharp
=
$
(
"
public static class BuildDetails
{
public const string GitCommitName =
`"
$(
$CommitName
)
`"
;
public const string GitBranch =
`"
$(
$Branch
)
`"
;
public const string GitMajor =
`"
$(
$Desc
[
0
]
)
`"
;
public const string GitMinor =
`"
$(
$Desc
[
1
]
)
`"
;
public const string GitPatch =
`"
$(
$Desc
[
2
]
)
`"
;
public const string BuildDate =
`"
$(
$Date
)
`"
;
}"
)
>
$Target
}"
)
Write-Verbose
$CSharp
Write-Output
$CSharp
>
$Target
}
function
Parse-GitDescribe
([
string
]
$CommitName
)
{
Write-Verbose
"Parsing 'git describe' result [
$(
$CommitName
)
]..."
try
{
$Items
=
$CommitName
.
Split
(
'-'
)
.
Split
(
'.'
)
if
(
$Items
.
Length
-ne
4
)
{
throw
}
}
catch
{
throw
"Can't parse commit name [
$(
$CommitName
)
]!"
}
Write-Verbose
"Just some
$(
$Items
[
2
]
)
commits after the last tag."
Return
$Items
}
$Error
ActionPreference
=
"Stop"
$oldpwd
=
pwd
cd
$ProjectDir
-ErrorAction
Stop
try
{
$CommitName
=
&
git
describe
--tags
$CommitName
=
&
git
describe
--tags
--long
--match
"[0-9].[0-9]"
if
(
-Not
$?
)
{
throw
}
$GitStatus
=
&
git
status
--porcelain
if
(
-Not
$?
)
{
throw
}
$GitBranch
=
&
git
symbolic-ref
--short
HEAD
if
(
-Not
$?
)
{
throw
}
$DescItems
=
Parse-GitDescribe
$CommitName
if
(
$GitStatus
.
Length
-gt
0
)
{
Write-Output
"NOTE
: repository has uncommitted changes!"
$StatusWarning
=
" <-- WARNING
: repository has uncommitted changes!"
$CommitName
=
"
$(
$CommitName
)
-unclean"
}
}
catch
{
$CommitName
=
"commit unknown"
$GitStatus
=
"status unknown"
$GitBranch
=
"branch unknown"
Write-Output
"
$(
">"
*
8
)
Running git failed, using default values!
$(
"<"
*
8
)
"
}
...
...
@@ -64,10 +86,10 @@ $BuildDetailsCS = "$($ProjectDir)\..\Resources\BuildDetails.cs"
Write-Output
$CommitName
>
$BCommit
Write-Output
$Date
>
$BuildDate
Write-Output
$Date
Write-Output
$CommitName
Write-Output
$GitBranch
Write-Output
"build-date:
$(
$Date
)
"
Write-Output
"git-branch:
$(
$GitBranch
)
"
Write-Output
"git-description:
$(
$CommitName
)$(
$StatusWarning
)
"
Write-BuildDetails
$BuildDetailsCS
$
CommitName
$GitBranch
$Date
Write-BuildDetails
$BuildDetailsCS
$
DescItems
$GitBranch
$Date
cd
$oldpwd
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment