physique 0.3.10 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/FLUENT_MIGRATOR.md +300 -300
- data/Gemfile +3 -3
- data/Gemfile.lock +51 -11
- data/Guardfile +34 -0
- data/README.md +368 -368
- data/RUBY_SETUP.md +14 -14
- data/Rakefile +1 -1
- data/lib/physique.rb +22 -22
- data/lib/physique/config.rb +23 -23
- data/lib/physique/dsl.rb +46 -46
- data/lib/physique/project_path_resolver.rb +45 -45
- data/lib/physique/solution.rb +72 -72
- data/lib/physique/task_builders/build.rb +76 -69
- data/lib/physique/task_builders/default.rb +19 -19
- data/lib/physique/task_builders/fluent_migrator.rb +302 -299
- data/lib/physique/task_builders/nuget.rb +18 -6
- data/lib/physique/task_builders/octopus.rb +4 -2
- data/lib/physique/task_builders/publish_nugets.rb +5 -3
- data/lib/physique/task_builders/test.rb +4 -4
- data/lib/physique/tasks/fluent_migrator.rb +158 -158
- data/lib/physique/tasks/nugets_pack.rb +12 -12
- data/lib/physique/tasks/octopus_pack.rb +1 -1
- data/lib/physique/tasks/sqlcmd.rb +109 -109
- data/lib/physique/tasks/versionizer.rb +112 -112
- data/lib/physique/tasks_builder.rb +59 -59
- data/lib/physique/tool_locator.rb +50 -50
- data/lib/physique/version.rb +3 -3
- data/physique.gemspec +29 -28
- data/spec/fluent_migrator_config_spec.rb +39 -39
- data/spec/project_spec.rb +42 -42
- data/spec/publish_nugets_spec.rb +40 -40
- data/spec/solution_spec.rb +11 -11
- data/spec/sqlcmd_spec.rb +146 -146
- data/spec/support/shared_contexts/rake.rb +20 -21
- data/spec/task_builders/build_spec.rb +25 -25
- data/spec/task_builders/default_spec.rb +17 -17
- data/spec/task_builders/fluent_migrator_spec.rb +70 -68
- data/spec/task_builders/nspec_spec.rb +13 -13
- data/spec/task_builders/nuget_spec.rb +16 -16
- data/spec/test_data/solutions/.nuget/NuGet.Config +5 -5
- data/spec/test_data/solutions/.nuget/NuGet.exe +0 -0
- data/spec/test_data/solutions/.nuget/NuGet.targets +144 -144
- data/spec/test_data/solutions/.nuget/packages.config +3 -3
- data/spec/test_data/solutions/basic/.semver +6 -6
- data/spec/test_data/solutions/basic/Basic.Tests/Basic.Tests.csproj +58 -58
- data/spec/test_data/solutions/basic/Basic.Tests/Class1.cs +14 -14
- data/spec/test_data/solutions/basic/Basic.Tests/Properties/AssemblyInfo.cs +36 -36
- data/spec/test_data/solutions/basic/Basic.Tests/packages.config +3 -3
- data/spec/test_data/solutions/basic/Basic.sln +28 -28
- data/spec/test_data/solutions/basic/Basic/Basic.csproj +52 -52
- data/spec/test_data/solutions/basic/Basic/Class1.cs +12 -12
- data/spec/test_data/solutions/basic/Basic/Properties/AssemblyInfo.cs +36 -36
- data/spec/test_data/solutions/basic/Rakefile.rb +10 -10
- data/spec/test_data/solutions/basic/packages.config +3 -3
- data/spec/test_data/solutions/fluent-migrator/.semver +6 -6
- data/spec/test_data/solutions/fluent-migrator/Basic.Migrations/Migrations/.gitkeep +0 -0
- data/spec/test_data/solutions/fluent-migrator/Basic.Migrations/Properties/AssemblyInfo.cs +36 -36
- data/spec/test_data/solutions/fluent-migrator/Basic.Migrations/TestMigration.cs +19 -19
- data/spec/test_data/solutions/fluent-migrator/Basic.Migrations/_Scripts/create.sql +1 -1
- data/spec/test_data/solutions/fluent-migrator/Basic.Migrations/_Scripts/drop.sql +4 -4
- data/spec/test_data/solutions/fluent-migrator/Basic.Migrations/_Scripts/seed.sql +1 -1
- data/spec/test_data/solutions/fluent-migrator/Basic.Migrations/packages.config +3 -3
- data/spec/test_data/solutions/fluent-migrator/Basic.Specs/Basic.Specs.csproj +59 -59
- data/spec/test_data/solutions/fluent-migrator/Basic.Specs/Class1.cs +12 -12
- data/spec/test_data/solutions/fluent-migrator/Basic.Specs/DebuggerShim.cs +42 -42
- data/spec/test_data/solutions/fluent-migrator/Basic.Specs/Properties/AssemblyInfo.cs +36 -36
- data/spec/test_data/solutions/fluent-migrator/Basic.Specs/packages.config +3 -3
- data/spec/test_data/solutions/fluent-migrator/Basic.sln +39 -39
- data/spec/test_data/solutions/fluent-migrator/Basic/Basic.csproj +55 -55
- data/spec/test_data/solutions/fluent-migrator/Basic/Class1.cs +12 -12
- data/spec/test_data/solutions/fluent-migrator/Basic/Properties/AssemblyInfo.cs +36 -36
- data/spec/test_data/solutions/fluent-migrator/Basic/packages.config +2 -2
- data/spec/test_data/solutions/fluent-migrator/Rakefile.rb +20 -20
- data/spec/test_data/solutions/multiple-fluent-migrator/.semver +6 -6
- data/spec/test_data/solutions/multiple-fluent-migrator/Basic.Migrations1/Basic.Migrations1.csproj +52 -52
- data/spec/test_data/solutions/multiple-fluent-migrator/Basic.Migrations1/Class1.cs +12 -12
- data/spec/test_data/solutions/multiple-fluent-migrator/Basic.Migrations1/Properties/AssemblyInfo.cs +36 -36
- data/spec/test_data/solutions/multiple-fluent-migrator/Basic.Migrations2/Basic.Migrations2.csproj +52 -52
- data/spec/test_data/solutions/multiple-fluent-migrator/Basic.Migrations2/Class1.cs +12 -12
- data/spec/test_data/solutions/multiple-fluent-migrator/Basic.Migrations2/Properties/AssemblyInfo.cs +36 -36
- data/spec/test_data/solutions/multiple-fluent-migrator/Basic.Specs/Basic.Specs.csproj +59 -59
- data/spec/test_data/solutions/multiple-fluent-migrator/Basic.Specs/Class1.cs +12 -12
- data/spec/test_data/solutions/multiple-fluent-migrator/Basic.Specs/DebuggerShim.cs +42 -42
- data/spec/test_data/solutions/multiple-fluent-migrator/Basic.Specs/Properties/AssemblyInfo.cs +36 -36
- data/spec/test_data/solutions/multiple-fluent-migrator/Basic.Specs/packages.config +3 -3
- data/spec/test_data/solutions/multiple-fluent-migrator/Basic.sln +45 -45
- data/spec/test_data/solutions/multiple-fluent-migrator/Basic/Basic.csproj +55 -55
- data/spec/test_data/solutions/multiple-fluent-migrator/Basic/Class1.cs +12 -12
- data/spec/test_data/solutions/multiple-fluent-migrator/Basic/Properties/AssemblyInfo.cs +36 -36
- data/spec/test_data/solutions/multiple-fluent-migrator/Basic/packages.config +2 -2
- data/spec/test_data/solutions/multiple-fluent-migrator/Rakefile.rb +28 -28
- data/spec/test_data/solutions/nspec/.semver +6 -6
- data/spec/test_data/solutions/nspec/Basic.Specs/Basic.Specs.csproj +59 -59
- data/spec/test_data/solutions/nspec/Basic.Specs/Class1.cs +12 -12
- data/spec/test_data/solutions/nspec/Basic.Specs/DebuggerShim.cs +42 -42
- data/spec/test_data/solutions/nspec/Basic.Specs/Properties/AssemblyInfo.cs +36 -36
- data/spec/test_data/solutions/nspec/Basic.Specs/packages.config +3 -3
- data/spec/test_data/solutions/nspec/Basic.sln +28 -28
- data/spec/test_data/solutions/nspec/Basic/Basic.csproj +55 -55
- data/spec/test_data/solutions/nspec/Basic/Class1.cs +12 -12
- data/spec/test_data/solutions/nspec/Basic/Properties/AssemblyInfo.cs +36 -36
- data/spec/test_data/solutions/nspec/Basic/packages.config +2 -2
- data/spec/test_data/solutions/nspec/Rakefile.rb +14 -14
- data/spec/test_data/tool_locator/Program Files/Microsoft SQL Server/110/Tools/Binn/SQLCMD.exe.txt b/data/spec/test_data/tool_locator/Program Files/Microsoft SQL → Server/110/Tools/Binn/SQLCMD.exe.txt +0 -0
- data/spec/test_data/tool_locator/Windows/Microsoft.NET/Framework/v3.5/MSBuild.exe.txt +0 -0
- data/spec/test_data/tool_locator/Windows/Microsoft.NET/Framework/v4.0.30319/MSBuild.exe.txt +0 -0
- data/spec/tool_locator_spec.rb +27 -29
- metadata +33 -16
@@ -1,110 +1,110 @@
|
|
1
|
-
require 'active_support/core_ext/string'
|
2
|
-
require 'albacore'
|
3
|
-
require 'albacore/cmd_config'
|
4
|
-
require 'physique/tool_locator'
|
5
|
-
|
6
|
-
module Physique
|
7
|
-
module SqlCmd
|
8
|
-
class Cmd
|
9
|
-
include Albacore::CrossPlatformCmd
|
10
|
-
|
11
|
-
attr_reader :parameters
|
12
|
-
|
13
|
-
def initialize(opts)
|
14
|
-
@executable = opts[:exe]
|
15
|
-
set_parameters opts
|
16
|
-
end
|
17
|
-
|
18
|
-
def execute
|
19
|
-
sh "#{@executable} #{@parameters.join(' ')}"
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def set_parameters(opts)
|
25
|
-
@parameters = @parameters || []
|
26
|
-
@parameters << "-S #{opts[:server_name]}"
|
27
|
-
@parameters << "-d #{opts[:database_name]}" unless opts.blank? :database_name
|
28
|
-
@parameters << "-i #{opts[:file]}" if opts[:source] == :file
|
29
|
-
@parameters << %{-Q "#{opts[:command]}"} if opts[:source] == :command
|
30
|
-
@parameters << '-b' unless opts[:continue_on_error]
|
31
|
-
|
32
|
-
opts[:variables].each do |k, v|
|
33
|
-
@parameters << "-v #{k}=#{v}"
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
class Config
|
39
|
-
include Albacore::CmdConfig
|
40
|
-
include Physique::ToolLocator
|
41
|
-
self.extend Albacore::ConfigDSL
|
42
|
-
|
43
|
-
# The database server
|
44
|
-
attr_path :server_name
|
45
|
-
|
46
|
-
# The database name
|
47
|
-
attr_writer :database_name
|
48
|
-
|
49
|
-
# The sql script to execute
|
50
|
-
attr_path :file
|
51
|
-
|
52
|
-
# The sql command to execute
|
53
|
-
attr_writer :command
|
54
|
-
|
55
|
-
def initialize
|
56
|
-
@variables = Hash.new
|
57
|
-
@continue_on_error = false
|
58
|
-
|
59
|
-
@exe = which('sqlcmd') ||
|
60
|
-
locate_tool('C:/Program Files/Microsoft SQL Server/**/Tools/Binn/SQLCMD.EXE')
|
61
|
-
end
|
62
|
-
|
63
|
-
def set_variable(k, v)
|
64
|
-
@variables[k] = v
|
65
|
-
end
|
66
|
-
|
67
|
-
def continue_on_error
|
68
|
-
@continue_on_error = true
|
69
|
-
end
|
70
|
-
|
71
|
-
def opts
|
72
|
-
raise ArgumentError, 'You must specify a server name' if @server_name.blank?
|
73
|
-
raise ArgumentError, 'You must specify a command or a file to execute' unless can_execute?
|
74
|
-
|
75
|
-
Map.new({
|
76
|
-
exe: @exe,
|
77
|
-
server_name: @server_name,
|
78
|
-
database_name: @database_name,
|
79
|
-
file: @file,
|
80
|
-
command: @command,
|
81
|
-
source: execute_source,
|
82
|
-
continue_on_error: @continue_on_error,
|
83
|
-
variables: @variables
|
84
|
-
})
|
85
|
-
end
|
86
|
-
|
87
|
-
private
|
88
|
-
|
89
|
-
def can_execute?
|
90
|
-
!(@file.blank? && @command.blank?)
|
91
|
-
end
|
92
|
-
|
93
|
-
def execute_source
|
94
|
-
# Command takes precedence over a file
|
95
|
-
return :command unless @command.blank?
|
96
|
-
:file
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
class Task
|
101
|
-
def initialize(opts)
|
102
|
-
@cmd = Physique::SqlCmd::Cmd.new opts
|
103
|
-
end
|
104
|
-
|
105
|
-
def execute
|
106
|
-
@cmd.execute
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
1
|
+
require 'active_support/core_ext/string'
|
2
|
+
require 'albacore'
|
3
|
+
require 'albacore/cmd_config'
|
4
|
+
require 'physique/tool_locator'
|
5
|
+
|
6
|
+
module Physique
|
7
|
+
module SqlCmd
|
8
|
+
class Cmd
|
9
|
+
include Albacore::CrossPlatformCmd
|
10
|
+
|
11
|
+
attr_reader :parameters
|
12
|
+
|
13
|
+
def initialize(opts)
|
14
|
+
@executable = opts[:exe]
|
15
|
+
set_parameters opts
|
16
|
+
end
|
17
|
+
|
18
|
+
def execute
|
19
|
+
sh "#{@executable} #{@parameters.join(' ')}"
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def set_parameters(opts)
|
25
|
+
@parameters = @parameters || []
|
26
|
+
@parameters << "-S #{opts[:server_name]}"
|
27
|
+
@parameters << "-d #{opts[:database_name]}" unless opts.blank? :database_name
|
28
|
+
@parameters << "-i #{opts[:file]}" if opts[:source] == :file
|
29
|
+
@parameters << %{-Q "#{opts[:command]}"} if opts[:source] == :command
|
30
|
+
@parameters << '-b' unless opts[:continue_on_error]
|
31
|
+
|
32
|
+
opts[:variables].each do |k, v|
|
33
|
+
@parameters << "-v #{k}=#{v}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class Config
|
39
|
+
include Albacore::CmdConfig
|
40
|
+
include Physique::ToolLocator
|
41
|
+
self.extend Albacore::ConfigDSL
|
42
|
+
|
43
|
+
# The database server
|
44
|
+
attr_path :server_name
|
45
|
+
|
46
|
+
# The database name
|
47
|
+
attr_writer :database_name
|
48
|
+
|
49
|
+
# The sql script to execute
|
50
|
+
attr_path :file
|
51
|
+
|
52
|
+
# The sql command to execute
|
53
|
+
attr_writer :command
|
54
|
+
|
55
|
+
def initialize
|
56
|
+
@variables = Hash.new
|
57
|
+
@continue_on_error = false
|
58
|
+
|
59
|
+
@exe = which('sqlcmd') ||
|
60
|
+
locate_tool('C:/Program Files/Microsoft SQL Server/**/Tools/Binn/SQLCMD.EXE')
|
61
|
+
end
|
62
|
+
|
63
|
+
def set_variable(k, v)
|
64
|
+
@variables[k] = v
|
65
|
+
end
|
66
|
+
|
67
|
+
def continue_on_error
|
68
|
+
@continue_on_error = true
|
69
|
+
end
|
70
|
+
|
71
|
+
def opts
|
72
|
+
raise ArgumentError, 'You must specify a server name' if @server_name.blank?
|
73
|
+
raise ArgumentError, 'You must specify a command or a file to execute' unless can_execute?
|
74
|
+
|
75
|
+
Map.new({
|
76
|
+
exe: @exe,
|
77
|
+
server_name: @server_name,
|
78
|
+
database_name: @database_name,
|
79
|
+
file: @file,
|
80
|
+
command: @command,
|
81
|
+
source: execute_source,
|
82
|
+
continue_on_error: @continue_on_error,
|
83
|
+
variables: @variables
|
84
|
+
})
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
|
89
|
+
def can_execute?
|
90
|
+
!(@file.blank? && @command.blank?)
|
91
|
+
end
|
92
|
+
|
93
|
+
def execute_source
|
94
|
+
# Command takes precedence over a file
|
95
|
+
return :command unless @command.blank?
|
96
|
+
:file
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
class Task
|
101
|
+
def initialize(opts)
|
102
|
+
@cmd = Physique::SqlCmd::Cmd.new opts
|
103
|
+
end
|
104
|
+
|
105
|
+
def execute
|
106
|
+
@cmd.execute
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
110
|
end
|
@@ -1,113 +1,113 @@
|
|
1
|
-
require 'xsemver'
|
2
|
-
require 'albacore/logging'
|
3
|
-
|
4
|
-
module Physique
|
5
|
-
module Tasks
|
6
|
-
# Versionizer does versioning ITS OWN WAY!
|
7
|
-
#
|
8
|
-
# Defines ENV vars:
|
9
|
-
# * BUILD_VERSION
|
10
|
-
# * NUGET_VERSION
|
11
|
-
# * FORMAL_VERSION
|
12
|
-
#
|
13
|
-
# Publishes symbol :build_version
|
14
|
-
module Versionizer
|
15
|
-
# adds a new task with the given symbol to the Rake/Albacore application
|
16
|
-
# You can use this like any other albacore method, such as build,
|
17
|
-
# in order to give it parameters or dependencies, but there is no
|
18
|
-
# configuration object that you can configure. Copy-n-paste this
|
19
|
-
# code if you want something of your own.
|
20
|
-
#
|
21
|
-
def self.new(*sym)
|
22
|
-
version = gitflow_version(XSemVer::SemVer.find)
|
23
|
-
version_data = define_versions(version)
|
24
|
-
|
25
|
-
Albacore.subscribe :build_version do |data|
|
26
|
-
ENV['BUILD_VERSION'] = data.build_version
|
27
|
-
ENV['NUGET_VERSION'] = data.nuget_version
|
28
|
-
ENV['FORMAL_VERSION'] = data.formal_version
|
29
|
-
ENV['LONG_VERSION'] = data.long_version
|
30
|
-
end
|
31
|
-
|
32
|
-
Albacore.define_task(*sym) do
|
33
|
-
Albacore.publish :build_version, OpenStruct.new(version_data)
|
34
|
-
end
|
35
|
-
|
36
|
-
Albacore.define_task :version do
|
37
|
-
puts version_data.inspect
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def self.define_versions(semver)
|
42
|
-
build = build_number
|
43
|
-
|
44
|
-
{
|
45
|
-
# just a monotonic inc
|
46
|
-
:semver => semver,
|
47
|
-
:build_number => build,
|
48
|
-
:current_branch => current_branch,
|
49
|
-
|
50
|
-
# purely M.m.p format
|
51
|
-
:formal_version => "#{semver.format('%M.%m.%p')}",
|
52
|
-
|
53
|
-
# four-numbers version, useful if you're dealing with COM/Windows
|
54
|
-
:long_version => "#{semver.format('%M.%m.%p')}.#{build}",
|
55
|
-
|
56
|
-
# extensible number w/ git hash
|
57
|
-
:build_version => "#{semver.format('%M.%m.%p%s')}.#{last_commit[0]}",
|
58
|
-
|
59
|
-
# nuget (not full semver 2.0.0-rc.1 support) see http://nuget.codeplex.com/workitem/1796
|
60
|
-
:nuget_version => semver.format('%M.%m.%p%s')
|
61
|
-
}
|
62
|
-
end
|
63
|
-
|
64
|
-
# load the commit data
|
65
|
-
# returns: [short-commit :: String]
|
66
|
-
#
|
67
|
-
def self.last_commit
|
68
|
-
begin
|
69
|
-
`git rev-parse --short HEAD`.chomp[0,6]
|
70
|
-
rescue
|
71
|
-
(ENV['BUILD_VCS_NUMBER'] || '000000')[0,6]
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
# Determine the current branch
|
76
|
-
# returns: branch name
|
77
|
-
#
|
78
|
-
def self.current_branch
|
79
|
-
begin
|
80
|
-
`git rev-parse --abbrev-ref HEAD`.chomp
|
81
|
-
rescue
|
82
|
-
'master'
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def self.gitflow_version(version)
|
87
|
-
return unless ENV.include?('BUILD_NUMBER')
|
88
|
-
version.special = gitflow_special
|
89
|
-
version
|
90
|
-
end
|
91
|
-
|
92
|
-
def self.build_number
|
93
|
-
ENV['BUILD_NUMBER'] || '0'
|
94
|
-
end
|
95
|
-
|
96
|
-
def self.gitflow_special
|
97
|
-
prefix = special_prefix
|
98
|
-
return version.special if prefix == 'master'
|
99
|
-
|
100
|
-
"#{prefix}#{build_number}"
|
101
|
-
end
|
102
|
-
|
103
|
-
def self.special_prefix
|
104
|
-
# TODO: There is a better way to do this.
|
105
|
-
branch_name = current_branch
|
106
|
-
return 'release' if branch_name.start_with? 'release/'
|
107
|
-
return 'hotfix' if branch_name.start_with? 'hotfix/'
|
108
|
-
return 'feature' if branch_name.start_with? 'feature/'
|
109
|
-
branch_name
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
1
|
+
require 'xsemver'
|
2
|
+
require 'albacore/logging'
|
3
|
+
|
4
|
+
module Physique
|
5
|
+
module Tasks
|
6
|
+
# Versionizer does versioning ITS OWN WAY!
|
7
|
+
#
|
8
|
+
# Defines ENV vars:
|
9
|
+
# * BUILD_VERSION
|
10
|
+
# * NUGET_VERSION
|
11
|
+
# * FORMAL_VERSION
|
12
|
+
#
|
13
|
+
# Publishes symbol :build_version
|
14
|
+
module Versionizer
|
15
|
+
# adds a new task with the given symbol to the Rake/Albacore application
|
16
|
+
# You can use this like any other albacore method, such as build,
|
17
|
+
# in order to give it parameters or dependencies, but there is no
|
18
|
+
# configuration object that you can configure. Copy-n-paste this
|
19
|
+
# code if you want something of your own.
|
20
|
+
#
|
21
|
+
def self.new(*sym)
|
22
|
+
version = gitflow_version(XSemVer::SemVer.find)
|
23
|
+
version_data = define_versions(version)
|
24
|
+
|
25
|
+
Albacore.subscribe :build_version do |data|
|
26
|
+
ENV['BUILD_VERSION'] = data.build_version
|
27
|
+
ENV['NUGET_VERSION'] = data.nuget_version
|
28
|
+
ENV['FORMAL_VERSION'] = data.formal_version
|
29
|
+
ENV['LONG_VERSION'] = data.long_version
|
30
|
+
end
|
31
|
+
|
32
|
+
Albacore.define_task(*sym) do
|
33
|
+
Albacore.publish :build_version, OpenStruct.new(version_data)
|
34
|
+
end
|
35
|
+
|
36
|
+
Albacore.define_task :version do
|
37
|
+
puts version_data.inspect
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.define_versions(semver)
|
42
|
+
build = build_number
|
43
|
+
|
44
|
+
{
|
45
|
+
# just a monotonic inc
|
46
|
+
:semver => semver,
|
47
|
+
:build_number => build,
|
48
|
+
:current_branch => current_branch,
|
49
|
+
|
50
|
+
# purely M.m.p format
|
51
|
+
:formal_version => "#{semver.format('%M.%m.%p')}",
|
52
|
+
|
53
|
+
# four-numbers version, useful if you're dealing with COM/Windows
|
54
|
+
:long_version => "#{semver.format('%M.%m.%p')}.#{build}",
|
55
|
+
|
56
|
+
# extensible number w/ git hash
|
57
|
+
:build_version => "#{semver.format('%M.%m.%p%s')}.#{last_commit[0]}",
|
58
|
+
|
59
|
+
# nuget (not full semver 2.0.0-rc.1 support) see http://nuget.codeplex.com/workitem/1796
|
60
|
+
:nuget_version => semver.format('%M.%m.%p%s')
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
# load the commit data
|
65
|
+
# returns: [short-commit :: String]
|
66
|
+
#
|
67
|
+
def self.last_commit
|
68
|
+
begin
|
69
|
+
`git rev-parse --short HEAD`.chomp[0,6]
|
70
|
+
rescue
|
71
|
+
(ENV['BUILD_VCS_NUMBER'] || '000000')[0,6]
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# Determine the current branch
|
76
|
+
# returns: branch name
|
77
|
+
#
|
78
|
+
def self.current_branch
|
79
|
+
begin
|
80
|
+
`git rev-parse --abbrev-ref HEAD`.chomp
|
81
|
+
rescue
|
82
|
+
'master'
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def self.gitflow_version(version)
|
87
|
+
return unless ENV.include?('BUILD_NUMBER')
|
88
|
+
version.special = gitflow_special
|
89
|
+
version
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.build_number
|
93
|
+
ENV['BUILD_NUMBER'] || '0'
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.gitflow_special
|
97
|
+
prefix = special_prefix
|
98
|
+
return version.special if prefix == 'master'
|
99
|
+
|
100
|
+
"#{prefix}#{build_number}"
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.special_prefix
|
104
|
+
# TODO: There is a better way to do this.
|
105
|
+
branch_name = current_branch
|
106
|
+
return 'release' if branch_name.start_with? 'release/'
|
107
|
+
return 'hotfix' if branch_name.start_with? 'hotfix/'
|
108
|
+
return 'feature' if branch_name.start_with? 'feature/'
|
109
|
+
branch_name
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
113
|
end
|