Set origin and rebase on the master if it has not been done.

Fixes #521.

Akinori MUSHA 10 gadi atpakaļ
vecāks
revīzija
c42489b637
1 mainītis faili ar 23 papildinājumiem un 0 dzēšanām
  1. 23 0
      bin/setup_heroku

+ 23 - 0
bin/setup_heroku

@@ -84,6 +84,29 @@ unless yes?("Your Heroku app name is #{app_name}.  Is this correct?")
84 84
   exit 1
85 85
 end
86 86
 
87
+if (root_id = `git rev-list --max-parents=0 HEAD`.chomp) != '620acffa5a302c6a27165d3214cf3da6be6c1d0d'
88
+  if (`git remote`.split - %w[heroku]).empty?
89
+    puts "You don't seem to have cantino/huginn set up as upstream repository."
90
+    if yes?("Would you like me to set this work tree up for you?")
91
+      if system('git remote add origin https://github.com/cantino/huginn.git') &&
92
+         system('git remote update origin')
93
+        rebase_command = "git rebase #{root_id} --onto origin/master"
94
+        if system(rebase_command)
95
+          puts "Done!"
96
+        else
97
+          system('git rebase --abort')
98
+          puts "Rebasing your work tree onto the upstream master failed."
99
+          puts "Please run the following command and merge your local changes by yourself."
100
+          puts "\t#{rebase_command}"
101
+          exit 1
102
+        end
103
+      else
104
+        exit 1
105
+      end
106
+    end
107
+  end
108
+end
109
+
87 110
 grab_heroku_config!
88 111
 
89 112
 if $config.length > 0