web_git 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +240 -0
- data/README.markdown +0 -4
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/app/controllers/web_git/commands_controller.rb +10 -13
- data/app/views/web_git/commands/hello.html.erb +1 -0
- data/app/views/web_git/commands/status.html.erb +1 -2
- data/lib/web_git.rb +2 -0
- data/lib/web_git/diff.rb +233 -0
- data/web_git-0.0.1.gem +0 -0
- data/web_git.gemspec +59 -54
- metadata +23 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89d8eef92b2c4cb8ca66b0ab374148141681c23a48546d6527f9f20142fdd53e
|
4
|
+
data.tar.gz: 1d650a1dd33ae931104e89fde068fe22de2c03f9c7baa8ef34095510493b12d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72a468c367e5e54661d2fed60e95b3481f20a044a16fcfb152300930d94a065937b8c5a3e8dbf6e869c3d791b25d16c18ff01983b31f52d4c54655cee681bfea
|
7
|
+
data.tar.gz: 5421ce8a8b8bf1ddbeee887850c55a0f3d6cad9ee12f6a1e425b8c624263cefeea74a6ccb9fe66eae81d66becf7841d08eaf96541dfc7df1b788f3d637e23dd2
|
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,240 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
actioncable (5.2.2.1)
|
5
|
+
actionpack (= 5.2.2.1)
|
6
|
+
nio4r (~> 2.0)
|
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)
|
12
|
+
mail (~> 2.5, >= 2.5.4)
|
13
|
+
rails-dom-testing (~> 2.0)
|
14
|
+
actionpack (5.2.2.1)
|
15
|
+
actionview (= 5.2.2.1)
|
16
|
+
activesupport (= 5.2.2.1)
|
17
|
+
rack (~> 2.0)
|
18
|
+
rack-test (>= 0.6.3)
|
19
|
+
rails-dom-testing (~> 2.0)
|
20
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
21
|
+
actionview (5.2.2.1)
|
22
|
+
activesupport (= 5.2.2.1)
|
23
|
+
builder (~> 3.1)
|
24
|
+
erubi (~> 1.4)
|
25
|
+
rails-dom-testing (~> 2.0)
|
26
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
27
|
+
activejob (5.2.2.1)
|
28
|
+
activesupport (= 5.2.2.1)
|
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)
|
35
|
+
arel (>= 9.0)
|
36
|
+
activestorage (5.2.2.1)
|
37
|
+
actionpack (= 5.2.2.1)
|
38
|
+
activerecord (= 5.2.2.1)
|
39
|
+
marcel (~> 0.3.1)
|
40
|
+
activesupport (5.2.2.1)
|
41
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
42
|
+
i18n (>= 0.7, < 2)
|
43
|
+
minitest (~> 5.1)
|
44
|
+
tzinfo (~> 1.1)
|
45
|
+
addressable (2.6.0)
|
46
|
+
public_suffix (>= 2.0.2, < 4.0)
|
47
|
+
arel (9.0.0)
|
48
|
+
binding_of_caller (0.8.0)
|
49
|
+
debug_inspector (>= 0.0.1)
|
50
|
+
builder (3.2.3)
|
51
|
+
byebug (11.0.1)
|
52
|
+
coderay (1.1.2)
|
53
|
+
concurrent-ruby (1.1.5)
|
54
|
+
crass (1.0.4)
|
55
|
+
debug_inspector (0.0.3)
|
56
|
+
descendants_tracker (0.0.4)
|
57
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
58
|
+
diff-lcs (1.3)
|
59
|
+
diffy (3.3.0)
|
60
|
+
docile (1.3.1)
|
61
|
+
erubi (1.8.0)
|
62
|
+
faraday (0.15.4)
|
63
|
+
multipart-post (>= 1.2, < 3)
|
64
|
+
git (1.5.0)
|
65
|
+
git_clone_url (2.0.0)
|
66
|
+
uri-ssh_git (>= 2.0)
|
67
|
+
github_api (0.18.2)
|
68
|
+
addressable (~> 2.4)
|
69
|
+
descendants_tracker (~> 0.0.4)
|
70
|
+
faraday (~> 0.8)
|
71
|
+
hashie (~> 3.5, >= 3.5.2)
|
72
|
+
oauth2 (~> 1.0)
|
73
|
+
globalid (0.4.2)
|
74
|
+
activesupport (>= 4.2.0)
|
75
|
+
hashie (3.6.0)
|
76
|
+
highline (2.0.1)
|
77
|
+
i18n (1.6.0)
|
78
|
+
concurrent-ruby (~> 1.0)
|
79
|
+
interception (0.5)
|
80
|
+
jquery-rails (4.3.3)
|
81
|
+
rails-dom-testing (>= 1, < 3)
|
82
|
+
railties (>= 4.2.0)
|
83
|
+
thor (>= 0.14, < 2.0)
|
84
|
+
json (1.8.6)
|
85
|
+
juwelier (2.1.3)
|
86
|
+
builder
|
87
|
+
bundler (>= 1.13)
|
88
|
+
git (>= 1.2.5)
|
89
|
+
github_api
|
90
|
+
highline (>= 1.6.15)
|
91
|
+
nokogiri (>= 1.5.10)
|
92
|
+
rake
|
93
|
+
rdoc
|
94
|
+
semver
|
95
|
+
jwt (2.1.0)
|
96
|
+
loofah (2.2.3)
|
97
|
+
crass (~> 1.0.2)
|
98
|
+
nokogiri (>= 1.5.9)
|
99
|
+
mail (2.7.1)
|
100
|
+
mini_mime (>= 0.1.1)
|
101
|
+
marcel (0.3.3)
|
102
|
+
mimemagic (~> 0.3.2)
|
103
|
+
method_source (0.9.2)
|
104
|
+
mimemagic (0.3.3)
|
105
|
+
mini_mime (1.0.1)
|
106
|
+
mini_portile2 (2.4.0)
|
107
|
+
minitest (5.11.3)
|
108
|
+
multi_json (1.13.1)
|
109
|
+
multi_xml (0.6.0)
|
110
|
+
multipart-post (2.0.0)
|
111
|
+
nio4r (2.3.1)
|
112
|
+
nokogiri (1.10.2)
|
113
|
+
mini_portile2 (~> 2.4.0)
|
114
|
+
oauth2 (1.4.1)
|
115
|
+
faraday (>= 0.8, < 0.16.0)
|
116
|
+
jwt (>= 1.0, < 3.0)
|
117
|
+
multi_json (~> 1.3)
|
118
|
+
multi_xml (~> 0.5)
|
119
|
+
rack (>= 1.2, < 3)
|
120
|
+
octicons (8.5.0)
|
121
|
+
nokogiri (>= 1.6.3.1)
|
122
|
+
octicons_helper (8.5.0)
|
123
|
+
octicons (= 8.5.0)
|
124
|
+
rails
|
125
|
+
pry (0.12.2)
|
126
|
+
coderay (~> 1.1.0)
|
127
|
+
method_source (~> 0.9.0)
|
128
|
+
pry-byebug (3.7.0)
|
129
|
+
byebug (~> 11.0)
|
130
|
+
pry (~> 0.10)
|
131
|
+
pry-doc (0.13.5)
|
132
|
+
pry (~> 0.11)
|
133
|
+
yard (~> 0.9.11)
|
134
|
+
pry-remote (0.1.8)
|
135
|
+
pry (~> 0.9)
|
136
|
+
slop (~> 3.0)
|
137
|
+
pry-rescue (1.5.0)
|
138
|
+
interception (>= 0.5)
|
139
|
+
pry (>= 0.12.0)
|
140
|
+
pry-stack_explorer (0.4.9.3)
|
141
|
+
binding_of_caller (>= 0.7)
|
142
|
+
pry (>= 0.9.11)
|
143
|
+
public_suffix (3.0.3)
|
144
|
+
rack (2.0.6)
|
145
|
+
rack-test (1.1.0)
|
146
|
+
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)
|
157
|
+
bundler (>= 1.3.0)
|
158
|
+
railties (= 5.2.2.1)
|
159
|
+
sprockets-rails (>= 2.0.0)
|
160
|
+
rails-dom-testing (2.0.3)
|
161
|
+
activesupport (>= 4.2.0)
|
162
|
+
nokogiri (>= 1.6)
|
163
|
+
rails-html-sanitizer (1.0.4)
|
164
|
+
loofah (~> 2.2, >= 2.2.2)
|
165
|
+
railties (5.2.2.1)
|
166
|
+
actionpack (= 5.2.2.1)
|
167
|
+
activesupport (= 5.2.2.1)
|
168
|
+
method_source
|
169
|
+
rake (>= 0.8.7)
|
170
|
+
thor (>= 0.19.0, < 2.0)
|
171
|
+
rake (12.3.2)
|
172
|
+
rdoc (3.12.2)
|
173
|
+
json (~> 1.4)
|
174
|
+
rspec (3.5.0)
|
175
|
+
rspec-core (~> 3.5.0)
|
176
|
+
rspec-expectations (~> 3.5.0)
|
177
|
+
rspec-mocks (~> 3.5.0)
|
178
|
+
rspec-core (3.5.4)
|
179
|
+
rspec-support (~> 3.5.0)
|
180
|
+
rspec-expectations (3.5.0)
|
181
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
182
|
+
rspec-support (~> 3.5.0)
|
183
|
+
rspec-mocks (3.5.0)
|
184
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
185
|
+
rspec-support (~> 3.5.0)
|
186
|
+
rspec-support (3.5.0)
|
187
|
+
semver (1.0.1)
|
188
|
+
simplecov (0.16.1)
|
189
|
+
docile (~> 1.1)
|
190
|
+
json (>= 1.8, < 3)
|
191
|
+
simplecov-html (~> 0.10.0)
|
192
|
+
simplecov-html (0.10.2)
|
193
|
+
slop (3.6.0)
|
194
|
+
sprockets (3.7.2)
|
195
|
+
concurrent-ruby (~> 1.0)
|
196
|
+
rack (> 1, < 3)
|
197
|
+
sprockets-rails (3.2.1)
|
198
|
+
actionpack (>= 4.0)
|
199
|
+
activesupport (>= 4.0)
|
200
|
+
sprockets (>= 3.0.0)
|
201
|
+
tether-rails (1.4.0)
|
202
|
+
rails (>= 3.1)
|
203
|
+
thor (0.20.3)
|
204
|
+
thread_safe (0.3.6)
|
205
|
+
turbolinks (5.2.0)
|
206
|
+
turbolinks-source (~> 5.2)
|
207
|
+
turbolinks-source (5.2.0)
|
208
|
+
tzinfo (1.2.5)
|
209
|
+
thread_safe (~> 0.1)
|
210
|
+
uri-ssh_git (2.0.0)
|
211
|
+
websocket-driver (0.7.0)
|
212
|
+
websocket-extensions (>= 0.1.0)
|
213
|
+
websocket-extensions (0.1.3)
|
214
|
+
yard (0.9.18)
|
215
|
+
|
216
|
+
PLATFORMS
|
217
|
+
ruby
|
218
|
+
|
219
|
+
DEPENDENCIES
|
220
|
+
bundler (~> 1.0)
|
221
|
+
diffy
|
222
|
+
git_clone_url
|
223
|
+
jquery-rails
|
224
|
+
juwelier (~> 2.1.0)
|
225
|
+
octicons_helper
|
226
|
+
pry (~> 0)
|
227
|
+
pry-byebug (~> 3)
|
228
|
+
pry-doc (~> 0)
|
229
|
+
pry-remote (~> 0)
|
230
|
+
pry-rescue (~> 1)
|
231
|
+
pry-stack_explorer (~> 0)
|
232
|
+
rdoc (~> 3.12)
|
233
|
+
rspec (~> 3.5.0)
|
234
|
+
simplecov
|
235
|
+
tether-rails
|
236
|
+
turbolinks (~> 5)
|
237
|
+
tzinfo-data
|
238
|
+
|
239
|
+
BUNDLED WITH
|
240
|
+
1.17.2
|
data/README.markdown
CHANGED
@@ -6,10 +6,6 @@ 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
|
13
9
|
```
|
14
10
|
|
15
11
|
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"]
|
22
|
+
gem.authors = ["Raghu Betina", "Jelani Woods"]
|
23
23
|
|
24
24
|
# dependencies defined in Gemfile
|
25
25
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
@@ -4,7 +4,7 @@ module WebGit
|
|
4
4
|
|
5
5
|
def status
|
6
6
|
Dir.chdir(Rails.root) do
|
7
|
-
@status = `git status`
|
7
|
+
logger.debug @status = `git status`
|
8
8
|
|
9
9
|
@current_branch = `git symbolic-ref --short HEAD`.chomp
|
10
10
|
|
@@ -23,15 +23,10 @@ module WebGit
|
|
23
23
|
diff = `git diff`
|
24
24
|
|
25
25
|
unless diff.blank?
|
26
|
-
@diff_html =
|
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>", "")
|
26
|
+
@diff_html = WebGit::Diff.diff_to_html(diff)
|
30
27
|
else
|
31
|
-
|
32
|
-
|
33
|
-
gsub("<a class=\"d2h-file-switch d2h-hide\">hide</a>", "").
|
34
|
-
gsub("<a class=\"d2h-file-switch d2h-show\">show</a>", "")
|
28
|
+
last_diff = WebGit::Diff.get_last_diff
|
29
|
+
@last_diff_html = WebGit::Diff.last_to_html(last_diff)
|
35
30
|
|
36
31
|
@last_commit_message = `git log -1 --pretty=%B`
|
37
32
|
end
|
@@ -40,11 +35,13 @@ module WebGit
|
|
40
35
|
|
41
36
|
# @log = `git log --branches --remotes --tags --graph --oneline --decorate --pretty=format:"#%h %d %s - %cr"`
|
42
37
|
shell_script_path = WebGit::Engine.root.to_s + "/ansi2html.sh"
|
43
|
-
|
44
|
-
@log_html = `git log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --branches --remotes --tags | sh #{shell_script_path} --bg=dark`
|
38
|
+
logger.debug @log_html = `git log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n%C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --branches --remotes --tags | sh #{shell_script_path} --bg=dark`
|
45
39
|
end
|
46
|
-
|
47
|
-
render
|
40
|
+
# render layout: "web_git/application"
|
41
|
+
# render "web_git/commands/hello.html.erb"
|
42
|
+
render "web_git/commands/status.html.erb", layout: "web_git/application"
|
48
43
|
end
|
44
|
+
|
49
45
|
end
|
46
|
+
|
50
47
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
We made it!
|
data/lib/web_git.rb
CHANGED
data/lib/web_git/diff.rb
ADDED
@@ -0,0 +1,233 @@
|
|
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
ADDED
Binary file
|
data/web_git.gemspec
CHANGED
@@ -10,8 +10,8 @@ Gem::Specification.new do |s|
|
|
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]
|
14
|
-
s.date = "
|
13
|
+
s.authors = ["Raghu Betina".freeze, "Jelani Woods".freeze]
|
14
|
+
s.date = "2019-05-06"
|
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 = [
|
@@ -22,6 +22,7 @@ Gem::Specification.new do |s|
|
|
22
22
|
".document",
|
23
23
|
".rspec",
|
24
24
|
"Gemfile",
|
25
|
+
"Gemfile.lock",
|
25
26
|
"LICENSE.txt",
|
26
27
|
"MIT-LICENSE",
|
27
28
|
"README.markdown",
|
@@ -43,73 +44,77 @@ Gem::Specification.new do |s|
|
|
43
44
|
"app/views/web_git/commands/status.html.erb",
|
44
45
|
"config/routes.rb",
|
45
46
|
"lib/web_git.rb",
|
47
|
+
"lib/web_git/diff.rb",
|
46
48
|
"lib/web_git/engine.rb",
|
47
49
|
"lib/web_git/version.rb",
|
48
50
|
"web_git.gemspec"
|
49
51
|
]
|
50
52
|
s.homepage = "http://github.com/firstdraft/web_git".freeze
|
51
53
|
s.licenses = ["MIT".freeze]
|
52
|
-
s.rubygems_version = "
|
54
|
+
s.rubygems_version = "3.0.1".freeze
|
53
55
|
s.summary = "An in-browser Git GUI for your Rails project".freeze
|
54
56
|
|
55
57
|
if s.respond_to? :specification_version then
|
56
58
|
s.specification_version = 4
|
57
59
|
|
58
60
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
59
|
-
s.add_runtime_dependency(%q<
|
60
|
-
s.add_runtime_dependency(%q<
|
61
|
-
s.add_runtime_dependency(%q<
|
62
|
-
s.add_runtime_dependency(%q<
|
63
|
-
s.add_runtime_dependency(%q<
|
64
|
-
s.add_runtime_dependency(%q<
|
65
|
-
s.
|
66
|
-
s.add_development_dependency(%q<
|
67
|
-
s.add_development_dependency(%q<
|
68
|
-
s.add_development_dependency(%q<
|
69
|
-
s.add_development_dependency(%q<
|
70
|
-
s.add_development_dependency(%q<
|
71
|
-
s.add_development_dependency(%q<pry
|
72
|
-
s.add_development_dependency(%q<pry-
|
73
|
-
s.add_development_dependency(%q<pry-
|
74
|
-
s.add_development_dependency(%q<pry-
|
75
|
-
s.add_development_dependency(%q<pry-
|
61
|
+
s.add_runtime_dependency(%q<diffy>.freeze, [">= 0"])
|
62
|
+
s.add_runtime_dependency(%q<tzinfo-data>.freeze, [">= 0"])
|
63
|
+
s.add_runtime_dependency(%q<tether-rails>.freeze, [">= 0"])
|
64
|
+
s.add_runtime_dependency(%q<octicons_helper>.freeze, [">= 0"])
|
65
|
+
s.add_runtime_dependency(%q<turbolinks>.freeze, ["~> 5"])
|
66
|
+
s.add_runtime_dependency(%q<jquery-rails>.freeze, [">= 0"])
|
67
|
+
s.add_runtime_dependency(%q<git_clone_url>.freeze, [">= 0"])
|
68
|
+
s.add_development_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
69
|
+
s.add_development_dependency(%q<rdoc>.freeze, ["~> 3.12"])
|
70
|
+
s.add_development_dependency(%q<bundler>.freeze, ["~> 1.0"])
|
71
|
+
s.add_development_dependency(%q<juwelier>.freeze, ["~> 2.1.0"])
|
72
|
+
s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
|
73
|
+
s.add_development_dependency(%q<pry>.freeze, ["~> 0"])
|
74
|
+
s.add_development_dependency(%q<pry-byebug>.freeze, ["~> 3"])
|
75
|
+
s.add_development_dependency(%q<pry-doc>.freeze, ["~> 0"])
|
76
|
+
s.add_development_dependency(%q<pry-remote>.freeze, ["~> 0"])
|
77
|
+
s.add_development_dependency(%q<pry-rescue>.freeze, ["~> 1"])
|
78
|
+
s.add_development_dependency(%q<pry-stack_explorer>.freeze, ["~> 0"])
|
76
79
|
else
|
77
|
-
s.add_dependency(%q<
|
78
|
-
s.add_dependency(%q<
|
79
|
-
s.add_dependency(%q<
|
80
|
-
s.add_dependency(%q<
|
81
|
-
s.add_dependency(%q<
|
82
|
-
s.add_dependency(%q<
|
83
|
-
s.add_dependency(%q<
|
84
|
-
s.add_dependency(%q<
|
85
|
-
s.add_dependency(%q<
|
86
|
-
s.add_dependency(%q<
|
87
|
-
s.add_dependency(%q<
|
88
|
-
s.add_dependency(%q<
|
89
|
-
s.add_dependency(%q<pry
|
90
|
-
s.add_dependency(%q<pry-
|
91
|
-
s.add_dependency(%q<pry-
|
92
|
-
s.add_dependency(%q<pry-
|
93
|
-
s.add_dependency(%q<pry-
|
80
|
+
s.add_dependency(%q<diffy>.freeze, [">= 0"])
|
81
|
+
s.add_dependency(%q<tzinfo-data>.freeze, [">= 0"])
|
82
|
+
s.add_dependency(%q<tether-rails>.freeze, [">= 0"])
|
83
|
+
s.add_dependency(%q<octicons_helper>.freeze, [">= 0"])
|
84
|
+
s.add_dependency(%q<turbolinks>.freeze, ["~> 5"])
|
85
|
+
s.add_dependency(%q<jquery-rails>.freeze, [">= 0"])
|
86
|
+
s.add_dependency(%q<git_clone_url>.freeze, [">= 0"])
|
87
|
+
s.add_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
88
|
+
s.add_dependency(%q<rdoc>.freeze, ["~> 3.12"])
|
89
|
+
s.add_dependency(%q<bundler>.freeze, ["~> 1.0"])
|
90
|
+
s.add_dependency(%q<juwelier>.freeze, ["~> 2.1.0"])
|
91
|
+
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
|
92
|
+
s.add_dependency(%q<pry>.freeze, ["~> 0"])
|
93
|
+
s.add_dependency(%q<pry-byebug>.freeze, ["~> 3"])
|
94
|
+
s.add_dependency(%q<pry-doc>.freeze, ["~> 0"])
|
95
|
+
s.add_dependency(%q<pry-remote>.freeze, ["~> 0"])
|
96
|
+
s.add_dependency(%q<pry-rescue>.freeze, ["~> 1"])
|
97
|
+
s.add_dependency(%q<pry-stack_explorer>.freeze, ["~> 0"])
|
94
98
|
end
|
95
99
|
else
|
96
|
-
s.add_dependency(%q<
|
97
|
-
s.add_dependency(%q<
|
98
|
-
s.add_dependency(%q<
|
99
|
-
s.add_dependency(%q<
|
100
|
-
s.add_dependency(%q<
|
101
|
-
s.add_dependency(%q<
|
102
|
-
s.add_dependency(%q<
|
103
|
-
s.add_dependency(%q<
|
104
|
-
s.add_dependency(%q<
|
105
|
-
s.add_dependency(%q<
|
106
|
-
s.add_dependency(%q<
|
107
|
-
s.add_dependency(%q<
|
108
|
-
s.add_dependency(%q<pry
|
109
|
-
s.add_dependency(%q<pry-
|
110
|
-
s.add_dependency(%q<pry-
|
111
|
-
s.add_dependency(%q<pry-
|
112
|
-
s.add_dependency(%q<pry-
|
100
|
+
s.add_dependency(%q<diffy>.freeze, [">= 0"])
|
101
|
+
s.add_dependency(%q<tzinfo-data>.freeze, [">= 0"])
|
102
|
+
s.add_dependency(%q<tether-rails>.freeze, [">= 0"])
|
103
|
+
s.add_dependency(%q<octicons_helper>.freeze, [">= 0"])
|
104
|
+
s.add_dependency(%q<turbolinks>.freeze, ["~> 5"])
|
105
|
+
s.add_dependency(%q<jquery-rails>.freeze, [">= 0"])
|
106
|
+
s.add_dependency(%q<git_clone_url>.freeze, [">= 0"])
|
107
|
+
s.add_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
108
|
+
s.add_dependency(%q<rdoc>.freeze, ["~> 3.12"])
|
109
|
+
s.add_dependency(%q<bundler>.freeze, ["~> 1.0"])
|
110
|
+
s.add_dependency(%q<juwelier>.freeze, ["~> 2.1.0"])
|
111
|
+
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
|
112
|
+
s.add_dependency(%q<pry>.freeze, ["~> 0"])
|
113
|
+
s.add_dependency(%q<pry-byebug>.freeze, ["~> 3"])
|
114
|
+
s.add_dependency(%q<pry-doc>.freeze, ["~> 0"])
|
115
|
+
s.add_dependency(%q<pry-remote>.freeze, ["~> 0"])
|
116
|
+
s.add_dependency(%q<pry-rescue>.freeze, ["~> 1"])
|
117
|
+
s.add_dependency(%q<pry-stack_explorer>.freeze, ["~> 0"])
|
113
118
|
end
|
114
119
|
end
|
115
120
|
|
metadata
CHANGED
@@ -1,15 +1,30 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: web_git
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Raghu Betina
|
8
|
+
- Jelani Woods
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2019-07-09 00:00:00.000000000 Z
|
12
13
|
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'
|
13
28
|
- !ruby/object:Gem::Dependency
|
14
29
|
name: tzinfo-data
|
15
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -260,6 +275,7 @@ files:
|
|
260
275
|
- ".document"
|
261
276
|
- ".rspec"
|
262
277
|
- Gemfile
|
278
|
+
- Gemfile.lock
|
263
279
|
- LICENSE.txt
|
264
280
|
- MIT-LICENSE
|
265
281
|
- README.markdown
|
@@ -278,11 +294,14 @@ files:
|
|
278
294
|
- app/controllers/web_git/commands_controller.rb
|
279
295
|
- app/controllers/web_git/commits_controller.rb
|
280
296
|
- app/views/layouts/web_git/application.html.erb
|
297
|
+
- app/views/web_git/commands/hello.html.erb
|
281
298
|
- app/views/web_git/commands/status.html.erb
|
282
299
|
- config/routes.rb
|
283
300
|
- lib/web_git.rb
|
301
|
+
- lib/web_git/diff.rb
|
284
302
|
- lib/web_git/engine.rb
|
285
303
|
- lib/web_git/version.rb
|
304
|
+
- web_git-0.0.1.gem
|
286
305
|
- web_git.gemspec
|
287
306
|
homepage: http://github.com/firstdraft/web_git
|
288
307
|
licenses:
|
@@ -303,7 +322,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
303
322
|
- !ruby/object:Gem::Version
|
304
323
|
version: '0'
|
305
324
|
requirements: []
|
306
|
-
|
325
|
+
rubyforge_project:
|
326
|
+
rubygems_version: 2.7.8
|
307
327
|
signing_key:
|
308
328
|
specification_version: 4
|
309
329
|
summary: An in-browser Git GUI for your Rails project
|