falkorlib 0.1.0 → 0.2.8
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/Gemfile.lock +56 -4
- data/README.md +147 -34
- data/Rakefile +42 -23
- data/falkorlib.gemspec +11 -7
- data/lib/falkorlib.rb +31 -2
- data/lib/falkorlib/common.rb +93 -41
- data/lib/falkorlib/config.rb +91 -0
- data/lib/falkorlib/git.rb +15 -0
- data/lib/falkorlib/git/base.rb +405 -0
- data/lib/falkorlib/git/flow.rb +120 -0
- data/lib/falkorlib/git_tasks.rb +56 -0
- data/lib/falkorlib/loader.rb +9 -1
- data/lib/falkorlib/tasks.rb +30 -0
- data/lib/falkorlib/tasks/git.rake +121 -0
- data/lib/falkorlib/tasks/git.rb +56 -0
- data/lib/falkorlib/tasks/gitflow.rake +139 -0
- data/{tasks/spec_test.rake → lib/falkorlib/tasks/rspec.rake} +4 -3
- data/lib/falkorlib/tasks/yard.rake +78 -0
- data/lib/falkorlib/version.rb +62 -54
- data/lib/falkorlib/versioning.rb +162 -0
- data/spec/falkorlib/common_spec.rb +12 -12
- data/spec/falkorlib/git_spec.rb +191 -0
- data/spec/falkorlib/gitflow_spec.rb +47 -45
- data/spec/falkorlib/versioning_spec.rb +108 -0
- data/spec/spec_helper.rb +58 -9
- metadata +80 -24
- data/lib/falkorlib/gitflow.rb +0 -71
- data/tasks/debug_mail.rake +0 -75
- data/tasks/debug_mail.txt +0 -13
- data/tasks/gem.rake +0 -73
- data/tasks/unit_test.rake +0 -77
- data/tasks/yard.rake +0 -51
- data/test/test_gitflow.rb +0 -16
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
################################################################################
|
|
3
|
+
# Time-stamp: <Jeu 2014-06-19 18:14 svarrette>
|
|
4
|
+
################################################################################
|
|
5
|
+
# Management of Git Flow operations
|
|
6
|
+
|
|
7
|
+
require "falkorlib"
|
|
8
|
+
require "falkorlib/common"
|
|
9
|
+
require "falkorlib/git/base"
|
|
10
|
+
|
|
11
|
+
include FalkorLib::Common
|
|
12
|
+
|
|
13
|
+
module FalkorLib
|
|
14
|
+
module Config
|
|
15
|
+
|
|
16
|
+
# Default configuration for Gitflow
|
|
17
|
+
module GitFlow
|
|
18
|
+
# git flow defaults
|
|
19
|
+
DEFAULTS = {
|
|
20
|
+
:branches => {
|
|
21
|
+
:master => 'production',
|
|
22
|
+
:develop => 'master',
|
|
23
|
+
},
|
|
24
|
+
:prefix => {
|
|
25
|
+
:feature => 'feature/',
|
|
26
|
+
:release => 'release/',
|
|
27
|
+
:hotfix => 'hotfix/',
|
|
28
|
+
:support => 'support/',
|
|
29
|
+
:versiontag => "v",
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# Management of [git flow](https://github.com/nvie/gitflow) operations I'm
|
|
37
|
+
# using everywhere
|
|
38
|
+
module GitFlow
|
|
39
|
+
|
|
40
|
+
module_function
|
|
41
|
+
|
|
42
|
+
## Initialize a git-flow repository
|
|
43
|
+
def init(path = Dir.pwd)
|
|
44
|
+
exit_status = FalkorLib::Git.init(path)
|
|
45
|
+
error "you shall install git-flow: see https://github.com/nvie/gitflow/wiki/Installation" unless command?('git-flow')
|
|
46
|
+
remotes = FalkorLib::Git.remotes(path)
|
|
47
|
+
git_root_dir = FalkorLib::Git.rootdir( path )
|
|
48
|
+
Dir.chdir( git_root_dir ) do
|
|
49
|
+
unless FalkorLib::Git.has_commits?( git_root_dir)
|
|
50
|
+
warn "Not yet any commit detected in this repository."
|
|
51
|
+
readme = 'README.md'
|
|
52
|
+
answer = ask(cyan("=> Shall one be initiated with a #{readme} file (Y|n)?"), 'Yes')
|
|
53
|
+
exit 0 if answer =~ /n.*/i
|
|
54
|
+
FileUtils.touch(readme)
|
|
55
|
+
FalkorLib::Git.add(readme, "Initiate the repository with a '#{readme}' file")
|
|
56
|
+
end
|
|
57
|
+
branches = FalkorLib::Git.list_branch(path)
|
|
58
|
+
if remotes.include?( 'origin' )
|
|
59
|
+
info "=> configure remote (tracked) branches"
|
|
60
|
+
exit_status = FalkorLib::Git.fetch(path)
|
|
61
|
+
FalkorLib.config.gitflow[:branches].each do |type,branch|
|
|
62
|
+
if branches.include? "remotes/origin/#{branch}"
|
|
63
|
+
exit_status = FalkorLib::Git.grab(branch, path)
|
|
64
|
+
else
|
|
65
|
+
unless branches.include? branch
|
|
66
|
+
info "Creating the branch '#{branch}'"
|
|
67
|
+
FalkorLib::Git.create_branch( branch, path )
|
|
68
|
+
end
|
|
69
|
+
exit_status = FalkorLib::Git.publish(branch, path )
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
else
|
|
73
|
+
FalkorLib.config.gitflow[:branches].each do |type, branch|
|
|
74
|
+
unless branches.include? branch
|
|
75
|
+
info "creating the branch '#{branch}'"
|
|
76
|
+
exit_status = FalkorLib::Git.create_branch( branch, path )
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
info "Initialize git flow configs"
|
|
81
|
+
FalkorLib.config.gitflow[:branches].each do |t,branch|
|
|
82
|
+
exit_status = execute "git config gitflow.branch.#{t} #{branch}"
|
|
83
|
+
end
|
|
84
|
+
FalkorLib.config.gitflow[:prefix].each do |t,prefix|
|
|
85
|
+
exit_status = execute "git config gitflow.prefix.#{t} #{prefix}"
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
exit_status
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
## generic function to run any of the gitflow commands
|
|
93
|
+
def command(name, type = 'feature', action = 'start', path = Dir.pwd, optional_args = '')
|
|
94
|
+
error "Invalid git-flow type '#{type}'" unless ['feature', 'release', 'hotfix', 'support'].include?(type)
|
|
95
|
+
error "Invalid action '#{action}'" unless ['start', 'finish'].include?(action)
|
|
96
|
+
error "You must provide a name" if name == ''
|
|
97
|
+
error "The name '#{name}' cannot contain spaces" if name =~ /\s+/
|
|
98
|
+
exit_status = 1
|
|
99
|
+
Dir.chdir( FalkorLib::Git.rootdir(path) ) do
|
|
100
|
+
exit_status = run %{
|
|
101
|
+
git flow #{type} #{action} #{optional_args} #{name}
|
|
102
|
+
}
|
|
103
|
+
end
|
|
104
|
+
exit_status
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
## git flow {feature, hotfix, release, support} start <name>
|
|
108
|
+
def start (type, name, path = Dir.pwd, optional_args = '')
|
|
109
|
+
command(name, type, 'start', path, optional_args)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
## git flow {feature, hotfix, release, support} finish <name>
|
|
113
|
+
def finish (type, name, path = Dir.pwd, optional_args = '')
|
|
114
|
+
command(name, type, 'finish', path, optional_args)
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
end # module FalkorLib::GitFlow
|
|
119
|
+
|
|
120
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
################################################################################
|
|
3
|
+
# Time-stamp: <Sam 2014-06-14 00:05 svarrette>
|
|
4
|
+
################################################################################
|
|
5
|
+
#
|
|
6
|
+
# FalkorLib rake tasks to pilot Git [flow] operations
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
require 'rake'
|
|
10
|
+
require 'falkorlib'
|
|
11
|
+
require 'falkorlib/tasks'
|
|
12
|
+
|
|
13
|
+
module FalkorLib #:nodoc:
|
|
14
|
+
|
|
15
|
+
# Rake tasks to pilot Git operations
|
|
16
|
+
class GitTasks
|
|
17
|
+
include Rake::DSL if defined? Rake::DSL
|
|
18
|
+
|
|
19
|
+
# Install the git[flow] tasks for Rake
|
|
20
|
+
def install_tasks
|
|
21
|
+
load 'falkorlib/tasks/git.rake'
|
|
22
|
+
load 'falkorlib/tasks/gitflow.rake'
|
|
23
|
+
end
|
|
24
|
+
end # class FalkorLib::GitTasks
|
|
25
|
+
end # module FalkorLib
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
if FalkorLib::Git.init?
|
|
29
|
+
# Now install them ;)
|
|
30
|
+
FalkorLib::GitTasks.new.install_tasks
|
|
31
|
+
else
|
|
32
|
+
warn "Git is not initialized for this directory."
|
|
33
|
+
warn "==> consider running 'rake git[:flow]:init' to be able to access the regular git Rake tasks"
|
|
34
|
+
#.....................
|
|
35
|
+
namespace :git do
|
|
36
|
+
########### git:init ###########
|
|
37
|
+
desc "Initialize Git repository"
|
|
38
|
+
task :init do
|
|
39
|
+
FalkorLib::Git.init
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
#.....................
|
|
43
|
+
namespace :flow do
|
|
44
|
+
########### git:flow:init ###########
|
|
45
|
+
desc "Initialize Git-flow repository"
|
|
46
|
+
task :init do
|
|
47
|
+
FalkorLib::GitFlow.init
|
|
48
|
+
end
|
|
49
|
+
end # namespace git:flow
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
end # namespace git
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
end
|
data/lib/falkorlib/loader.rb
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
################################################################################
|
|
3
|
+
# Time-stamp: <Mer 2014-06-18 17:17 svarrette>
|
|
4
|
+
################################################################################
|
|
5
|
+
# Place the component you wish to see loaded
|
|
1
6
|
|
|
7
|
+
require "falkorlib/config"
|
|
2
8
|
require "falkorlib/common"
|
|
3
|
-
require "falkorlib/
|
|
9
|
+
require "falkorlib/git"
|
|
10
|
+
require "falkorlib/versioning"
|
|
11
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
################################################################################
|
|
3
|
+
# Time-stamp: <Jeu 2014-06-12 16:36 svarrette>
|
|
4
|
+
################################################################################
|
|
5
|
+
#
|
|
6
|
+
# Default FalkorLib rake tasks
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
require 'rake'
|
|
10
|
+
require 'yaml'
|
|
11
|
+
|
|
12
|
+
#Needed for rake/gem '= 0.9.2.2'
|
|
13
|
+
Rake::TaskManager.record_task_metadata = true
|
|
14
|
+
|
|
15
|
+
FalkorLib.config.debug = ARGV.include?('DEBUG')
|
|
16
|
+
|
|
17
|
+
#.....................
|
|
18
|
+
namespace :falkorlib do
|
|
19
|
+
########### falkorlib:conf ###########
|
|
20
|
+
desc "Print the current configuration of FalkorLib"
|
|
21
|
+
task :conf do
|
|
22
|
+
puts FalkorLib.config.to_yaml
|
|
23
|
+
end
|
|
24
|
+
end # namespace falkorlib<
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# Empty task debug
|
|
28
|
+
task :DEBUG do
|
|
29
|
+
end
|
|
30
|
+
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
################################################################################
|
|
3
|
+
# git.rake - Special tasks for the management of Git operations
|
|
4
|
+
# Time-stamp: <Jeu 2014-06-19 18:19 svarrette>
|
|
5
|
+
#
|
|
6
|
+
# Copyright (c) 2014 Sebastien Varrette <Sebastien.Varrette@uni.lu>
|
|
7
|
+
# http://varrette.gforge.uni.lu
|
|
8
|
+
################################################################################
|
|
9
|
+
|
|
10
|
+
require 'falkorlib'
|
|
11
|
+
require 'falkorlib/tasks'
|
|
12
|
+
require 'falkorlib/git'
|
|
13
|
+
|
|
14
|
+
#.....................
|
|
15
|
+
namespace :git do
|
|
16
|
+
|
|
17
|
+
include FalkorLib::Common
|
|
18
|
+
git_root_dir = FalkorLib::Git.rootdir
|
|
19
|
+
remotes = FalkorLib::Git.remotes
|
|
20
|
+
#ap remotes
|
|
21
|
+
|
|
22
|
+
########### git:fetch ###########
|
|
23
|
+
desc "Fetch the latest changes on remotes"
|
|
24
|
+
task :fetch do |t|
|
|
25
|
+
info t.comment
|
|
26
|
+
FalkorLib::Git.fetch()
|
|
27
|
+
end # task fetch
|
|
28
|
+
|
|
29
|
+
[ 'up', 'push' ].each do |op|
|
|
30
|
+
|
|
31
|
+
description = case op
|
|
32
|
+
when 'up'; "Update your local copy of the repository from GIT server"
|
|
33
|
+
when 'push'; "Push your modifications onto the remote branches"
|
|
34
|
+
end
|
|
35
|
+
########### git:{up,push} ###########
|
|
36
|
+
desc "#{description}"
|
|
37
|
+
task op.to_sym do |t|
|
|
38
|
+
info t.comment
|
|
39
|
+
if remotes.empty? || ! remotes.include?( 'origin' )
|
|
40
|
+
warn "No git remote configured... Exiting #{t}"
|
|
41
|
+
next
|
|
42
|
+
end
|
|
43
|
+
cmd = ( op == 'up') ? 'pull' : op
|
|
44
|
+
branch = FalkorLib::Git.branch?
|
|
45
|
+
if FalkorLib::Git.list_branch.include? "remotes/origin/#{branch}"
|
|
46
|
+
status = run %{
|
|
47
|
+
git #{cmd} origin
|
|
48
|
+
}
|
|
49
|
+
if (status.to_i != 0)
|
|
50
|
+
warn("The command '#{cmd}' failed with exit status #{status.to_i}")
|
|
51
|
+
warn("This may be due to the fact that you're not connected to the internet")
|
|
52
|
+
really_continue?('no')
|
|
53
|
+
end
|
|
54
|
+
else
|
|
55
|
+
warn "The current branch '#{branch} is not currently tracked on the remote 'origin'."
|
|
56
|
+
warn "=> exiting"
|
|
57
|
+
next
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
unless FalkorLib.config.git[:submodules].empty?
|
|
63
|
+
#.....................
|
|
64
|
+
namespace :submodules do
|
|
65
|
+
########### init ###########
|
|
66
|
+
desc "Initialize the Git subtrees defined in FalkorLib.config.git.submodules"
|
|
67
|
+
task :init do |t|
|
|
68
|
+
info t.full_comment
|
|
69
|
+
FalkorLib::Git.submodule_init(git_root_dir)
|
|
70
|
+
end # task submodules:init
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
end # namespace submodules
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
if File.exists?("#{git_root_dir}/.gitmodules")
|
|
77
|
+
#.....................
|
|
78
|
+
namespace :submodules do
|
|
79
|
+
|
|
80
|
+
########### git:submodules:update ###########
|
|
81
|
+
desc "Update the git submodules from '#{git_root_dir}'"
|
|
82
|
+
task :update do |t|
|
|
83
|
+
info t.comment
|
|
84
|
+
FalkorLib::Git.submodule_update( git_root_dir )
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
########### git:submodules:upgrade ###########
|
|
88
|
+
desc "Upgrade the git submodules to the latest HEAD commit -- USE WITH CAUTION"
|
|
89
|
+
task :upgrade => [ :update] do |t|
|
|
90
|
+
info t.comment
|
|
91
|
+
FalkorLib::Git.submodule_upgrade( git_root_dir )
|
|
92
|
+
end
|
|
93
|
+
end # namespace git:submodules
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
unless FalkorLib.config.git[:subtrees].empty?
|
|
97
|
+
#.....................
|
|
98
|
+
namespace :subtrees do
|
|
99
|
+
########### git:subtrees:init ###########
|
|
100
|
+
desc "Initialize the Git subtrees defined in FalkorLib.config.git.subtrees"
|
|
101
|
+
task :init do
|
|
102
|
+
FalkorLib::Git.subtree_init(git_root_dir)
|
|
103
|
+
end # task git:subtree:init
|
|
104
|
+
|
|
105
|
+
########### git:subtrees:diff ###########
|
|
106
|
+
desc "Show difference between local subtree(s) and their remotes"
|
|
107
|
+
task :diff do
|
|
108
|
+
FalkorLib::Git.subtree_diff(git_root_dir)
|
|
109
|
+
end # task git:subtree:diff
|
|
110
|
+
|
|
111
|
+
########### git:subtrees:up ###########
|
|
112
|
+
desc "Pull the latest changes from the remote to the local subtree(s)"
|
|
113
|
+
task :up do
|
|
114
|
+
FalkorLib::Git.subtree_up(git_root_dir)
|
|
115
|
+
end # task git:subtree:diff
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
end # namespace git:subtrees
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
end # namespace git
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
################################################################################
|
|
3
|
+
# Time-stamp: <Sam 2014-06-14 00:05 svarrette>
|
|
4
|
+
################################################################################
|
|
5
|
+
#
|
|
6
|
+
# FalkorLib rake tasks to pilot Git [flow] operations
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
require 'rake'
|
|
10
|
+
require 'falkorlib'
|
|
11
|
+
require 'falkorlib/tasks'
|
|
12
|
+
|
|
13
|
+
module FalkorLib #:nodoc:
|
|
14
|
+
|
|
15
|
+
# Rake tasks to pilot Git operations
|
|
16
|
+
class GitTasks
|
|
17
|
+
include Rake::DSL if defined? Rake::DSL
|
|
18
|
+
|
|
19
|
+
# Install the git[flow] tasks for Rake
|
|
20
|
+
def install_tasks
|
|
21
|
+
load 'falkorlib/tasks/git.rake'
|
|
22
|
+
load 'falkorlib/tasks/gitflow.rake'
|
|
23
|
+
end
|
|
24
|
+
end # class FalkorLib::GitTasks
|
|
25
|
+
end # module FalkorLib
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
if FalkorLib::Git.init?
|
|
29
|
+
# Now install them ;)
|
|
30
|
+
FalkorLib::GitTasks.new.install_tasks
|
|
31
|
+
else
|
|
32
|
+
warn "Git is not initialized for this directory."
|
|
33
|
+
warn "==> consider running 'rake git[:flow]:init' to be able to access the regular git Rake tasks"
|
|
34
|
+
#.....................
|
|
35
|
+
namespace :git do
|
|
36
|
+
########### git:init ###########
|
|
37
|
+
desc "Initialize Git repository"
|
|
38
|
+
task :init do
|
|
39
|
+
FalkorLib::Git.init
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
#.....................
|
|
43
|
+
namespace :flow do
|
|
44
|
+
########### git:flow:init ###########
|
|
45
|
+
desc "Initialize Git-flow repository"
|
|
46
|
+
task :init do
|
|
47
|
+
FalkorLib::GitFlow.init
|
|
48
|
+
end
|
|
49
|
+
end # namespace git:flow
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
end # namespace git
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
end
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
################################################################################
|
|
2
|
+
# gitflow.rake - Special tasks for the management of Git [Flow] operations
|
|
3
|
+
# Time-stamp: <Jeu 2014-06-19 18:53 svarrette>
|
|
4
|
+
#
|
|
5
|
+
# Copyright (c) 2014 Sebastien Varrette <Sebastien.Varrette@uni.lu>
|
|
6
|
+
# http://varrette.gforge.uni.lu
|
|
7
|
+
################################################################################
|
|
8
|
+
|
|
9
|
+
require 'falkorlib'
|
|
10
|
+
require 'falkorlib/tasks'
|
|
11
|
+
require 'falkorlib/git'
|
|
12
|
+
|
|
13
|
+
#.....................
|
|
14
|
+
namespace :git do
|
|
15
|
+
|
|
16
|
+
include FalkorLib::Common
|
|
17
|
+
git_root_dir = FalkorLib::Git.rootdir
|
|
18
|
+
|
|
19
|
+
#.....................
|
|
20
|
+
namespace :flow do
|
|
21
|
+
|
|
22
|
+
########### git:flow:init ###########
|
|
23
|
+
desc "Initialize your local clone of the repository for the git-flow management"
|
|
24
|
+
task :init do |t|
|
|
25
|
+
FalkorLib::GitFlow.init(git_root_dir)
|
|
26
|
+
end # task init
|
|
27
|
+
|
|
28
|
+
end # namespace git::flow
|
|
29
|
+
|
|
30
|
+
#.....................
|
|
31
|
+
namespace :feature do
|
|
32
|
+
|
|
33
|
+
######### git:feature:start ##########################
|
|
34
|
+
desc "Start a new feature operation on the repository using the git-flow framework"
|
|
35
|
+
task :start, [:name] do |t, args|
|
|
36
|
+
#args.with_default[:name => '']
|
|
37
|
+
name = args.name == 'name' ? ask("Name of the feature (the git branch will be 'feature/<name>')") : args.name
|
|
38
|
+
info t.comment + " with name 'feature/#{name}'"
|
|
39
|
+
really_continue?
|
|
40
|
+
Rake::Task['git:up'].invoke unless FalkorLib::Git.remotes.empty?
|
|
41
|
+
info "=> prepare new 'feature' using git flow"
|
|
42
|
+
o = FalkorLib::GitFlow.start('feature', name)
|
|
43
|
+
error "Git flow feature operation failed" unless o == 0
|
|
44
|
+
# Now you should be in the new branch
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
######### git:feature:finish ##########################
|
|
48
|
+
desc "Finalize the feature operation"
|
|
49
|
+
task :finish do |t|
|
|
50
|
+
branch = FalkorLib::Git.branch?
|
|
51
|
+
expected_branch_prefix = FalkorLib.config.gitflow[:prefix][:feature]
|
|
52
|
+
if branch !~ /^#{expected_branch_prefix}/
|
|
53
|
+
error "You are not in the expected branch (with prefix '#{expected_branch_prefix}')"
|
|
54
|
+
end
|
|
55
|
+
name = branch.sub(/^#{expected_branch_prefix}/, '')
|
|
56
|
+
info t.comment
|
|
57
|
+
o = FalkorLib::GitFlow.finish('feature', name)
|
|
58
|
+
error "Git flow feature operation failed" unless o == 0
|
|
59
|
+
unless FalkorLib::Git.remotes.empty?
|
|
60
|
+
info "=> about to update remote tracked branches"
|
|
61
|
+
really_continue?
|
|
62
|
+
Rake::Task['git:push'].invoke
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end # End namespace 'git:feature'
|
|
66
|
+
|
|
67
|
+
end # namespace git
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
#.....................
|
|
71
|
+
namespace :version do
|
|
72
|
+
|
|
73
|
+
########### version:info ###########
|
|
74
|
+
desc "Get versioning information"
|
|
75
|
+
task :info do |t|
|
|
76
|
+
include FalkorLib::Versioning
|
|
77
|
+
version = get_version
|
|
78
|
+
#major, minor, patch = bump(version, :major), bumpversion, :minor), bump(version, :patch)
|
|
79
|
+
info t.comment
|
|
80
|
+
puts "Current version: " + bold(version)
|
|
81
|
+
FalkorLib.config[:versioning][:levels].reverse.each do |level|
|
|
82
|
+
puts "- next #{level} version: " + bump(version, level.to_sym)
|
|
83
|
+
end
|
|
84
|
+
end # task info
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
#.....................
|
|
88
|
+
namespace :bump do
|
|
89
|
+
[ 'major', 'minor', 'patch' ].each do |level|
|
|
90
|
+
|
|
91
|
+
################# version:bump:{major,minor,patch} ##################################
|
|
92
|
+
desc "Prepare the #{level} release of the repository"
|
|
93
|
+
task level.to_sym do |t|
|
|
94
|
+
version = FalkorLib::Versioning.get_version
|
|
95
|
+
release_version = FalkorLib::Versioning.bump(version, level.to_sym)
|
|
96
|
+
info t.comment + " (from version '#{version}' to '#{release_version}')"
|
|
97
|
+
really_continue?
|
|
98
|
+
Rake::Task['git:up'].invoke unless FalkorLib::Git.remotes.empty?
|
|
99
|
+
info "=> prepare release using git flow"
|
|
100
|
+
o = FalkorLib::GitFlow.start('release', release_version)
|
|
101
|
+
error "Git flow release process failed" unless o == 0
|
|
102
|
+
# Now you should be in the new branch
|
|
103
|
+
current_branch = FalkorLib::Git.branch?
|
|
104
|
+
expected_branch = FalkorLib.config[:gitflow][:prefix][:release] + release_version
|
|
105
|
+
if (current_branch == expected_branch)
|
|
106
|
+
FalkorLib::Versioning.set_version(release_version)
|
|
107
|
+
warning "The version number has already been bumped"
|
|
108
|
+
warning "==> run 'rake version:release' to finalize the release and merge the current version of the repository into the '#{FalkorLib.config[:gitflow][:branches][:master]}' branch"
|
|
109
|
+
else
|
|
110
|
+
error "You are in the '#{branch}' branch and not the expected one, i.e. #{expected_branch}"
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end # namespace version:bump
|
|
115
|
+
|
|
116
|
+
########### release ###########
|
|
117
|
+
desc "Finalize the release of a given bumped version"
|
|
118
|
+
task :release do |t|
|
|
119
|
+
version = FalkorLib::Versioning.get_version
|
|
120
|
+
branch = FalkorLib::Git.branch?
|
|
121
|
+
expected_branch = FalkorLib.config[:gitflow][:prefix][:release] + version
|
|
122
|
+
error "You are not in the '#{expected_branch}' branch but in the '#{branch}' one. May be you forgot to run 'rake version:bump:{patch,minor,major}' first" if branch != expected_branch
|
|
123
|
+
info "=> Finalize the release of the version '#{version}' into the '#{FalkorLib.config[:gitflow][:branches][:master]}' branch/environment"
|
|
124
|
+
o = FalkorLib::GitFlow.finish('release', version, Dir.pwd, '-s')
|
|
125
|
+
error "Git flow release process failed" unless o == 0
|
|
126
|
+
info("=> about to update remote tracked branches")
|
|
127
|
+
really_continue?
|
|
128
|
+
FalkorLib.config[:gitflow][:branches].each do |type, branch|
|
|
129
|
+
run %{
|
|
130
|
+
git checkout #{branch}
|
|
131
|
+
git push origin
|
|
132
|
+
}
|
|
133
|
+
end
|
|
134
|
+
#Rake::Task['git:push'].invoke
|
|
135
|
+
end # task version:release
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
end # namespace version
|