Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1193 from heroku/fork-deploy-type
Browse files Browse the repository at this point in the history
Record source app id as fork deploy source
  • Loading branch information
jdx committed Aug 22, 2014
2 parents 7dc91fe + 9b05383 commit ff131e4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 5 additions & 3 deletions lib/heroku/command/fork.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def index
end

action("Copying slug") do
copy_slug(from, to)
copy_slug(from_info, to_info)
end

from_config = api.get_config_vars(from).body
Expand Down Expand Up @@ -108,7 +108,9 @@ def index

private

def copy_slug(from, to)
def copy_slug(from_info, to_info)
from = from_info["name"]
to = to_info["name"]
from_releases = api.get_releases_v3(from, 'version ..; order=desc,max=1;').body
raise Heroku::Command::CommandFailed.new("No releases on #{from}") if from_releases.empty?
from_slug = from_releases.first.fetch('slug', {})
Expand All @@ -117,7 +119,7 @@ def copy_slug(from, to)
from_slug["id"],
:description => "Forked from #{from}",
:deploy_type => "fork",
:deploy_source => from)
:deploy_source => from_info["id"])
end

def check_for_pgbackups!(app)
Expand Down
3 changes: 2 additions & 1 deletion spec/heroku/command/fork_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,13 @@ module Heroku::Command
end

it "copies slug" do
from_info = api.get_app("example").body
expect_any_instance_of(Heroku::API).to receive(:get_releases_v3).with("example", "version ..; order=desc,max=1;").and_call_original
expect_any_instance_of(Heroku::API).to receive(:post_release_v3).with("example-fork",
"SLUG_ID",
:description => "Forked from example",
:deploy_type => "fork",
:deploy_source => "example").and_call_original
:deploy_source => from_info["id"]).and_call_original
execute("fork example-fork")
end

Expand Down

0 comments on commit ff131e4

Please sign in to comment.