heroku-bartender 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,6 +20,9 @@ For now you must run `heroku-bartender` inside your repo dir
20
20
  1. You can rollback your heroku app to a specific commit hash
21
21
  2. You can secure your heroku-bartender server using HTTP Basic Auth
22
22
  3. You can use a custom heroku remote target to deploy your app
23
+ 4. Shows red/yellow/green status for deploys (red: fail, green: ok, yellow: unknow problem)
24
+ 5. Shows dates for deployed versions
25
+ 6. Shows colors/status for old deployed versions (only the versions that are deployed from the start)
23
26
 
24
27
  # TODO
25
28
  1. Keep update the repo
@@ -1,10 +1,29 @@
1
+ require 'grit'
1
2
  module Heroku
2
3
  module Bartender
3
4
  class Command
5
+
6
+ def self.current_version(heroku_remote)
7
+ repo = Grit::Repo.new('.')
8
+ if repo.remote_list.include?(heroku_remote)
9
+ return `git ls-remote #{heroku_remote}`.split("\t").first
10
+ end
11
+ nil
12
+ end
13
+ def self.sha_exist?(sha)
14
+ if sha and not `git show #{sha}`.empty?
15
+ return true
16
+ end
17
+ false
18
+ end
4
19
  # move to an specific commit
5
- # Pending ada more testing stuff
6
20
  def self.move_to release, heroku_remote
7
- `git push -f #{heroku_remote} #{release}:master`
21
+ repo = Grit::Repo.new('.')
22
+ if repo.remote_list.include?(heroku_remote) && sha_exist?(release)
23
+ `git push -f #{heroku_remote} #{release}:master`
24
+ return true
25
+ end
26
+ false
8
27
  end
9
28
  end
10
29
  end
@@ -1,9 +1,9 @@
1
- require "git"
1
+ require "grit"
2
2
  module Heroku
3
3
  module Bartender
4
4
  class Log
5
- def self.get_log(old_commits = 500)
6
- Git.open('.').log(old_commits)
5
+ def self.get_log
6
+ Grit::Repo.new('.').log
7
7
  end
8
8
  def self.generate_commits
9
9
  get_log.map do |item|
@@ -6,16 +6,27 @@ module Heroku
6
6
  @@heroku_remote
7
7
  @@user
8
8
  @@pass
9
+ @@deployed_versions = {}
10
+ @@status = nil
9
11
  dir = File.dirname(File.expand_path(__FILE__))
10
12
  set :views, "#{dir}/views"
11
13
  get "/" do
12
- erb(:template, {}, :commits => Log.generate_commits)
14
+ erb(:template, {}, :commits => Log.generate_commits,
15
+ :current_version => Command.current_version(@@heroku_remote),
16
+ :deployed_versions => @@deployed_versions,
17
+ :status => @@status
18
+ )
13
19
  end
14
20
  post "/" do
15
21
  if params[:sha]
16
- Command.move_to params[:sha], @@heroku_remote
22
+ @@status = Command.move_to params[:sha], @@heroku_remote
23
+ @@deployed_versions[params[:sha]] = [Time.now, @@status]
17
24
  end
18
- erb(:template, {}, :commits => Log.generate_commits)
25
+ erb(:template, {}, :commits => Log.generate_commits,
26
+ :current_version => Command.current_version(@@heroku_remote),
27
+ :deployed_versions => @@deployed_versions,
28
+ :status => @@status
29
+ )
19
30
  end
20
31
  def self.start(host, port, heroku_remote, user, pass)
21
32
  @@heroku_remote = heroku_remote
@@ -29,7 +40,35 @@ module Heroku
29
40
  [username, password] == [user, pass]
30
41
  end
31
42
  end
32
- end
43
+ end
44
+
45
+ helpers do
46
+ include Rack::Utils
47
+ def current_class(current_version_sha, sha)
48
+ sha == current_version_sha ? 'current' : ''
49
+ end
50
+
51
+ def color_status(version_sha)
52
+ if @@deployed_versions[version_sha]
53
+ status = @@deployed_versions[version_sha][1]
54
+ if status == true
55
+ return 'green'
56
+ elsif status == false
57
+ return 'red'
58
+ end
59
+ return 'yellow'
60
+ end
61
+ ''
62
+ end
63
+ def state(status)
64
+ if status == true
65
+ return 'OK'
66
+ elsif status == false
67
+ return 'FAIL'
68
+ end
69
+ 'UNKNOWN'
70
+ end
71
+ end
33
72
  end
34
73
  end
35
74
  end
@@ -1,5 +1,5 @@
1
1
  module Heroku
2
2
  module Bartender
3
- VERSION = '0.2.0'
3
+ VERSION = '0.3.0'
4
4
  end
5
5
  end
@@ -2,24 +2,51 @@
2
2
  <html>
3
3
  <head>
4
4
  <title>Heroku Bartender</title>
5
+ <style type="text/css">
6
+ #home{
7
+ width: 80%;
8
+ float:left;
9
+ }
10
+ #colors{
11
+ margin-left: 81%;
12
+ position: fixed;
13
+ width: 20%;
14
+ }
15
+ .current{
16
+ color: blue;
17
+ }
18
+ .green { background-color: lime; }
19
+ .yellow { background-color: yellow; }
20
+ .red { background-color: red; }
21
+ </style>
5
22
  </head>
6
23
  <body>
7
24
  <div class='title'>
8
25
  <h1> Heroku Bartender </h1>
9
26
  </div>
27
+ <a href="#<%= current_version %>">
28
+ Current version status: <%= state(status) %>
29
+ </a>
10
30
  <div class="site">
11
31
  <div id="home">
12
32
  <ul class="posts">
13
33
  <% commits.each do |commit| %>
14
- <li>
34
+ <li class="<%= current_class(current_version, commit.sha) %> <%= color_status(commit.sha) %>">
35
+ <a name="<%= commit.sha %>"> <%= commit.sha %> </a>
15
36
  <h3> <%= commit.author %> | <%= commit.email %></h3>
16
37
  <p>
17
- <%= commit.sha %>
38
+ <%= commit.message %>
18
39
  </p>
19
40
  <p>
20
- <%= commit.message %>
41
+ <strong> Committed date </strong>
21
42
  <%= commit.date %>
22
43
  </p>
44
+ <% if deployed_versions[commit.sha] %>
45
+ <p>
46
+ <strong> Deployed date </strong>
47
+ <%= deployed_versions[commit.sha][0] %>
48
+ </p>
49
+ <% end %>
23
50
  <form method="POST">
24
51
  <input type="hidden" value="<%= commit.sha %>" name="sha"/>
25
52
  <input type="submit" value="Build"/>
@@ -29,6 +56,17 @@
29
56
  <% end %>
30
57
  </ul>
31
58
  </div>
59
+ <div id='colors'>
60
+ <div class="green">
61
+ Ok: The deploy runs properly
62
+ </div>
63
+ <div class="yellow">
64
+ Unknown: No deployed version, or problems contacting heroku
65
+ </div>
66
+ <div class="red">
67
+ Fail: The deploy goes wrong
68
+ </div>
69
+ </div>
32
70
  </div>
33
71
  </body>
34
72
  </html>
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: heroku-bartender
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.0
5
+ version: 0.3.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Sebastian Arcila-Valenzuela
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-11 00:00:00 -05:00
13
+ date: 2011-03-15 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -25,14 +25,14 @@ dependencies:
25
25
  type: :development
26
26
  version_requirements: *id001
27
27
  - !ruby/object:Gem::Dependency
28
- name: git
28
+ name: grit
29
29
  prerelease: false
30
30
  requirement: &id002 !ruby/object:Gem::Requirement
31
31
  none: false
32
32
  requirements:
33
33
  - - ">="
34
34
  - !ruby/object:Gem::Version
35
- version: 1.2.5
35
+ version: 2.4.1
36
36
  type: :runtime
37
37
  version_requirements: *id002
38
38
  - !ruby/object:Gem::Dependency