diff --git a/lib/integrity/builder.rb b/lib/integrity/builder.rb index ae1d494d..e698e3fb 100644 --- a/lib/integrity/builder.rb +++ b/lib/integrity/builder.rb @@ -11,8 +11,12 @@ def initialize(project) @build = Build.new(:project => project) end - def build - @scm.with_latest_code { run_build_script } + def build(commit=nil) + if commit + @scm.with_revision(commit) { run_build_script } + else + @scm.with_latest_code { run_build_script } + end @build ensure @build.commit = @scm.head diff --git a/spec/builder_spec.rb b/spec/builder_spec.rb index 89f0d3b1..72374a8f 100644 --- a/spec/builder_spec.rb +++ b/spec/builder_spec.rb @@ -67,6 +67,14 @@ def mock_scm(messages={}) end @builder.build end + + it 'should checkout the given commit from the scm and run the build script' do + mock_scm.should_receive(:with_revision). + with('6437fa27779daba40dbd130e2937d36253be1d4c').and_yield do + @builder.should_receive(:run_build_script) + end + @builder.build('6437fa27779daba40dbd130e2937d36253be1d4c') + end it "should assign the head of the SCM as the commit in the build" do mock_build.should_receive(:commit=).with mock_scm.head