File tree Expand file tree Collapse file tree 6 files changed +42
-3
lines changed
rdoc/generator/template/rails Expand file tree Collapse file tree 6 files changed +42
-3
lines changed Original file line number Diff line number Diff line change 2020
2121 < div class ="banner ">
2222 <% if project_name %>
23- < div > <%= project_name %> <%= project_version %> </ div >
23+ < div >
24+ <%= project_name %>
25+ < span title ="<%= project_git_head %> "> <%= badge_version || project_version %> </ span >
26+ </ div >
2427 <% end %>
2528
2629 < h2 >
Original file line number Diff line number Diff line change 1717
1818 < div class ="banner ">
1919 <% if project_name %>
20- < div > <%= project_name %> <%= project_version %> </ div >
20+ < div >
21+ <%= project_name %>
22+ < span title ="<%= project_git_head %> "> <%= badge_version || project_version %> </ span >
23+ </ div >
2124 <% end %>
2225
2326 < h2 >
Original file line number Diff line number Diff line change 1515
1616 < div class ="banner ">
1717 <% if project_name %>
18- < div > <%= project_name %> <%= project_version %> </ div >
18+ < div >
19+ <%= project_name %>
20+ < span title ="<%= project_git_head %> "> <%= badge_version || project_version %> </ span >
21+ </ div >
1922 <% end %>
2023
2124 < h2 >
Original file line number Diff line number Diff line change @@ -41,6 +41,10 @@ def badge_version
4141 h ( ENV [ "HORO_BADGE_VERSION" ] ) if ENV [ "HORO_BADGE_VERSION" ]
4242 end
4343
44+ def project_git_head
45+ h "#{ git_head_branch } @#{ git_head_sha1 [ 0 , 12 ] } " if git?
46+ end
47+
4448 def page_title ( title = nil )
4549 h [ title , @options . title ] . compact . join ( " - " )
4650 end
Original file line number Diff line number Diff line change @@ -20,6 +20,12 @@ def git_command(command)
2020 Dir . chdir ( @options . root ) { `git #{ command } ` . chomp } if git?
2121 end
2222
23+ attr_writer :git_head_branch
24+
25+ def git_head_branch
26+ @git_head_branch ||= git_command ( "rev-parse --abbrev-ref HEAD" )
27+ end
28+
2329 attr_writer :git_head_sha1
2430
2531 def git_head_sha1
Original file line number Diff line number Diff line change @@ -229,6 +229,26 @@ module Foo; module Bar; module Qux; end; end; end
229229 end
230230 end
231231
232+ describe "#project_git_head" do
233+ it "returns the branch name and abbreviated SHA1 of the most recent commit in HEAD" do
234+ @helpers . git_bin_path = "path/to/git"
235+ @helpers . git_head_branch = "1-0-stable"
236+ @helpers . git_head_sha1 = "1337c0d3d00d" * 3
237+
238+ _ ( @helpers . project_git_head ) . must_equal "1-0-stable@1337c0d3d00d"
239+ end
240+
241+ it "returns the branch name and abbreviated SHA1 of the most recent commit in HEAD (smoke test)" do
242+ _ ( @helpers . project_git_head ) . must_match %r"\A .+@[[:xdigit:]]{12}\z "
243+ end
244+
245+ it "returns nil when git is not installed" do
246+ @helpers . git_bin_path = ""
247+
248+ _ ( @helpers . project_git_head ) . must_be_nil
249+ end
250+ end
251+
232252 describe "#page_title" do
233253 it "includes options.title" do
234254 @helpers . options . title = "My Docs"
You can’t perform that action at this time.
0 commit comments