5
5
def find_start(start)
6
6
# This is a case statement, as we might want to map certain
7
7
# git tags to starting points that are not currently in git.
10
when @next_release: return "master"
10
when @next_release; return "master"
15
15
desc "Set up git for working with Puppet"
17
# This should be changed as new versions get released
18
@next_release = '0.26.x'
21
default_remote[:url] = 'git://github.com/reductivelabs/puppet'
22
default_remote[:name] = 'origin'
23
@remote[:name] = %x{git config puppet.defaultremote}.chomp
24
@remote[:name] = @remote[:name].empty? ? default_remote[:name] : @remote[:name]
25
@remote[:url] = default_remote[:url] if @remote[:name] == default_remote[:name]
26
default_fetch = '+refs/heads/*:refs/remotes/puppet/*'
27
@remote[:fetch] = %x{git config puppet.#{@remote[:name]}.fetch}.chomp
28
@remote[:fetch] = @remote[:fetch].empty? ? default_fetch : @remote[:fetch]
17
# This should be changed as new versions get released
18
@next_release = '0.26.x'
21
default_remote[:url] = 'git://github.com/reductivelabs/puppet'
22
default_remote[:name] = 'origin'
23
@remote[:name] = %x{git config puppet.defaultremote}.chomp
24
@remote[:name] = @remote[:name].empty? ? default_remote[:name] : @remote[:name]
25
@remote[:url] = default_remote[:url] if @remote[:name] == default_remote[:name]
26
default_fetch = '+refs/heads/*:refs/remotes/puppet/*'
27
@remote[:fetch] = %x{git config puppet.#{@remote[:name]}.fetch}.chomp
28
@remote[:fetch] = @remote[:fetch].empty? ? default_fetch : @remote[:fetch]
31
31
desc "Start work on a feature"
32
32
task :start_feature, [:feature,:remote,:branch] => :git_setup do |t, args|
33
args.with_defaults(:remote => @remote[:name])
34
args.with_defaults(:branch => @next_release)
35
start_at = find_start(args.branch)
36
branch = "feature/#{start_at}/#{args.feature}"
37
sh "git checkout -b #{branch} #{start_at}" do |ok, res|
33
args.with_defaults(:remote => @remote[:name])
34
args.with_defaults(:branch => @next_release)
35
start_at = find_start(args.branch)
36
branch = "feature/#{start_at}/#{args.feature}"
37
sh "git checkout -b #{branch} #{start_at}" do |ok, res|
40
40
Was not able to create branch for #{args.feature} on branch #{args.branch}, starting at #{start_at}: error code was: #{res.exitstatus}
44
sh "git config branch.#{branch}.remote #{args.remote}" do |ok, res|
45
raise "Could not set remote: #{$?}" unless ok
44
sh "git config branch.#{branch}.remote #{args.remote}" do |ok, res|
45
raise "Could not set remote: #{$?}" unless ok
48
sh "git config branch.#{branch}.merge refs/heads/#{branch}" do |ok, res|
49
raise "Could not configure merge: #{$?}" unless ok
48
sh "git config branch.#{branch}.merge refs/heads/#{branch}" do |ok, res|
49
raise "Could not configure merge: #{$?}" unless ok
53
53
desc "Do git prep to start work on a Redmine ticket"
54
54
task :start_ticket, [:ticket, :remote, :branch] => :git_setup do |t, args|
55
args.with_defaults(:remote => @remote[:name])
56
args.with_defaults(:branch => @next_release)
57
start_at = find_start(args.branch)
58
branch = "tickets/#{start_at}/#{args.ticket}"
59
sh "git checkout -b #{branch} #{start_at}" do |ok, res|
55
args.with_defaults(:remote => @remote[:name])
56
args.with_defaults(:branch => @next_release)
57
start_at = find_start(args.branch)
58
branch = "tickets/#{start_at}/#{args.ticket}"
59
sh "git checkout -b #{branch} #{start_at}" do |ok, res|
62
62
Was not able to create branch for ticket #{args.ticket} on branch #{args.branch}, starting at #{start_at}: error code was: #{$?}
63
63
Git command used was: #{command}
67
67
sh "git config branch.#{branch}.remote #{args.remote}" do |ok, res|
68
raise "Could not set remote: #{$?}" unless ok
68
raise "Could not set remote: #{$?}" unless ok
71
71
sh "git config branch.#{branch}.merge refs/heads/#{branch}" do |ok, res|
72
raise "Could not configure merge: #{$?}" unless ok
72
raise "Could not configure merge: #{$?}" unless ok
76
76
# This isn't very useful by itself, but we might enhance it later, or use it
77
77
# in a dependency for a more complex task.
78
78
desc "Push out changes"
79
79
task :push_changes, [:remote] do |t, arg|
80
branch = %x{git branch | grep "^" | awk '{print $2}'}
81
sh "git push #{arg.remote} #{branch}" do |ok, res|
82
raise "Unable to push to #{arg.remote}" unless ok
80
branch = %x{git branch | grep "^" | awk '{print $2}'}
81
sh "git push #{arg.remote} #{branch}" do |ok, res|
82
raise "Unable to push to #{arg.remote}" unless ok
86
86
desc "Send patch information to the puppet-dev list"