Skip to content
This repository

New Merge request #12

Closed
wants to merge 1 commit into from

1 participant

Ryan Lewon
Ryan Lewon

Some fixes, some patches, some modifications, this should fix general users issues with git@ urls and diff being broken

Some fixes, some patches, some modifications, this should fix general…
… users issues with git@ urls and diff being broken
1d93a7c
Ryan Lewon xorl closed this September 29, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Sep 29, 2011
Some fixes, some patches, some modifications, this should fix general…
… users issues with git@ urls and diff being broken
1d93a7c
This page is out of date. Refresh to see the latest.
5  config/test.rb
@@ -2,4 +2,7 @@
2 2
 
3 3
 Deployinator.issue_tracker = proc do |issue|
4 4
   "https://github.com/example/repo/issues/#{issue}"
5  
-end
  5
+end
  6
+
  7
+Deployinator.default_stack = "demo"
  8
+Deployinator.default_stack = "http"
8  deployinator.rb
@@ -14,6 +14,12 @@ class << self
14 14
     # New Relic logging of deploys
15 15
     attr_accessor :new_relic_options
16 16
 
  17
+    # The default stack name 
  18
+    attr_accessor :default_stack
  19
+
  20
+    # The default protocol, http/https
  21
+    attr_accessor :protocol
  22
+
17 23
     # Hostname where deployinator runs
18 24
     attr_accessor :hostname
19 25
 
@@ -62,4 +68,4 @@ def root(path = nil)
62 68
       path ? File.join(base, path) : base
63 69
     end
64 70
   end
65  
-end
  71
+end
15  helpers.rb
@@ -20,14 +20,14 @@ def set_block(&block)
20 20
     end
21 21
 
22 22
     def init(env)
23  
-      @username = (env["HTTP_X_USERNAME"] || ENV["HTTP_X_USERNAME"]) or raise "Must be logged in"
24  
-      @groups   = CGI.unescape(env["HTTP_X_GROUPS"] || ENV["HTTP_X_GROUPS"]).split("|")
  23
+      #@username = (env["HTTP_X_USERNAME"] || ENV["HTTP_X_USERNAME"]) or raise "Must be logged in"
  24
+      #@groups   = CGI.unescape(env["HTTP_X_GROUPS"] || ENV["HTTP_X_GROUPS"]).split("|")
25 25
       @host     = env["HTTP_HOST"]
26 26
       @local    = @host.match(/local|dev/)
27  
-      @ny4      = @host.match(/ny4/)
28  
-      if @username == "nobody" && ! request.path_info.match(OK_PATH_REGEX)
29  
-        raise "Must be logged in"
30  
-      end
  27
+      #@ny4      = @host.match(/ny4/)
  28
+      #if @username == "nobody" && ! request.path_info.match(OK_PATH_REGEX)
  29
+      #  raise "Must be logged in"
  30
+      #end
31 31
       @stack = form_hash(env, "stack") unless @stack
32 32
       @filename = "#{Time.now.to_i}-#{@username}-#{dep_method(env)}.html"
33 33
     end
@@ -133,7 +133,7 @@ def log_and_shout(options={})
133 133
     # Actual helper methods
134 134
 
135 135
     def diff_url(stack, old_build, new_build)
136  
-      "http://#{Deployinator.hostname}/diff/#{stack}/#{old_build}/#{new_build}"
  136
+      "#{Deployinator.protocol}://#{Deployinator.hostname}/diff/#{stack}/#{old_build}/#{new_build}"
137 137
     end
138 138
 
139 139
     def stack
@@ -182,7 +182,6 @@ def head_build
182 182
 
183 183
     def use_github(stack, rev1, rev2)
184 184
       # Hackery
185  
-      raise self.send("#{stack.to_s}_git_repo_url")
186 185
       return true if self.respond_to?(stack.to_s + "_git_repo_url")
187 186
       return false if [rev1, rev2].all? {|r| r.match(/^\d{5}$/)}
188 187
       return true if github_info_for_stack.key?(stack)
23  lib/app.rb
@@ -18,7 +18,11 @@ class App < Sinatra::Base
18 18
     end
19 19
 
20 20
     get '/' do
21  
-      @stack = "demo"
  21
+      if Deployinator.default_stack 
  22
+        @stack = Deployinator::default_stack
  23
+      else 
  24
+        @stack = "demo"
  25
+      end
22 26
       mustache @stack
23 27
     end
24 28
 
@@ -56,10 +60,6 @@ class App < Sinatra::Base
56 60
       inst.push_order.collect {|env| [env, inst.send(meth % env)]}.to_json
57 61
     end
58 62
 
59  
-    get '/last_chef' do
60  
-      chef_commits.gsub(/\n/, "<br>\n")
61  
-    end
62  
-
63 63
     get '/last_pushes' do
64 64
       @stack = params[:stack] || "web"
65 65
       @dep_env = params[:env] || "production"
@@ -155,9 +155,16 @@ def version_for_and_before(stack, env)
155 155
       stack = params[:stack].to_sym
156 156
       if Deployinator::Helpers.respond_to?(stack.to_s + "_git_repo_url")
157 157
         repo_url = Deployinator::Helpers.send(stack.to_s + "_git_repo_url")
158  
-        parts = repo_url.split("/")
159  
-        user = parts[3]
160  
-        repo = parts[4].gsub(/\.git$/, "")
  158
+	if repo_url == /https:\/\//
  159
+          parts = repo_url.split("/")
  160
+          user = parts[3]
  161
+          repo = parts[4].gsub(/\.git$/, "")
  162
+        elsif repo_url == /git@github/
  163
+          user_actual = parts[0].split(":")
  164
+          user = user_actual[1] 
  165
+          repo = parts[1].gsub(/\.git$/, "")
  166
+        end
  167
+
161 168
         redirect "#{github_url}#{user}/#{repo}/compare/#{params[:r1]}...#{params[:r2]}"
162 169
       else
163 170
         gh_info = github_info_for_stack[stack]
4  templates/layout.mustache
@@ -6,8 +6,8 @@
6 6
         <link rel="shortcut icon" href="/favicon.ico">
7 7
         <link rel="stylesheet" href="/css/highlight.css" type="text/css" media="screen">
8 8
         <link rel="stylesheet" href="/css/style.css" type="text/css" media="screen">
9  
-        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
10  
-        <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
  9
+        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
  10
+        <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
11 11
     </head>
12 12
     <body>
13 13
         <div id="content" class="clearfix">
10  views/view_helpers.rb
@@ -5,6 +5,10 @@ module ViewHelpers
5 5
 
6 6
       HEADER_URL_EXCLUDE_STACKS = %w[web stats atlas api]
7 7
 
  8
+      def protocol
  9
+        Deployinator.protocol
  10
+      end
  11
+
8 12
       def push_order
9 13
         %w[production]
10 14
       end
@@ -18,11 +22,11 @@ def groups
18 22
       end
19 23
 
20 24
       def my_url
21  
-        "http://#{@host}"
  25
+        "#{protocol}://#{@host}"
22 26
       end
23 27
 
24 28
       def logout_url
25  
-        "http://#{auth_url}?logout=true&return=#{my_url}"
  29
+        "#{protocol}://#{auth_url}?logout=true&return=#{my_url}"
26 30
       end
27 31
 
28 32
       def current_stack_url
@@ -31,7 +35,7 @@ def current_stack_url
31 35
         else
32 36
           destination = ""
33 37
         end
34  
-        "http://#{@host}/#{destination}"
  38
+        "#{protocol}://#{@host}/#{destination}"
35 39
       end
36 40
 
37 41
       def allowed_to_push_to_prod?
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.