libdolt 0.25.0 → 0.26.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,10 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- libdolt (0.25.0)
4
+ libdolt (0.26.0)
5
5
  htmlentities (~> 4.3)
6
6
  json (~> 1.7)
7
- makeup (~> 0.2)
7
+ makeup (~> 0.4)
8
8
  mime-types (~> 1.19)
9
9
  rugged (= 0.18.0.gh.de28323)
10
10
  tzinfo (~> 0.3)
@@ -13,15 +13,23 @@ GEM
13
13
  remote: http://rubygems.org/
14
14
  specs:
15
15
  builder (3.2.2)
16
+ charlock_holmes (0.6.9.4)
16
17
  ci_reporter (1.9.0)
17
18
  builder (>= 2.1.2)
19
+ escape_utils (0.3.2)
20
+ github-linguist (2.8.5)
21
+ charlock_holmes (~> 0.6.6)
22
+ escape_utils (~> 0.3.1)
23
+ mime-types (~> 1.19)
24
+ pygments.rb (~> 0.4.2)
18
25
  github-markup (0.7.5)
19
26
  htmlentities (4.3.1)
20
27
  json (1.8.0)
21
- makeup (0.3.0)
28
+ makeup (0.4.0)
29
+ github-linguist (~> 2.8)
22
30
  github-markup (~> 0.7)
23
31
  htmlentities (~> 4.3)
24
- pygments.rb (~> 0.2)
32
+ pygments.rb (~> 0.4)
25
33
  metaclass (0.0.1)
26
34
  mime-types (1.23)
27
35
  minitest (2.12.1)
@@ -29,7 +37,7 @@ GEM
29
37
  metaclass (~> 0.0.1)
30
38
  multi_json (1.7.7)
31
39
  posix-spawn (0.3.6)
32
- pygments.rb (0.5.1)
40
+ pygments.rb (0.4.2)
33
41
  posix-spawn (~> 0.3.6)
34
42
  yajl-ruby (~> 1.1.0)
35
43
  rake (0.9.6)
@@ -30,7 +30,8 @@ module Dolt
30
30
  def blob(repo, ref, path)
31
31
  repository = resolve_repository(repo)
32
32
  tpl_data(repository, ref, path, {
33
- :blob => repository.rev_parse("#{ref}:#{path}")
33
+ :blob => repository.rev_parse("#{ref}:#{path}"),
34
+ :filemode => filemode(repository, ref, path)
34
35
  })
35
36
  end
36
37
 
@@ -47,13 +48,15 @@ module Dolt
47
48
  key = result.class.to_s.match(/Blob/) ? :blob : :tree
48
49
  hash = tpl_data(repository, ref, path, { key => result, :type => key })
49
50
  hash[:readme] = readme(repo, ref, path) if key == :tree
51
+ hash[:filemode] = filemode(repository, ref, path) if key == :blob
50
52
  hash
51
53
  end
52
54
 
53
55
  def blame(repo, ref, path)
54
56
  repository = resolve_repository(repo)
55
57
  tpl_data(repository, ref, path, {
56
- :blame => repository.blame(ref, path)
58
+ :blame => repository.blame(ref, path),
59
+ :filemode => filemode(repository, ref, path)
57
60
  })
58
61
  end
59
62
 
@@ -120,6 +123,13 @@ module Dolt
120
123
  blob = repository.blob(ref, blob_path)
121
124
  {:blob => blob, :path => blob_path}
122
125
  end
126
+
127
+ def filemode(repo, ref, path)
128
+ file = File.basename(path)
129
+ refspec = "#{ref}:#{File.dirname(path).sub(/^\.$/, '')}"
130
+ entry = repo.rev_parse(refspec).find { |e| e[:name] == file }
131
+ entry.nil? ? nil : entry[:filemode].to_s(8)
132
+ end
123
133
  end
124
134
 
125
135
  class ResolvedRepository
@@ -17,5 +17,5 @@
17
17
  #++
18
18
 
19
19
  module Dolt
20
- VERSION = "0.25.0"
20
+ VERSION = "0.26.0"
21
21
  end
@@ -25,7 +25,14 @@ module Dolt
25
25
  include Dolt::View::SyntaxHighlight
26
26
 
27
27
  def format_text_blob(path, content, repo = nil, ref = nil, options = {})
28
- return render_markup(path, content) if supported_markup_format?(path)
28
+ begin
29
+ return render_markup(path, content) if supported_markup_format?(path)
30
+ rescue StandardError => err
31
+ $stderr.puts("Failed rendering markup in #{path}, render syntax highlighted insted")
32
+ $stderr.puts("Original error was: #{err.name}")
33
+ $stderr.puts(err.backtrace)
34
+ end
35
+
29
36
  highlight_multiline(path, content, options)
30
37
  end
31
38
  end
data/libdolt.gemspec CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
 
16
16
  s.add_dependency "rugged", "0.18.0.gh.de28323"
17
17
  s.add_dependency "tzinfo", "~> 0.3"
18
- s.add_dependency "makeup", "~>0.2"
18
+ s.add_dependency "makeup", "~>0.4"
19
19
  s.add_dependency "htmlentities", "~> 4.3"
20
20
  s.add_dependency "json", "~> 1.7"
21
21
  s.add_dependency "mime-types", "~> 1.19"
@@ -48,11 +48,12 @@ describe Dolt::RepositoryLookup do
48
48
  end
49
49
 
50
50
  describe "#blob" do
51
- it "returns path, blob, repo, ref and base_tree_url" do
51
+ it "returns path, blob, repo, ref, filemode and base_tree_url" do
52
52
  data = @lookup.blob("gitorious", "fc5f5fb50b435e18", "lib/foo.rb")
53
53
  assert_equal "gitorious", data[:repository_slug]
54
54
  assert_equal "fc5f5fb50b435e18", data[:ref]
55
55
  assert Rugged::Blob === data[:blob]
56
+ assert_equal "100644", data[:filemode]
56
57
  end
57
58
  end
58
59
 
@@ -83,12 +84,13 @@ describe Dolt::RepositoryLookup do
83
84
  assert_equal :tree, data[:type]
84
85
  end
85
86
 
86
- it "returns blob, repo and ref" do
87
+ it "returns blob, filemode, repo and ref" do
87
88
  data = @lookup.tree_entry("gitorious", "fc5f5fb50b435e18", "lib/foo.rb")
88
89
 
89
90
  assert_equal "lib/foo.rb", data[:path]
90
91
  assert_equal "fc5f5fb50b435e18", data[:ref]
91
92
  assert_equal :blob, data[:type]
93
+ assert_equal "100644", data[:filemode]
92
94
  end
93
95
  end
94
96
 
@@ -98,12 +100,13 @@ describe Dolt::RepositoryLookup do
98
100
  assert_equal 1, @resolver.resolved.size
99
101
  end
100
102
 
101
- it "returns blame, repo and ref" do
103
+ it "returns blame, filemode, repo and ref" do
102
104
  data = @lookup.blame("gitorious", "fc5f5fb50b435e18", "lib")
103
105
  assert Dolt::Git::Blame === data[:blame]
104
106
  assert_equal "gitorious", data[:repository_slug]
105
107
  assert_equal "fc5f5fb50b435e18", data[:ref]
106
108
  assert_equal "lib", data[:path]
109
+ assert_equal "40000", data[:filemode]
107
110
  end
108
111
  end
109
112
 
@@ -48,14 +48,6 @@ describe Dolt::View::Blob do
48
48
  assert_match "Hey<span class=\"nt\">&lt;/h1&gt;</span>", html
49
49
  end
50
50
 
51
- it "highlights file with custom suffix" do
52
- Makeup::SyntaxHighlighter.add_lexer_alias("derp", "rb")
53
- html = highlight("file.derp", "class File")
54
-
55
- assert_match "<span class=\"k\">class</span>", html
56
- assert_match "<span class=\"nc\">File</span>", html
57
- end
58
-
59
51
  it "skips highlighting if lexer is missing" do
60
52
  html = highlight("file.trololol", "Yeah yeah yeah")
61
53
 
data/views/tree.erb CHANGED
@@ -50,11 +50,18 @@
50
50
  </tbody>
51
51
  </table>
52
52
  <% if readme %>
53
- <div class="gts-readme" id="readme">
54
- <div class="gts-page-header">
55
- <h4><%= readme[:path] %></h4>
53
+ <div class="gts-readme" id="readme">
54
+ <div class="gts-page-header">
55
+ <h4><%= readme[:path] %></h4>
56
+ </div>
57
+ <% begin %>
58
+ <%= format_blob(readme[:path], readme[:blob].text(nil, defined?(Encoding) ? Encoding.default_external : nil), repository_slug, ref) %>
59
+ <% rescue StandardError => err %>
60
+ <p>
61
+ <em>Failed to render <%= readme[:path] %></em>
62
+ <!-- <%= err.message %> -->
63
+ </p>
64
+ <% end %>
56
65
  </div>
57
- <%= format_blob(readme[:path], readme[:blob].text(nil, defined?(Encoding) ? Encoding.default_external : nil), repository_slug, ref) %>
58
- </div>
59
66
  <% end %>
60
67
  </div>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libdolt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.25.0
4
+ version: 0.26.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -50,7 +50,7 @@ dependencies:
50
50
  requirements:
51
51
  - - ~>
52
52
  - !ruby/object:Gem::Version
53
- version: '0.2'
53
+ version: '0.4'
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
@@ -58,7 +58,7 @@ dependencies:
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: '0.2'
61
+ version: '0.4'
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: htmlentities
64
64
  requirement: !ruby/object:Gem::Requirement