~bkerensa/ubuntu/raring/puppet/new-upstream-release

« back to all changes in this revision

Viewing changes to tasks/rake/git_workflow.rake

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2011-07-25 01:00:37 UTC
  • mfrom: (1.1.24 upstream) (3.1.25 sid)
  • Revision ID: james.westby@ubuntu.com-20110725010037-875vuxs10eboqgw3
Tags: 2.7.1-1ubuntu1
* Merge from debian unstable.  Remaining changes:
  - debian/puppetmaster-passenger.postinst: Use cacrl instead of hostcrl to
    set the location of the CRL in apache2 configuration. Fix apache2
    configuration on upgrade as well (LP: #641001)
  - move all puppet dependencies to puppet-common since all the code
    actually located in puppet-common.
  - move libagueas from a recommend to a dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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.
8
 
        case start
9
 
                when nil?:
10
 
                when @next_release: return "master"
11
 
                else return start
12
 
        end
 
8
  case start
 
9
    when nil?;
 
10
    when @next_release; return "master"
 
11
    else return start
 
12
  end
13
13
end
14
14
 
15
15
desc "Set up git for working with Puppet"
16
16
task :git_setup do
17
 
        # This should be changed as new versions get released
18
 
        @next_release = '0.26.x'
19
 
        @remote = {}
20
 
        default_remote = {}
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'
 
19
  @remote = {}
 
20
  default_remote = {}
 
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]
29
29
end
30
30
 
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|
38
 
                if ! ok
39
 
                        raise <<EOS
 
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|
 
38
    if ! ok
 
39
      raise <<EOS
40
40
Was not able to create branch for #{args.feature} on branch #{args.branch}, starting at #{start_at}: error code was: #{res.exitstatus}
41
41
EOS
42
 
                end
43
 
        end
44
 
        sh "git config branch.#{branch}.remote #{args.remote}" do |ok, res|
45
 
                raise "Could not set remote: #{$?}" unless ok
46
 
        end
 
42
    end
 
43
  end
 
44
  sh "git config branch.#{branch}.remote #{args.remote}" do |ok, res|
 
45
    raise "Could not set remote: #{$?}" unless ok
 
46
  end
47
47
 
48
 
        sh "git config branch.#{branch}.merge refs/heads/#{branch}" do |ok, res|
49
 
                raise "Could not configure merge: #{$?}" unless ok
50
 
        end
 
48
  sh "git config branch.#{branch}.merge refs/heads/#{branch}" do |ok, res|
 
49
    raise "Could not configure merge: #{$?}" unless ok
 
50
  end
51
51
end
52
52
 
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|
60
 
                unless ok
61
 
                        raise <<EOS
 
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|
 
60
    unless ok
 
61
      raise <<EOS
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}
64
64
EOS
65
 
                end
66
 
        end
 
65
    end
 
66
  end
67
67
    sh "git config branch.#{branch}.remote #{args.remote}" do |ok, res|
68
 
        raise "Could not set remote: #{$?}" unless ok
69
 
        end
 
68
      raise "Could not set remote: #{$?}" unless ok
 
69
  end
70
70
 
71
71
    sh "git config branch.#{branch}.merge refs/heads/#{branch}" do |ok, res|
72
 
        raise "Could not configure merge: #{$?}" unless ok
73
 
        end
 
72
      raise "Could not configure merge: #{$?}" unless ok
 
73
  end
74
74
end
75
75
 
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
83
 
        end
 
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
 
83
  end
84
84
end
85
85
 
86
86
desc "Send patch information to the puppet-dev list"
103
103
    # Create all of the patches
104
104
    sh "git format-patch -C -M -s -n --subject-prefix='PATCH/puppet' #{parent}..HEAD"
105
105
 
 
106
    # Add info to the patches
 
107
    additional_info = "Local-branch: #{branch}\n"
 
108
    files = Dir.glob("00*.patch")
 
109
    files.each do |file|
 
110
        contents = File.read(file)
 
111
        contents.sub!(/^---\n/, "---\n#{additional_info}")
 
112
        File.open(file, 'w') do |file_handle|
 
113
            file_handle.print contents
 
114
        end
 
115
    end
 
116
 
106
117
    # And then mail them out.
107
118
 
108
119
    # If we've got more than one patch, add --compose
109
 
    if Dir.glob("00*.patch").length > 1
 
120
    if files.length > 1
110
121
        compose = "--compose"
111
122
        subject = "--subject \"#{type} #{name} against #{parent}\""
112
123
    else