statusz 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -46,8 +46,15 @@ If you want statusz to write a plain text file or json instead of an html file,
46
46
  Statusz.write_file("statusz.txt", :format => :text)
47
47
  ```
48
48
 
49
+ If you're deploying a commit other than HEAD of the current branch, you can give statusz a treeish
50
+ identifying it (sha or symbolic ref):
51
+
52
+ ``` ruby
53
+ Statusz.write_file("statusz.html", :commit => "HEAD~3")
54
+ ```
55
+
49
56
  If you want statusz to only write some of the fields (skip `commit_search` to save space -- this field
50
- contains every sha in your repo, so it can be kind of large):
57
+ contains the sha of every ancestor of the latest commit in your repo, so it can be kind of large):
51
58
 
52
59
  ``` ruby
53
60
  Statusz.write_file("statusz.html", :fields => ["latest commit", "date", "git user info"])
@@ -57,11 +64,11 @@ Here are the possible fields -- by default, statusz will write them all:
57
64
 
58
65
  * `"git directory"` -- The name of the directory at the git root
59
66
  * `"latest commit"` -- The sha of the latest commit
60
- * `"current branch"` -- The name of the branch, if any, from which the deploy is being run
67
+ * `"containing branches"` -- The name of the branches, if any, that contain the latest commit
61
68
  * `"date"` -- Timestamp
62
69
  * `"current user on deploy host"` -- The output of `whoami`
63
70
  * `"git user info"` -- The user name and email in git
64
- * `"all commits"` -- A list of all commits. In the html version, it's a search box.
71
+ * `"all commits"` -- A list of all ancestors of the latest commit. In the html version, it's a search box.
65
72
 
66
73
  Finally, statusz can write out extra arbitrary fields if you want. Just attach a hash of objects that have
67
74
  meaningful `to_s` representations:
@@ -77,7 +84,7 @@ The only method provided by statusz is `Statusz.write_file(filename = "./statusz
77
84
  full list of possible `options`:
78
85
 
79
86
  * `:format` -- one of `:html`, `:text`, `:json` (defaults to `:html`).
80
- * `:fields` -- an array; some subset of `["git directory", "latest commit", "current branch", "date", "current
87
+ * `:fields` -- an array; some subset of `["git directory", "latest commit", "containing branches", "date", "current
81
88
  user on deploy host", "git user info", "all commits"]` (defaults to the whole thing).
82
89
  * `:extra_fields` -- a hash of arbitrary keys and values that will be stringified. You can override values in
83
90
  `:fields` if you wish.
@@ -1,3 +1,3 @@
1
1
  module Statusz
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/statusz.erb CHANGED
@@ -1,7 +1,7 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
3
  <head>
4
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
4
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
5
5
  <title>statusz</title>
6
6
 
7
7
  <style type="text/css">
data/lib/statusz.rb CHANGED
@@ -5,21 +5,21 @@ require "json"
5
5
 
6
6
  module Statusz
7
7
  FIELD_TO_SCRAPING_PROC = {
8
- "git directory" => Proc.new { `git rev-parse --show-toplevel`.strip.rpartition("/").last },
9
- "latest commit" => Proc.new { `git log --pretty=%H -n 1`.strip },
10
- "current branch" => Proc.new do
11
- branch = `git symbolic-ref HEAD 2> /dev/null`.strip.sub(%r{^refs/heads/}, "")
12
- $?.to_i.zero? ? branch : "<no branch>"
8
+ "git directory" => Proc.new { |commit| `git rev-parse --show-toplevel`.strip.rpartition("/").last },
9
+ "latest commit" => Proc.new { |commit| `git log --pretty=%H #{commit} -n 1`.strip },
10
+ "containing branches" => Proc.new do |commit|
11
+ `git branch --contains #{commit}`.strip.gsub("* ", "").gsub("\n", ", ")
13
12
  end,
14
- "date" => Proc.new { Time.now.strftime("%Y-%m-%d %H:%M:%S %z") },
15
- "current user on deploy host" => Proc.new { `whoami`.strip },
16
- "git user info" => Proc.new do
13
+ "date" => Proc.new { |commit| Time.now.strftime("%Y-%m-%d %H:%M:%S %z") },
14
+ "current user on deploy host" => Proc.new { |commit| `whoami`.strip },
15
+ "git user info" => Proc.new do |commit|
17
16
  "#{`git config --get user.name`.strip} <#{`git config --get user.email`.strip}>"
18
17
  end,
19
- "all commits" => Proc.new { `git log --pretty=%H`.strip }
18
+ "all commits" => Proc.new { |commit| `git log --pretty=%H #{commit}`.strip }
20
19
  }
21
20
 
22
21
  def self.write_file(filename = "./statusz.html", options = {})
22
+ options[:commit] ||= "HEAD"
23
23
  options[:format] ||= :html
24
24
  raise "Bad format: #{options[:format]}" unless [:html, :text, :json].include? options[:format]
25
25
  options[:fields] ||= FIELD_TO_SCRAPING_PROC.keys
@@ -32,7 +32,7 @@ module Statusz
32
32
 
33
33
  results = {}
34
34
  options[:fields].each do |field|
35
- results[field] = FIELD_TO_SCRAPING_PROC[field].call
35
+ results[field] = FIELD_TO_SCRAPING_PROC[field].call(options[:commit])
36
36
  end
37
37
  extra_fields.each { |field, value| results[field.to_s] = value.to_s }
38
38
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: statusz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-06 00:00:00.000000000Z
12
+ date: 2012-08-23 00:00:00.000000000Z
13
13
  dependencies: []
14
14
  description: statusz is a gem that writes out git metadata at deploy time.
15
15
  email:
@@ -52,3 +52,4 @@ signing_key:
52
52
  specification_version: 3
53
53
  summary: statusz is a gem that writes out git metadata at deploy time.
54
54
  test_files: []
55
+ has_rdoc: