mirror of
https://github.com/Fishwaldo/huginn.git
synced 2025-03-15 19:31:26 +00:00
Merge pull request #557 from knu/heroku-reset-repo
Set up the work tree for user in bin/setup_heroku.
This commit is contained in:
commit
f24b7dc910
1 changed files with 29 additions and 2 deletions
|
@ -10,7 +10,11 @@ unless `which heroku` =~ /heroku/
|
|||
end
|
||||
|
||||
def capture(cmd, opts = {})
|
||||
o, s = Open3.capture2e(cmd, opts)
|
||||
if opts.delete(:no_stderr)
|
||||
o, s = Open3.capture2(cmd, opts)
|
||||
else
|
||||
o, s = Open3.capture2e(cmd, opts)
|
||||
end
|
||||
o.strip
|
||||
end
|
||||
|
||||
|
@ -33,7 +37,7 @@ def yes?(question)
|
|||
end
|
||||
|
||||
def grab_heroku_config!
|
||||
config_data = capture("heroku config -s")
|
||||
config_data = capture("heroku config -s", no_stderr: true)
|
||||
$config = {}
|
||||
if config_data !~ /has no config vars/
|
||||
config_data.split("\n").map do |line|
|
||||
|
@ -80,6 +84,29 @@ unless yes?("Your Heroku app name is #{app_name}. Is this correct?")
|
|||
exit 1
|
||||
end
|
||||
|
||||
if (root_id = `git rev-list --max-parents=0 HEAD`.chomp) != '620acffa5a302c6a27165d3214cf3da6be6c1d0d'
|
||||
if (`git remote`.split - %w[heroku]).empty?
|
||||
puts "You don't seem to have cantino/huginn set up as upstream repository."
|
||||
if yes?("Would you like me to set this work tree up for you?")
|
||||
if system('git remote add origin https://github.com/cantino/huginn.git') &&
|
||||
system('git remote update origin')
|
||||
rebase_command = "git rebase #{root_id} --onto origin/master"
|
||||
if system(rebase_command)
|
||||
puts "Done!"
|
||||
else
|
||||
system('git rebase --abort')
|
||||
puts "Rebasing your work tree onto the upstream master failed."
|
||||
puts "Please run the following command and merge your local changes by yourself."
|
||||
puts "\t#{rebase_command}"
|
||||
exit 1
|
||||
end
|
||||
else
|
||||
exit 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
grab_heroku_config!
|
||||
|
||||
if $config.length > 0
|
||||
|
|
Loading…
Add table
Reference in a new issue