web_git 0.0.2 → 0.0.2.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 89d8eef92b2c4cb8ca66b0ab374148141681c23a48546d6527f9f20142fdd53e
4
- data.tar.gz: 1d650a1dd33ae931104e89fde068fe22de2c03f9c7baa8ef34095510493b12d9
3
+ metadata.gz: de9efa350ad3a729b36039c0da0555e64c76e965b3b309916f3da6c018ff947e
4
+ data.tar.gz: 3af448fbbd8b2d7c022caf23f4b63e7cd34d4139179e913c79c36dd1c9e81098
5
5
  SHA512:
6
- metadata.gz: 72a468c367e5e54661d2fed60e95b3481f20a044a16fcfb152300930d94a065937b8c5a3e8dbf6e869c3d791b25d16c18ff01983b31f52d4c54655cee681bfea
7
- data.tar.gz: 5421ce8a8b8bf1ddbeee887850c55a0f3d6cad9ee12f6a1e425b8c624263cefeea74a6ccb9fe66eae81d66becf7841d08eaf96541dfc7df1b788f3d637e23dd2
6
+ metadata.gz: a66041301627a64606643f14bbd00ecb13e342d16e5d8f1b3bf86532226cc44101e7b7ad0158fc0935fa4072f7a2688e8a2d84e71f6e73c0af020ce6015aef1c
7
+ data.tar.gz: 68b6d7b6bf6c35774f54a47b34f9646aecb85a3b76ccb60a18a03bdb5d78fbc9a1b9c4e90a2d9e1dc70cff593b02de1cc4919ea20136f322ebfc4ffa46d1efb5
data/Gemfile CHANGED
@@ -8,7 +8,7 @@ source "https://rubygems.org"
8
8
  group :development do
9
9
  gem "rspec", "~> 3.5.0"
10
10
  gem "rdoc", "~> 3.12"
11
- gem "bundler", "~> 1.0"
11
+ # gem "bundler", "~> 1.0"
12
12
  gem "juwelier", "~> 2.1.0"
13
13
  gem "simplecov", ">= 0"
14
14
  gem "pry", "~> 0"
@@ -19,7 +19,6 @@ group :development do
19
19
  gem "pry-stack_explorer", "~> 0"
20
20
  end
21
21
 
22
- gem "diffy"
23
22
  # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
24
23
  gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]
25
24
 
data/Gemfile.lock CHANGED
@@ -1,43 +1,43 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- actioncable (5.2.2.1)
5
- actionpack (= 5.2.2.1)
4
+ actioncable (5.2.3)
5
+ actionpack (= 5.2.3)
6
6
  nio4r (~> 2.0)
7
7
  websocket-driver (>= 0.6.1)
8
- actionmailer (5.2.2.1)
9
- actionpack (= 5.2.2.1)
10
- actionview (= 5.2.2.1)
11
- activejob (= 5.2.2.1)
8
+ actionmailer (5.2.3)
9
+ actionpack (= 5.2.3)
10
+ actionview (= 5.2.3)
11
+ activejob (= 5.2.3)
12
12
  mail (~> 2.5, >= 2.5.4)
13
13
  rails-dom-testing (~> 2.0)
14
- actionpack (5.2.2.1)
15
- actionview (= 5.2.2.1)
16
- activesupport (= 5.2.2.1)
14
+ actionpack (5.2.3)
15
+ actionview (= 5.2.3)
16
+ activesupport (= 5.2.3)
17
17
  rack (~> 2.0)
18
18
  rack-test (>= 0.6.3)
19
19
  rails-dom-testing (~> 2.0)
20
20
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
21
- actionview (5.2.2.1)
22
- activesupport (= 5.2.2.1)
21
+ actionview (5.2.3)
22
+ activesupport (= 5.2.3)
23
23
  builder (~> 3.1)
24
24
  erubi (~> 1.4)
25
25
  rails-dom-testing (~> 2.0)
26
26
  rails-html-sanitizer (~> 1.0, >= 1.0.3)
27
- activejob (5.2.2.1)
28
- activesupport (= 5.2.2.1)
27
+ activejob (5.2.3)
28
+ activesupport (= 5.2.3)
29
29
  globalid (>= 0.3.6)
30
- activemodel (5.2.2.1)
31
- activesupport (= 5.2.2.1)
32
- activerecord (5.2.2.1)
33
- activemodel (= 5.2.2.1)
34
- activesupport (= 5.2.2.1)
30
+ activemodel (5.2.3)
31
+ activesupport (= 5.2.3)
32
+ activerecord (5.2.3)
33
+ activemodel (= 5.2.3)
34
+ activesupport (= 5.2.3)
35
35
  arel (>= 9.0)
36
- activestorage (5.2.2.1)
37
- actionpack (= 5.2.2.1)
38
- activerecord (= 5.2.2.1)
36
+ activestorage (5.2.3)
37
+ actionpack (= 5.2.3)
38
+ activerecord (= 5.2.3)
39
39
  marcel (~> 0.3.1)
40
- activesupport (5.2.2.1)
40
+ activesupport (5.2.3)
41
41
  concurrent-ruby (~> 1.0, >= 1.0.2)
42
42
  i18n (>= 0.7, < 2)
43
43
  minitest (~> 5.1)
@@ -56,8 +56,7 @@ GEM
56
56
  descendants_tracker (0.0.4)
57
57
  thread_safe (~> 0.3, >= 0.3.1)
58
58
  diff-lcs (1.3)
59
- diffy (3.3.0)
60
- docile (1.3.1)
59
+ docile (1.3.2)
61
60
  erubi (1.8.0)
62
61
  faraday (0.15.4)
63
62
  multipart-post (>= 1.2, < 3)
@@ -73,11 +72,11 @@ GEM
73
72
  globalid (0.4.2)
74
73
  activesupport (>= 4.2.0)
75
74
  hashie (3.6.0)
76
- highline (2.0.1)
75
+ highline (2.0.2)
77
76
  i18n (1.6.0)
78
77
  concurrent-ruby (~> 1.0)
79
78
  interception (0.5)
80
- jquery-rails (4.3.3)
79
+ jquery-rails (4.3.5)
81
80
  rails-dom-testing (>= 1, < 3)
82
81
  railties (>= 4.2.0)
83
82
  thor (>= 0.14, < 2.0)
@@ -92,7 +91,7 @@ GEM
92
91
  rake
93
92
  rdoc
94
93
  semver
95
- jwt (2.1.0)
94
+ jwt (2.2.1)
96
95
  loofah (2.2.3)
97
96
  crass (~> 1.0.2)
98
97
  nokogiri (>= 1.5.9)
@@ -107,9 +106,9 @@ GEM
107
106
  minitest (5.11.3)
108
107
  multi_json (1.13.1)
109
108
  multi_xml (0.6.0)
110
- multipart-post (2.0.0)
109
+ multipart-post (2.1.1)
111
110
  nio4r (2.3.1)
112
- nokogiri (1.10.2)
111
+ nokogiri (1.10.3)
113
112
  mini_portile2 (~> 2.4.0)
114
113
  oauth2 (1.4.1)
115
114
  faraday (>= 0.8, < 0.16.0)
@@ -117,10 +116,10 @@ GEM
117
116
  multi_json (~> 1.3)
118
117
  multi_xml (~> 0.5)
119
118
  rack (>= 1.2, < 3)
120
- octicons (8.5.0)
119
+ octicons (9.1.0)
121
120
  nokogiri (>= 1.6.3.1)
122
- octicons_helper (8.5.0)
123
- octicons (= 8.5.0)
121
+ octicons_helper (9.1.0)
122
+ octicons (= 9.1.0)
124
123
  rails
125
124
  pry (0.12.2)
126
125
  coderay (~> 1.1.0)
@@ -140,31 +139,31 @@ GEM
140
139
  pry-stack_explorer (0.4.9.3)
141
140
  binding_of_caller (>= 0.7)
142
141
  pry (>= 0.9.11)
143
- public_suffix (3.0.3)
144
- rack (2.0.6)
142
+ public_suffix (3.1.0)
143
+ rack (2.0.7)
145
144
  rack-test (1.1.0)
146
145
  rack (>= 1.0, < 3)
147
- rails (5.2.2.1)
148
- actioncable (= 5.2.2.1)
149
- actionmailer (= 5.2.2.1)
150
- actionpack (= 5.2.2.1)
151
- actionview (= 5.2.2.1)
152
- activejob (= 5.2.2.1)
153
- activemodel (= 5.2.2.1)
154
- activerecord (= 5.2.2.1)
155
- activestorage (= 5.2.2.1)
156
- activesupport (= 5.2.2.1)
146
+ rails (5.2.3)
147
+ actioncable (= 5.2.3)
148
+ actionmailer (= 5.2.3)
149
+ actionpack (= 5.2.3)
150
+ actionview (= 5.2.3)
151
+ activejob (= 5.2.3)
152
+ activemodel (= 5.2.3)
153
+ activerecord (= 5.2.3)
154
+ activestorage (= 5.2.3)
155
+ activesupport (= 5.2.3)
157
156
  bundler (>= 1.3.0)
158
- railties (= 5.2.2.1)
157
+ railties (= 5.2.3)
159
158
  sprockets-rails (>= 2.0.0)
160
159
  rails-dom-testing (2.0.3)
161
160
  activesupport (>= 4.2.0)
162
161
  nokogiri (>= 1.6)
163
162
  rails-html-sanitizer (1.0.4)
164
163
  loofah (~> 2.2, >= 2.2.2)
165
- railties (5.2.2.1)
166
- actionpack (= 5.2.2.1)
167
- activesupport (= 5.2.2.1)
164
+ railties (5.2.3)
165
+ actionpack (= 5.2.3)
166
+ activesupport (= 5.2.3)
168
167
  method_source
169
168
  rake (>= 0.8.7)
170
169
  thor (>= 0.19.0, < 2.0)
@@ -208,17 +207,15 @@ GEM
208
207
  tzinfo (1.2.5)
209
208
  thread_safe (~> 0.1)
210
209
  uri-ssh_git (2.0.0)
211
- websocket-driver (0.7.0)
210
+ websocket-driver (0.7.1)
212
211
  websocket-extensions (>= 0.1.0)
213
- websocket-extensions (0.1.3)
214
- yard (0.9.18)
212
+ websocket-extensions (0.1.4)
213
+ yard (0.9.19)
215
214
 
216
215
  PLATFORMS
217
216
  ruby
218
217
 
219
218
  DEPENDENCIES
220
- bundler (~> 1.0)
221
- diffy
222
219
  git_clone_url
223
220
  jquery-rails
224
221
  juwelier (~> 2.1.0)
@@ -237,4 +234,4 @@ DEPENDENCIES
237
234
  tzinfo-data
238
235
 
239
236
  BUNDLED WITH
240
- 1.17.2
237
+ 2.0.2
data/README.markdown CHANGED
@@ -6,6 +6,10 @@ WebGit is a Rails Engine that provides an in-browser visual interface to a simpl
6
6
 
7
7
  ## Installation
8
8
 
9
+ You need to have the `diff2html-cli` command available on your system. You can install it with:
10
+
11
+ ```
12
+ npm install -g diff2html-cli
9
13
  ```
10
14
 
11
15
  Add this line to your application's Gemfile:
data/Rakefile CHANGED
@@ -19,7 +19,7 @@ Juwelier::Tasks.new do |gem|
19
19
  gem.summary = %Q{An in-browser Git GUI for your Rails project}
20
20
  gem.description = %Q{WebGit is a Rails Engine that provides an in-browser visual interface to a simple but effective Git workflow. For educational purposes.}
21
21
  gem.email = "raghu@firstdraft.com"
22
- gem.authors = ["Raghu Betina", "Jelani Woods"]
22
+ gem.authors = ["Raghu Betina"]
23
23
 
24
24
  # dependencies defined in Gemfile
25
25
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.2.1
@@ -23,10 +23,15 @@ module WebGit
23
23
  diff = `git diff`
24
24
 
25
25
  unless diff.blank?
26
- @diff_html = WebGit::Diff.diff_to_html(diff)
26
+ @diff_html = `diff2html --style=side --output=stdout`.
27
+ gsub("<h1>Diff to HTML by <a href=\"https://github.com/rtfpessoa\">rtfpessoa</a></h1>", "").
28
+ gsub("<a class=\"d2h-file-switch d2h-hide\">hide</a>", "").
29
+ gsub("<a class=\"d2h-file-switch d2h-show\">show</a>", "")
27
30
  else
28
- last_diff = WebGit::Diff.get_last_diff
29
- @last_diff_html = WebGit::Diff.last_to_html(last_diff)
31
+ @last_diff_html = `diff2html --style=line --output=stdout -- -M HEAD~1`.
32
+ gsub("<h1>Diff to HTML by <a href=\"https://github.com/rtfpessoa\">rtfpessoa</a></h1>", "").
33
+ gsub("<a class=\"d2h-file-switch d2h-hide\">hide</a>", "").
34
+ gsub("<a class=\"d2h-file-switch d2h-show\">show</a>", "")
30
35
 
31
36
  @last_commit_message = `git log -1 --pretty=%B`
32
37
  end
@@ -41,7 +46,5 @@ module WebGit
41
46
  # render "web_git/commands/hello.html.erb"
42
47
  render "web_git/commands/status.html.erb", layout: "web_git/application"
43
48
  end
44
-
45
49
  end
46
-
47
50
  end
@@ -116,7 +116,7 @@
116
116
  <%= simple_format @status %>
117
117
  </pre>
118
118
 
119
- <%= link_to commits_push_url, class: "btn btn-primary btn-block mb-4", data: { toggle: "tooltip", html: true }, title: "<code>git push</code>" do %>
119
+ <%= button_to commits_push_url, disabled: true, class: "btn btn-primary btn-block mb-4", data: { toggle: "tooltip", html: true }, title: "<code>git push</code>" do %>
120
120
  <%= octicon "repo-push", class: "mr-1" %>
121
121
 
122
122
  Push to GitHub
@@ -130,7 +130,7 @@
130
130
  <% end %>
131
131
  <% end %>
132
132
 
133
- <%= link_to commits_pull_url, class: "btn btn-primary btn-block mb-4", data: { toggle: "tooltip", html: true }, title: "<code>git pull</code>" do %>
133
+ <%= button_to commits_pull_url, disabled: true, class: "btn btn-primary btn-block mb-4", data: { toggle: "tooltip", html: true }, title: "<code>git pull</code>" do %>
134
134
  <%= octicon "repo-pull", class: "mr-1" %>
135
135
 
136
136
  Pull from GitHub
data/lib/web_git.rb CHANGED
@@ -1,6 +1,4 @@
1
1
  require "web_git/engine"
2
- require "web_git/diff"
3
- require "diffy"
4
2
  require "jquery-rails"
5
3
  require "octicons_helper"
6
4
  require "tether-rails"
data/web_git-0.0.2.gem ADDED
Binary file
data/web_git.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: web_git 0.0.1 ruby lib
5
+ # stub: web_git 0.0.3 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "web_git".freeze
9
- s.version = "0.0.1"
9
+ s.version = "0.0.3"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
- s.authors = ["Raghu Betina".freeze, "Jelani Woods".freeze]
14
- s.date = "2019-05-06"
13
+ s.authors = ["Raghu Betina".freeze]
14
+ s.date = "2019-07-11"
15
15
  s.description = "WebGit is a Rails Engine that provides an in-browser visual interface to a simple but effective Git workflow. For educational purposes.".freeze
16
16
  s.email = "raghu@firstdraft.com".freeze
17
17
  s.extra_rdoc_files = [
@@ -41,24 +41,24 @@ Gem::Specification.new do |s|
41
41
  "app/controllers/web_git/commands_controller.rb",
42
42
  "app/controllers/web_git/commits_controller.rb",
43
43
  "app/views/layouts/web_git/application.html.erb",
44
+ "app/views/web_git/commands/hello.html.erb",
44
45
  "app/views/web_git/commands/status.html.erb",
45
46
  "config/routes.rb",
46
47
  "lib/web_git.rb",
47
- "lib/web_git/diff.rb",
48
48
  "lib/web_git/engine.rb",
49
49
  "lib/web_git/version.rb",
50
+ "web_git-0.0.2.gem",
50
51
  "web_git.gemspec"
51
52
  ]
52
53
  s.homepage = "http://github.com/firstdraft/web_git".freeze
53
54
  s.licenses = ["MIT".freeze]
54
- s.rubygems_version = "3.0.1".freeze
55
+ s.rubygems_version = "2.7.8".freeze
55
56
  s.summary = "An in-browser Git GUI for your Rails project".freeze
56
57
 
57
58
  if s.respond_to? :specification_version then
58
59
  s.specification_version = 4
59
60
 
60
61
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
61
- s.add_runtime_dependency(%q<diffy>.freeze, [">= 0"])
62
62
  s.add_runtime_dependency(%q<tzinfo-data>.freeze, [">= 0"])
63
63
  s.add_runtime_dependency(%q<tether-rails>.freeze, [">= 0"])
64
64
  s.add_runtime_dependency(%q<octicons_helper>.freeze, [">= 0"])
@@ -67,7 +67,6 @@ Gem::Specification.new do |s|
67
67
  s.add_runtime_dependency(%q<git_clone_url>.freeze, [">= 0"])
68
68
  s.add_development_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
69
69
  s.add_development_dependency(%q<rdoc>.freeze, ["~> 3.12"])
70
- s.add_development_dependency(%q<bundler>.freeze, ["~> 1.0"])
71
70
  s.add_development_dependency(%q<juwelier>.freeze, ["~> 2.1.0"])
72
71
  s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
73
72
  s.add_development_dependency(%q<pry>.freeze, ["~> 0"])
@@ -77,7 +76,6 @@ Gem::Specification.new do |s|
77
76
  s.add_development_dependency(%q<pry-rescue>.freeze, ["~> 1"])
78
77
  s.add_development_dependency(%q<pry-stack_explorer>.freeze, ["~> 0"])
79
78
  else
80
- s.add_dependency(%q<diffy>.freeze, [">= 0"])
81
79
  s.add_dependency(%q<tzinfo-data>.freeze, [">= 0"])
82
80
  s.add_dependency(%q<tether-rails>.freeze, [">= 0"])
83
81
  s.add_dependency(%q<octicons_helper>.freeze, [">= 0"])
@@ -86,7 +84,6 @@ Gem::Specification.new do |s|
86
84
  s.add_dependency(%q<git_clone_url>.freeze, [">= 0"])
87
85
  s.add_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
88
86
  s.add_dependency(%q<rdoc>.freeze, ["~> 3.12"])
89
- s.add_dependency(%q<bundler>.freeze, ["~> 1.0"])
90
87
  s.add_dependency(%q<juwelier>.freeze, ["~> 2.1.0"])
91
88
  s.add_dependency(%q<simplecov>.freeze, [">= 0"])
92
89
  s.add_dependency(%q<pry>.freeze, ["~> 0"])
@@ -97,7 +94,6 @@ Gem::Specification.new do |s|
97
94
  s.add_dependency(%q<pry-stack_explorer>.freeze, ["~> 0"])
98
95
  end
99
96
  else
100
- s.add_dependency(%q<diffy>.freeze, [">= 0"])
101
97
  s.add_dependency(%q<tzinfo-data>.freeze, [">= 0"])
102
98
  s.add_dependency(%q<tether-rails>.freeze, [">= 0"])
103
99
  s.add_dependency(%q<octicons_helper>.freeze, [">= 0"])
@@ -106,7 +102,6 @@ Gem::Specification.new do |s|
106
102
  s.add_dependency(%q<git_clone_url>.freeze, [">= 0"])
107
103
  s.add_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
108
104
  s.add_dependency(%q<rdoc>.freeze, ["~> 3.12"])
109
- s.add_dependency(%q<bundler>.freeze, ["~> 1.0"])
110
105
  s.add_dependency(%q<juwelier>.freeze, ["~> 2.1.0"])
111
106
  s.add_dependency(%q<simplecov>.freeze, [">= 0"])
112
107
  s.add_dependency(%q<pry>.freeze, ["~> 0"])
metadata CHANGED
@@ -1,30 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: web_git
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raghu Betina
8
- - Jelani Woods
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2019-07-09 00:00:00.000000000 Z
11
+ date: 2019-07-11 00:00:00.000000000 Z
13
12
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: diffy
16
- requirement: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - ">="
19
- - !ruby/object:Gem::Version
20
- version: '0'
21
- type: :runtime
22
- prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- version: '0'
28
13
  - !ruby/object:Gem::Dependency
29
14
  name: tzinfo-data
30
15
  requirement: !ruby/object:Gem::Requirement
@@ -137,20 +122,6 @@ dependencies:
137
122
  - - "~>"
138
123
  - !ruby/object:Gem::Version
139
124
  version: '3.12'
140
- - !ruby/object:Gem::Dependency
141
- name: bundler
142
- requirement: !ruby/object:Gem::Requirement
143
- requirements:
144
- - - "~>"
145
- - !ruby/object:Gem::Version
146
- version: '1.0'
147
- type: :development
148
- prerelease: false
149
- version_requirements: !ruby/object:Gem::Requirement
150
- requirements:
151
- - - "~>"
152
- - !ruby/object:Gem::Version
153
- version: '1.0'
154
125
  - !ruby/object:Gem::Dependency
155
126
  name: juwelier
156
127
  requirement: !ruby/object:Gem::Requirement
@@ -298,10 +269,9 @@ files:
298
269
  - app/views/web_git/commands/status.html.erb
299
270
  - config/routes.rb
300
271
  - lib/web_git.rb
301
- - lib/web_git/diff.rb
302
272
  - lib/web_git/engine.rb
303
273
  - lib/web_git/version.rb
304
- - web_git-0.0.1.gem
274
+ - web_git-0.0.2.gem
305
275
  - web_git.gemspec
306
276
  homepage: http://github.com/firstdraft/web_git
307
277
  licenses:
data/lib/web_git/diff.rb DELETED
@@ -1,233 +0,0 @@
1
- module WebGit
2
- class Diff
3
- def self.get_diff
4
- Dir.chdir(Rails.root) do
5
- `git diff`
6
- end
7
- end
8
-
9
- def self.get_each_left(diff)
10
- filenames = get_file_names("")
11
- files = file_diffs(diff)
12
- lefts = {}
13
- files.each_with_index do |file, i|
14
- file_content = ""
15
- lines = file.split("\n").drop(4)
16
- start_line = 0
17
- current_line_index = 0
18
- line_number = start_line + current_line_index
19
- lines.each do |line|
20
- if !line.match?(/@@ ([-]\d+,\d+\s[+]\d+,\d+) @@/)
21
- if line.first != "+"
22
- file_content += "#{line_number}| " + line + "\n"
23
- line_number += 1
24
- end
25
- else
26
- current_line_index = 0
27
- # The line numbers in the output of a git diff match this regex
28
- numbers = line.scan(/@@ ([-]\d+,\d+\s[+]\d+,\d+) @@/).map(&:join)
29
- # If left, starting line number is the first one in a split Array
30
- start_line = numbers.first.split(" ").first.
31
- split(",").first.to_i.abs
32
- line_number = start_line + current_line_index
33
- file_content += "\n"
34
- end
35
- end
36
- lefts[filenames[i]] = file_content.chomp "\n"
37
- end
38
- lefts
39
- end
40
-
41
- def self.get_each_right(diff)
42
- filenames = get_file_names("")
43
- files = file_diffs(diff)
44
- rights = {}
45
- files.each_with_index do |file, i|
46
- file_content = ""
47
- lines = file.split("\n").drop(4)
48
- start_line = 0
49
- current_line_index = 0
50
- line_number = start_line + current_line_index
51
- lines.each do |line|
52
- # The line numbers in the output of a git diff match this regex
53
- # @@ -61,18 +61,15 @@
54
- if !line.match?(/@@ ([-]\d+,\d+\s[+]\d+,\d+) @@/)
55
- if line.first != "-"
56
- file_content += "#{line_number}| " + line + "\n"
57
- line_number += 1
58
- end
59
- else
60
- current_line_index = 0
61
- numbers = line.scan(/@@ ([-]\d+,\d+\s[+]\d+,\d+) @@/).map(&:join)
62
- # If right, start line is the second in a split Array
63
- start_line = numbers.first.split(" ").second.
64
- split(",").first.to_i.abs
65
- line_number = start_line + current_line_index
66
- file_content += "\n"
67
- end
68
- end
69
- rights[filenames[i]] = file_content.chomp "\n"
70
- end
71
- rights
72
- end
73
-
74
- def self.get_last_commit_hash
75
- Dir.chdir(Rails.root) do
76
- log = `git log -1 --oneline`
77
- log.split.first
78
- end
79
- end
80
-
81
- def self.file_diffs(diff)
82
- diff.scan(/diff --git.*?(?=diff --git|\z)/m)
83
- end
84
-
85
- def self.match_other_files(line, file, filenames)
86
- filenames.each do |other_file|
87
- if file != other_file
88
- # It looks like:
89
- # --- a/<path-to-file>
90
- # +++ b/<path-to-file>
91
- if line.include?('diff --git a/' + other_file + ' b/' + other_file)
92
- return true
93
- end
94
- end
95
- end
96
- false
97
- end
98
-
99
- def self.get_file_names(commit)
100
- Dir.chdir(Rails.root) do
101
- if commit.blank?
102
- filenames = `git diff --name-only`
103
- else
104
- filenames = `git diff-tree --no-commit-id --name-only -r #{commit}`
105
- end
106
- filenames.split("\n")
107
- end
108
- end
109
-
110
- def self.get_last_diff
111
- Dir.chdir(Rails.root) do
112
- `git diff -M HEAD~1`
113
- end
114
- end
115
-
116
- def self.get_last_left(diff)
117
- filenames = get_file_names(get_last_commit_hash)
118
- files = file_diffs(diff)
119
- ones = {}
120
- files.each_with_index do |file, i|
121
- file_content = ""
122
- lines = file.split("\n").drop(4)
123
- lines.each do |line|
124
- # The line numbers in the output of a git diff match this regex
125
- # @@ -61,18 +61,15 @@
126
- if !line.match?(/@@ ([-]\d+,\d+\s[+]\d+,\d+) @@/)
127
- if line.first != "+"
128
- line.slice!(0)
129
- file_content += line + "\n"
130
- end
131
- else
132
- file_content += "\n"
133
- end
134
- end
135
- ones[filenames[i]] = file_content.chomp "\n"
136
- end
137
- ones
138
- end
139
-
140
- def self.get_last_right(diff)
141
- filenames = get_file_names(get_last_commit_hash)
142
- files = file_diffs(diff)
143
- ones = {}
144
- files.each_with_index do |file, i|
145
- file_content = ""
146
- lines = file.split("\n").drop(4)
147
- lines.each do |line|
148
- if !line.match?(/@@ ([-]\d+,\d+\s[+]\d+,\d+) @@/)
149
- if line.first != "+"
150
- elsif line.first == "+"
151
- line.slice!(0)
152
- file_content += line + "\n"
153
- end
154
- else
155
- file_content += "\n"
156
- end
157
- end
158
- ones[filenames[i]] = file_content.chomp "\n"
159
- end
160
- ones
161
- end
162
-
163
- def self.last_to_html(diff)
164
- left_hash = get_last_left(diff)
165
- right_hash = get_last_right(diff)
166
-
167
- html_output = '<link rel="stylesheet"' +
168
- 'href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/' +
169
- 'bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/' +
170
- '1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">'
171
- html_output += '<style>'
172
- html_output += Diffy::CSS
173
- html_output += '</style>'
174
- html_output += '<div class="card">'
175
- left_hash.keys.each do |file|
176
- html_output += '<div class="file mb-4 p-3">'
177
- html_output += '<h4>' + file + '</h4>'
178
- html_output += Diffy::Diff.new(
179
- left_hash[file],
180
- right_hash[file],
181
- :include_plus_and_minus_in_html => true
182
- ).to_s(:html)
183
- html_output += '</div>'
184
- end
185
- html_output += '</div>'
186
- html_output
187
- end
188
-
189
- def self.diff_to_html(diff)
190
- left_hash = get_each_left(diff)
191
- right_hash = get_each_right(diff)
192
- html_output = '<div style="overflow-y: scroll;height:400px">'
193
- html_output += '<style>'
194
- html_output += Diffy::CSS
195
- html_output += '</style>'
196
- html_output += '<div class="row mb-3">'
197
- html_output += '<div class="col-md-12 offset" style="overflow-y: scroll;">'
198
-
199
- left_hash.keys.each do |file|
200
- html_output += '<div class="row text-center">
201
- <div class="col-12">
202
- <h4>'
203
- html_output+= file.to_s
204
- html_output += '</h4>
205
- </div>
206
- </div>
207
- <div class="row mb-4">
208
- <div class="col-6">'
209
- html_output += Diffy::SplitDiff.new(
210
- left_hash[file],
211
- right_hash[file],
212
- :format => :html
213
- ).left
214
-
215
- html_output +=
216
- '</div>
217
- <div class="col-6">'
218
- html_output += Diffy::SplitDiff.new(
219
- left_hash[file],
220
- right_hash[file],
221
- :format => :html
222
- ).right
223
-
224
- html_output += '</div></div>'
225
- end
226
- html_output += "</div>"
227
- html_output += "</div>"
228
- html_output += "</div>"
229
- html_output
230
-
231
- end
232
- end
233
- end
data/web_git-0.0.1.gem DELETED
Binary file