Skip to content

Commit 7f609c3

Browse files
committed
Merge pull request #126 from socialchorus/master
Namespace Git module to avoid collision with the Git gem
2 parents a524585 + 2ad1b16 commit 7f609c3

File tree

10 files changed

+61
-59
lines changed

10 files changed

+61
-59
lines changed

lib/git.rb

-49
This file was deleted.

lib/heroku_san.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require File.join(File.dirname(__FILE__), 'railtie.rb') if defined?(Rails) && Rails::VERSION::MAJOR >= 3
2-
require 'git'
2+
require 'heroku_san/git'
33
require 'heroku_san/api'
44
require 'heroku_san/stage'
55
require 'heroku_san/parser'

lib/heroku_san/git.rb

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
require 'rake'
2+
require 'rake/dsl_definition'
3+
4+
module HerokuSan
5+
module Git
6+
class NoTagFoundError < Exception; end
7+
8+
include Rake::DSL
9+
10+
def git_clone(repos, dir)
11+
sh "git clone #{repos} #{dir}"
12+
end
13+
14+
def git_active_branch
15+
%x{git branch}.split("\n").select { |b| b =~ /^\*/ }.first.split(" ").last.strip
16+
end
17+
18+
def git_push(commit, repo, options = [])
19+
commit ||= "HEAD"
20+
options ||= []
21+
begin
22+
sh "git update-ref refs/heroku_san/deploy #{commit}^{commit}"
23+
sh "git push #{repo} #{options.join(' ')} refs/heroku_san/deploy:refs/heads/master"
24+
ensure
25+
sh "git update-ref -d refs/heroku_san/deploy"
26+
end
27+
end
28+
29+
def git_parsed_tag(tag)
30+
git_rev_parse(git_tag(tag))
31+
end
32+
33+
def git_rev_parse(ref)
34+
return nil if ref.nil?
35+
%x{git rev-parse #{ref}}.split("\n").first
36+
end
37+
38+
def git_tag(glob)
39+
return nil if glob.nil?
40+
%x{git tag -l '#{glob}'}.split("\n").last || (raise NoTagFoundError, "No tag found [#{glob}]")
41+
end
42+
43+
def git_revision(repo)
44+
%x{git ls-remote --heads #{repo} master}.split.first
45+
end
46+
47+
def git_named_rev(ref)
48+
%x{git name-rev #{ref}}.chomp
49+
end
50+
end
51+
end

lib/heroku_san/parser.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module HerokuSan
22
class Parser
3-
include Git
3+
include HerokuSan::Git
44
attr_accessor :settings
55
def parse(parseable)
66
@settings = parse_yaml(parseable.config_file)

lib/heroku_san/project.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module HerokuSan
22
class Project
3-
include Git
3+
include HerokuSan::Git
44
attr_reader :config_file
55
attr_reader :options
66
attr_writer :configuration

lib/heroku_san/stage.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
module HerokuSan
77
class Stage
8-
include Git
8+
include HerokuSan::Git
99
attr_reader :name
1010
attr_reader :options
1111

lib/heroku_san/tasks.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'heroku_san'
22
require 'git'
3-
include Git
3+
include HerokuSan::Git
44

55
if defined?(Rails)
66
HerokuSan.project ||= HerokuSan::Project.new(

lib/heroku_san/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module HerokuSan
2-
VERSION = "4.2.3"
2+
VERSION = "4.2.5"
33
end

spec/git_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'spec_helper'
2-
require 'git'
2+
require 'heroku_san/git'
33

4-
class GitTest; include Git; end
4+
class GitTest; include HerokuSan::Git; end
55

66
describe GitTest do
77
describe "#git_push" do
@@ -44,7 +44,7 @@ class GitTest; include Git; end
4444
subject.should_receive("`").with("git tag -l 'pattern*'") { "\n" }
4545
expect {
4646
subject.git_tag('pattern*')
47-
}.to raise_error(Git::NoTagFoundError)
47+
}.to raise_error(HerokuSan::Git::NoTagFoundError)
4848
end
4949

5050
it "returns nil for a nil glob" do

spec/heroku_san/stage_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'spec_helper'
22

33
describe HerokuSan::Stage do
4-
include Git
4+
include HerokuSan::Git
55
subject { HerokuSan::Stage.new('production', {"deploy" => HerokuSan::Deploy::Rails, "app" => "awesomeapp", "stack" => "cedar"})}
66
STOCK_CONFIG = {"BUNDLE_WITHOUT"=>"development:test", "LANG"=>"en_US.UTF-8", "RACK_ENV"=>"production"}
77
before do

0 commit comments

Comments
 (0)