Skip to content

Commit

Permalink
create repo spec passes
Browse files Browse the repository at this point in the history
  • Loading branch information
zilkey committed Sep 4, 2010
1 parent 97dfb9c commit a932ef2
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 6 deletions.
14 changes: 13 additions & 1 deletion lib/auto_tagger/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,19 @@ def configuration
end

def ref_name
"refs/#{configuration.ref_path}/#{configuration.stage}/#{Time.now.utc.strftime(configuration.date_separator)}"
"refs/#{configuration.ref_path}/#{configuration.stage}/#{timestamp}"
end

def timestamp
time = Time.now.utc
[
time.strftime("%Y"),
time.strftime("%m"),
time.strftime("%d"),
time.strftime("%H"),
time.strftime("%M"),
time.strftime("%S")
].join(configuration.date_separator)
end

def ensure_stage
Expand Down
33 changes: 28 additions & 5 deletions spec/auto_tagger/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,40 @@
end
end

# describe "#create_ref(commit = nil)" do
# it "should do something" do
# commit ||= repo.latest_commit_sha
# ensure_stage
# repo.refs.fetch("refs/#{configuration.ref_path}/*", configuration.remote) if configuration.fetch_refs?
# new_tag = repo.refs.create(commit, ref_name)
# repo.refs.push("refs/#{configuration.ref_path}/*", configuration.remote) if configuration.push_refs?
# new_tag
# end
# end
#
describe "#create_ref" do
it "creates a ref" do
base = AutoTagger::Base.new :stages => ["ci", "demo", "production"], :stage => "demo"
base.stub(:timestamp).and_return("20081010")

base.repo.should_receive(:latest_commit_sha).and_return("abc123")
base.repo.stub(:exec) { true }
base.repo.should_receive(:exec).with("update-ref refs/tags/demo/20081010 abc123")

ref = base.create_ref
ref.name.should == "refs/tags/demo/20081010"
ref.sha.should == "abc123"
end

it "defaults to the latest commit sha" do
base = AutoTagger::Base.new :stages => ["ci", "demo", "production"], :stage => "demo"
base.stub(:timestamp).and_return("20081010")

base.repo.should_receive(:latest_commit_sha).and_return("abc123")
base.repo.stub(:exec) { true }
base.repo.should_receive(:exec).with("update-ref refs/tags/demo/20081010 abc123")

ref = base.create_ref
ref.name.should == "refs/tags/demo/20081010"
ref.sha.should == "abc123"
end
end

# describe "#cleanup" do
# it "should do something" do
# stage_regexp = Regexp.escape(configuration.stage)
Expand Down

0 comments on commit a932ef2

Please sign in to comment.