Skip to content

Commit

Permalink
Update readme, add license, comment type definition, add Version memb…
Browse files Browse the repository at this point in the history
…er (tag + addn. commits)
  • Loading branch information
tmatijevich committed Mar 31, 2022
1 parent e7969f0 commit 3db2c2d
Show file tree
Hide file tree
Showing 4 changed files with 728 additions and 35 deletions.
19 changes: 12 additions & 7 deletions BuildVersion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
$ScriptName = $MyInvocation.MyCommand.Name
Write-Host "BuildVersion: Running $ScriptName powershell script"

#########
# Options
#########
############
# Parameters
############
# The script will search under Logical to find this program (e.g. .\Logical\BuildVersion\BuildVer)
$ProgramName = "BuildVer"
# The script will search under Logical to find this variable file (e.g. .\Logical\Global.var)
Expand Down Expand Up @@ -91,7 +91,7 @@ if([System.IO.Directory]::Exists($ProgramPath)) {
(*This file was automatically generated by $ScriptName on $FileDate.*)
(*Do not modify the contents of this file.*)
VAR
BuildVersion : BuildVersionType; (*Please install Git and create repository to initialize*)
BuildVersion : BuildVersionType; (*This is a placeholder. Please install Git and create repository to initialize*)
END_VAR
"@
Set-Content -Path $LocalVariableFile $FileContent
Expand Down Expand Up @@ -174,14 +174,19 @@ if($LASTEXITCODE -ne 0) {
$Tag = "None"
$Describe = "None"
$AdditionalCommits = 0
$Version = "None"
}
else {
$Describe = git -C $args[0] describe --tags 2> $Null
if($Describe.Replace($Tag,"").Split("-").Length -ne 3) {
Write-Warning "BuildVersion: Git describe is unable to determine # of additional commits"
$AdditionalCommits = 0
$Version = $Tag
}
else {
$AdditionalCommits = $Describe.Replace($Tag,"").Split("-")[1]
$Version = $Tag + "-" + $AdditionalCommits
}
else {$AdditionalCommits = $Describe.Replace($Tag,"").Split("-")[1]}
}
$Tag = TruncateString $Tag 80
$Describe = TruncateString $Describe 80
Expand Down Expand Up @@ -277,7 +282,7 @@ $BuildDate = Get-Date -Format "yyyy-MM-dd-HH:mm:ss"
################
# Initialization
################
$GitInit = "(Url:='$Url',Branch:='$Branch',Tag:='$Tag',AdditionalCommits:=$AdditionalCommits,Sha1:='$Sha1',Describe:='$Describe',UncommittedChanges:='$UncommittedChanges',CommitDate:=DT#$CommitDate,CommitAuthorName:='$CommitAuthorName',CommitAuthorEmail:='$CommitAuthorEmail')"
$GitInit = "(URL:='$Url',Branch:='$Branch',Tag:='$Tag',AdditionalCommits:=$AdditionalCommits,Version:='$Version',Sha1:='$Sha1',Describe:='$Describe',UncommittedChanges:='$UncommittedChanges',CommitDate:=DT#$CommitDate,CommitAuthorName:='$CommitAuthorName',CommitAuthorEmail:='$CommitAuthorEmail')"
$ProjectInit = "(ASVersion:='$ASVersion',UserName:='$UserName',ProjectName:='$ProjectName',Configuration:='$Configuration',BuildMode:='$BuildMode',BuildDate:=DT#$BuildDate)"
$BuildVersionInit = "(Git:=$GitInit,Project:=$ProjectInit)"

Expand Down Expand Up @@ -311,7 +316,7 @@ if([System.IO.Directory]::Exists($ProgramPath)) {
(*This file was automatically generated by $ScriptName on $BuildDate.*)
(*Do not modify the contents of this file.*)
VAR
BuildVersion : BuildVersionType := $BuildVersionInit;
BuildVersion : BuildVersionType := $BuildVersionInit; (*Generated build information*)
END_VAR
"@

Expand Down
43 changes: 22 additions & 21 deletions BuildVersion.typ
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@

TYPE
BuildVersionType : STRUCT
Git : BuildVersionGitType;
Project : BuildVersionProjectType;
BuildVersionType : STRUCT (*BuildVersion structure definition*)
Git : BuildVersionGitType; (*Git member*)
Project : BuildVersionProjectType; (*Project member*)
END_STRUCT;
BuildVersionGitType : STRUCT
Url : STRING[255];
Branch : STRING[80];
Tag : STRING[80];
AdditionalCommits : UINT;
Sha1 : STRING[80];
Describe : STRING[80];
UncommittedChanges : STRING[80];
CommitDate : DATE_AND_TIME;
CommitAuthorName : STRING[80];
CommitAuthorEmail : STRING[80];
BuildVersionGitType : STRUCT (*Git information structure definition*)
URL : STRING[255]; (*URL of git server referenced by the default remote "origin"*)
Branch : STRING[80]; (*Current branch checked out by local repository*)
Tag : STRING[80]; (*Latest tag on current branch*)
AdditionalCommits : UINT; (*Additional commits since latest tag*)
Version : STRING[80]; (*<tag>-<addn_commits>*)
Sha1 : STRING[80]; (*Full hash value from the latest commit*)
Describe : STRING[80]; (*<tag>-<addn_commits>-g<short_sha1>*)
UncommittedChanges : STRING[80]; (*Example: 5 files changed, 14 insertions(+), 11 deletions(-)*)
CommitDate : DATE_AND_TIME; (*Local timestamp of the latest commit*)
CommitAuthorName : STRING[80]; (*Name of author of latest commit*)
CommitAuthorEmail : STRING[80]; (*Email of author of latest commit*)
END_STRUCT;
BuildVersionProjectType : STRUCT
ASVersion : STRING[80];
UserName : STRING[80];
ProjectName : STRING[80];
Configuration : STRING[80];
BuildMode : STRING[80];
BuildDate : DT;
BuildVersionProjectType : STRUCT (*Project information structure definition*)
ASVersion : STRING[80]; (*From $(AS_VERSION), see help for PLC object properties*)
UserName : STRING[80]; (*From $(AS_USER_NAME)*)
ProjectName : STRING[80]; (*From $(AS_PROJECT_NAME)*)
Configuration : STRING[80]; (*From $(AS_CONFIGURATION)*)
BuildMode : STRING[80]; (*From $(AS_BUILD_MODE), see help for possible values - Build, Rebuild, BuildAndTransfer, ...*)
BuildDate : DATE_AND_TIME; (*Local timestamp grabbed by powershell on build*)
END_STRUCT;
END_TYPE
Loading

0 comments on commit 3db2c2d

Please sign in to comment.