File tree Expand file tree Collapse file tree 7 files changed +70
-2
lines changed Expand file tree Collapse file tree 7 files changed +70
-2
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,8 @@ public void AllArgsAreInHelp()
16
16
{ "TargetBranch" , "/b" } ,
17
17
{ "LogFilePath" , "/l" } ,
18
18
{ "DynamicRepositoryLocation" , "/dynamicRepoLocation" } ,
19
- { "IsHelp" , "/?" }
19
+ { "IsHelp" , "/?" } ,
20
+ { "IsVersion" , "/version" }
20
21
} ;
21
22
string helpText = null ;
22
23
Original file line number Diff line number Diff line change @@ -65,6 +65,13 @@ public static Arguments ParseArguments(List<string> commandLineArguments)
65
65
var values = switchesAndValues . GetValues ( name ) ;
66
66
var value = values != null ? values . FirstOrDefault ( ) : null ;
67
67
68
+ if ( name . IsSwitch ( "version" ) )
69
+ {
70
+ EnsureArgumentValueCount ( values ) ;
71
+ arguments . IsVersion = true ;
72
+ continue ;
73
+ }
74
+
68
75
if ( name . IsSwitch ( "l" ) )
69
76
{
70
77
EnsureArgumentValueCount ( values ) ;
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ public Arguments()
28
28
public bool Init ;
29
29
public bool Diag ;
30
30
31
+ public bool IsVersion ;
31
32
public bool IsHelp ;
32
33
public string LogFilePath ;
33
34
public string ShowVariable ;
Original file line number Diff line number Diff line change 72
72
<Compile Include =" AssemblyInfo.cs" />
73
73
<Compile Include =" AssemblyInfoFileUpdate.cs" />
74
74
<Compile Include =" SpecifiedArgumentRunner.cs" />
75
+ <Compile Include =" VersionWriter.cs" />
75
76
</ItemGroup >
76
77
<ItemGroup >
77
78
<None Include =" app.config" />
Original file line number Diff line number Diff line change @@ -11,12 +11,17 @@ public static void Write()
11
11
12
12
public static void WriteTo ( Action < string > writeAction )
13
13
{
14
- const string message = @"Use convention to derive a SemVer product version from a GitFlow or GitHub based repository.
14
+ string version = string . Empty ;
15
+ VersionWriter . WriteTo ( v => version = v ) ;
16
+
17
+ string message = "GitVersion " + version + @"
18
+ Use convention to derive a SemVer product version from a GitFlow or GitHub based repository.
15
19
16
20
GitVersion [path]
17
21
18
22
path The directory containing .git. If not defined current directory is used. (Must be first argument)
19
23
init Configuration utility for gitversion
24
+ /version Displays the version of GitVersion
20
25
/diag Runs GitVersion with additional diagnostic information (requires git.exe to be installed)
21
26
/h or /? Shows Help
22
27
Original file line number Diff line number Diff line change @@ -57,6 +57,12 @@ static int VerifyArgumentsAndRun()
57
57
return 1 ;
58
58
}
59
59
60
+ if ( arguments . IsVersion )
61
+ {
62
+ VersionWriter . Write ( ) ;
63
+ return 0 ;
64
+ }
65
+
60
66
if ( arguments . IsHelp )
61
67
{
62
68
HelpWriter . Write ( ) ;
Original file line number Diff line number Diff line change
1
+ namespace GitVersion
2
+ {
3
+ using System ;
4
+ using System . Linq ;
5
+ using System . Reflection ;
6
+
7
+ class VersionWriter
8
+ {
9
+ /// <summary>
10
+ /// Gets the xss version
11
+ /// </summary>
12
+ private static Version Version
13
+ {
14
+ get { return Assembly . GetExecutingAssembly ( ) . GetName ( ) . Version ; }
15
+ }
16
+
17
+ /// <summary>
18
+ /// Gets the AssemblyInformationalVersion
19
+ /// </summary>
20
+ private static string InformationalVersion
21
+ {
22
+ get
23
+ {
24
+ var attribute = Assembly . GetExecutingAssembly ( )
25
+ . GetCustomAttributes ( typeof ( AssemblyInformationalVersionAttribute ) , false )
26
+ . FirstOrDefault ( ) as AssemblyInformationalVersionAttribute ;
27
+
28
+ if ( attribute != null )
29
+ {
30
+ return attribute . InformationalVersion ;
31
+ }
32
+
33
+ return Version . ToString ( ) ;
34
+ }
35
+ }
36
+
37
+ public static void Write ( )
38
+ {
39
+ WriteTo ( Console . WriteLine ) ;
40
+ }
41
+
42
+ public static void WriteTo ( Action < string > writeAction )
43
+ {
44
+ writeAction ( InformationalVersion ) ;
45
+ }
46
+ }
47
+ }
You can’t perform that action at this time.
0 commit comments