~gandelman-a/ubuntu/precise/facter/merge922788

« back to all changes in this revision

Viewing changes to tasks/rake/mail_patches.rake

  • Committer: Package Import Robot
  • Author(s): Adam Gandelman
  • Date: 2011-10-18 10:32:42 UTC
  • mfrom: (1.3.3 upstream)
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: package-import@ubuntu.com-20111018103242-ag8i8vejfp8v7b1b
Tags: upstream-1.6.1
ImportĀ upstreamĀ versionĀ 1.6.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
desc "Send patch information to the puppet-dev list"
2
 
task :mail_patches do
3
 
    if Dir.glob("00*.patch").length > 0
4
 
        raise "Patches already exist matching '00*.patch'; clean up first"
5
 
    end
6
 
 
7
 
    unless %x{git status} =~ /On branch (.+)/
8
 
        raise "Could not get branch from 'git status'"
9
 
    end
10
 
    branch = $1
11
 
 
12
 
    unless branch =~ %r{^([^\/]+)/([^\/]+)/([^\/]+)$}
13
 
        raise "Branch name does not follow <type>/<parent>/<name> model; cannot autodetect parent branch"
14
 
    end
15
 
 
16
 
    type, parent, name = $1, $2, $3
17
 
 
18
 
    # Create all of the patches
19
 
    sh "git format-patch -C -M -s -n --subject-prefix='PATCH/facter' #{parent}..HEAD"
20
 
 
21
 
    # Add info to the patches
22
 
    additional_info = "Local-branch: #{branch}\n"
23
 
    files = Dir.glob("00*.patch")
24
 
    files.each do |file|
25
 
        contents = File.read(file)
26
 
        contents.sub!(/^---\n/, "---\n#{additional_info}")
27
 
        File.open(file, 'w') do |file_handle|
28
 
            file_handle.print contents
29
 
        end
30
 
    end
31
 
 
32
 
    # And then mail them out.
33
 
 
34
 
    # If we've got more than one patch, add --compose
35
 
    if files.length > 1
36
 
        compose = "--compose"
37
 
    else
38
 
        compose = ""
39
 
    end
40
 
 
41
 
    # Now send the mail.
42
 
    sh "git send-email #{compose} --no-signed-off-by-cc --suppress-from --to puppet-dev@googlegroups.com 00*.patch"
43
 
 
44
 
    # Finally, clean up the patches
45
 
    sh "rm 00*.patch"
46
 
end