Module: Hoe::Hg

Defined in:
lib/hoe/hg.rb

Overview

This module is a Hoe plugin. You can set its attributes in your Rakefile Hoe spec, like this:

Hoe.plugin :hg

Hoe.spec "myproj" do
  self.hg_release_tag_prefix  = "REL_"
  self.hg_repo           = "ssh://[email protected]/me/myrepo"
  self.hg_release_branch  = "default"
end

Tasks

hg:manifest

Update the manifest with Hg’s file list.

hg:tag

Create and push a tag.

Constant Summary collapse

VERSION =
"1.0.5"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#hg_release_branchObject

Returns the value of attribute hg_release_branch.



25
26
27
# File 'lib/hoe/hg.rb', line 25

def hg_release_branch
  @hg_release_branch
end

#hg_release_tag_prefixObject

Returns the value of attribute hg_release_tag_prefix.



24
25
26
# File 'lib/hoe/hg.rb', line 24

def hg_release_tag_prefix
  @hg_release_tag_prefix
end

#hg_repoObject

Returns the value of attribute hg_repo.



25
26
27
# File 'lib/hoe/hg.rb', line 25

def hg_repo
  @hg_repo
end

Instance Method Details

#define_hg_tasksObject

:nodoc:



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/hoe/hg.rb', line 33

def define_hg_tasks #:nodoc:
  return unless File.exist? ".hg"

  desc "Update the manifest with Hg's file list."
  task "hg:manifest" do
    with_config do |config, _|
      files = `hg manifest`.split "\n"
      File.open "Manifest.txt", "w" do |f|
        f.puts files.sort.join("\n")
      end
    end
  end

  desc "Create and push a TAG (default #{hg_release_tag_prefix}#{version})."

  task "hg:tag" do
    puts "tagging and pushing #{hg_release_branch} to '#{hg_repo}' or whatever you have configured in .hg/hgrc."
    tag ||= "#{hg_release_tag_prefix}#{ENV["VERSION"] || version}"

    hg_tag_and_push tag
  end

  task :release_sanity do
    puts 'doing sanity checks'
    unless `hg status`.strip.length==0
      abort "Won't release: Dirty index or untracked files present!"
    end
  end

  task :release => "hg:tag"
end

#hg_tag_and_push(tag) ⇒ Object



65
66
67
68
# File 'lib/hoe/hg.rb', line 65

def hg_tag_and_push tag
  sh "hg tag -m 'tagging #{tag} for release' #{tag}"
  sh "hg push #{hg_repo} -r #{hg_release_branch}" 
end

#initialize_hgObject

:nodoc:



27
28
29
30
31
# File 'lib/hoe/hg.rb', line 27

def initialize_hg #:nodoc:
  self.hg_release_tag_prefix = "r"
  self.hg_release_branch = "default"
  self.hg_repo = ""#use whatever is configured in hgrc
end