web_git 0.0.2.1 → 0.0.3
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 +4 -4
- data/Gemfile +2 -1
- data/Gemfile.lock +54 -51
- data/README.markdown +0 -4
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/app/controllers/web_git/commands_controller.rb +10 -13
- data/lib/web_git/diff.rb +233 -0
- data/lib/web_git.rb +2 -0
- data/web_git.gemspec +10 -5
- metadata +31 -3
- data/app/views/web_git/commands/hello.html.erb +0 -1
- data/web_git-0.0.2.gem +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2c5bfa1659ff7288b47ee5a359442da83f7d287d870b6835e0ab866e6da29398
|
|
4
|
+
data.tar.gz: dc3894d6d033944e3c87164e703805d2be7a097a738a231a2265e96b1b59f9ad
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c745137eee762be97fe2f5494ec0423bfbf7b61fbafe6c31affef0fd9b788376e9d7f98553c17efadce79b8588c541ad4108d2c747af6480db5b9ed39689f30a
|
|
7
|
+
data.tar.gz: b284391effc03a970b70d93ec007119c54b6508833eecf0fbbfd1100fd4f9ca852e97a744dec559e2ef49092e689fc1380c86d0dc8a41f51dfe23861bf9b5077
|
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
|
-
|
|
11
|
+
gem "bundler", "~> 1.0"
|
|
12
12
|
gem "juwelier", "~> 2.1.0"
|
|
13
13
|
gem "simplecov", ">= 0"
|
|
14
14
|
gem "pry", "~> 0"
|
|
@@ -19,6 +19,7 @@ group :development do
|
|
|
19
19
|
gem "pry-stack_explorer", "~> 0"
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
+
gem "diffy"
|
|
22
23
|
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
|
23
24
|
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]
|
|
24
25
|
|
data/Gemfile.lock
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
GEM
|
|
2
2
|
remote: https://rubygems.org/
|
|
3
3
|
specs:
|
|
4
|
-
actioncable (5.2.
|
|
5
|
-
actionpack (= 5.2.
|
|
4
|
+
actioncable (5.2.2.1)
|
|
5
|
+
actionpack (= 5.2.2.1)
|
|
6
6
|
nio4r (~> 2.0)
|
|
7
7
|
websocket-driver (>= 0.6.1)
|
|
8
|
-
actionmailer (5.2.
|
|
9
|
-
actionpack (= 5.2.
|
|
10
|
-
actionview (= 5.2.
|
|
11
|
-
activejob (= 5.2.
|
|
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
12
|
mail (~> 2.5, >= 2.5.4)
|
|
13
13
|
rails-dom-testing (~> 2.0)
|
|
14
|
-
actionpack (5.2.
|
|
15
|
-
actionview (= 5.2.
|
|
16
|
-
activesupport (= 5.2.
|
|
14
|
+
actionpack (5.2.2.1)
|
|
15
|
+
actionview (= 5.2.2.1)
|
|
16
|
+
activesupport (= 5.2.2.1)
|
|
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.
|
|
22
|
-
activesupport (= 5.2.
|
|
21
|
+
actionview (5.2.2.1)
|
|
22
|
+
activesupport (= 5.2.2.1)
|
|
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.
|
|
28
|
-
activesupport (= 5.2.
|
|
27
|
+
activejob (5.2.2.1)
|
|
28
|
+
activesupport (= 5.2.2.1)
|
|
29
29
|
globalid (>= 0.3.6)
|
|
30
|
-
activemodel (5.2.
|
|
31
|
-
activesupport (= 5.2.
|
|
32
|
-
activerecord (5.2.
|
|
33
|
-
activemodel (= 5.2.
|
|
34
|
-
activesupport (= 5.2.
|
|
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
35
|
arel (>= 9.0)
|
|
36
|
-
activestorage (5.2.
|
|
37
|
-
actionpack (= 5.2.
|
|
38
|
-
activerecord (= 5.2.
|
|
36
|
+
activestorage (5.2.2.1)
|
|
37
|
+
actionpack (= 5.2.2.1)
|
|
38
|
+
activerecord (= 5.2.2.1)
|
|
39
39
|
marcel (~> 0.3.1)
|
|
40
|
-
activesupport (5.2.
|
|
40
|
+
activesupport (5.2.2.1)
|
|
41
41
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
42
42
|
i18n (>= 0.7, < 2)
|
|
43
43
|
minitest (~> 5.1)
|
|
@@ -56,7 +56,8 @@ GEM
|
|
|
56
56
|
descendants_tracker (0.0.4)
|
|
57
57
|
thread_safe (~> 0.3, >= 0.3.1)
|
|
58
58
|
diff-lcs (1.3)
|
|
59
|
-
|
|
59
|
+
diffy (3.3.0)
|
|
60
|
+
docile (1.3.1)
|
|
60
61
|
erubi (1.8.0)
|
|
61
62
|
faraday (0.15.4)
|
|
62
63
|
multipart-post (>= 1.2, < 3)
|
|
@@ -72,11 +73,11 @@ GEM
|
|
|
72
73
|
globalid (0.4.2)
|
|
73
74
|
activesupport (>= 4.2.0)
|
|
74
75
|
hashie (3.6.0)
|
|
75
|
-
highline (2.0.
|
|
76
|
+
highline (2.0.1)
|
|
76
77
|
i18n (1.6.0)
|
|
77
78
|
concurrent-ruby (~> 1.0)
|
|
78
79
|
interception (0.5)
|
|
79
|
-
jquery-rails (4.3.
|
|
80
|
+
jquery-rails (4.3.3)
|
|
80
81
|
rails-dom-testing (>= 1, < 3)
|
|
81
82
|
railties (>= 4.2.0)
|
|
82
83
|
thor (>= 0.14, < 2.0)
|
|
@@ -91,7 +92,7 @@ GEM
|
|
|
91
92
|
rake
|
|
92
93
|
rdoc
|
|
93
94
|
semver
|
|
94
|
-
jwt (2.
|
|
95
|
+
jwt (2.1.0)
|
|
95
96
|
loofah (2.2.3)
|
|
96
97
|
crass (~> 1.0.2)
|
|
97
98
|
nokogiri (>= 1.5.9)
|
|
@@ -106,9 +107,9 @@ GEM
|
|
|
106
107
|
minitest (5.11.3)
|
|
107
108
|
multi_json (1.13.1)
|
|
108
109
|
multi_xml (0.6.0)
|
|
109
|
-
multipart-post (2.
|
|
110
|
+
multipart-post (2.0.0)
|
|
110
111
|
nio4r (2.3.1)
|
|
111
|
-
nokogiri (1.10.
|
|
112
|
+
nokogiri (1.10.2)
|
|
112
113
|
mini_portile2 (~> 2.4.0)
|
|
113
114
|
oauth2 (1.4.1)
|
|
114
115
|
faraday (>= 0.8, < 0.16.0)
|
|
@@ -116,10 +117,10 @@ GEM
|
|
|
116
117
|
multi_json (~> 1.3)
|
|
117
118
|
multi_xml (~> 0.5)
|
|
118
119
|
rack (>= 1.2, < 3)
|
|
119
|
-
octicons (
|
|
120
|
+
octicons (8.5.0)
|
|
120
121
|
nokogiri (>= 1.6.3.1)
|
|
121
|
-
octicons_helper (
|
|
122
|
-
octicons (=
|
|
122
|
+
octicons_helper (8.5.0)
|
|
123
|
+
octicons (= 8.5.0)
|
|
123
124
|
rails
|
|
124
125
|
pry (0.12.2)
|
|
125
126
|
coderay (~> 1.1.0)
|
|
@@ -139,31 +140,31 @@ GEM
|
|
|
139
140
|
pry-stack_explorer (0.4.9.3)
|
|
140
141
|
binding_of_caller (>= 0.7)
|
|
141
142
|
pry (>= 0.9.11)
|
|
142
|
-
public_suffix (3.
|
|
143
|
-
rack (2.0.
|
|
143
|
+
public_suffix (3.0.3)
|
|
144
|
+
rack (2.0.6)
|
|
144
145
|
rack-test (1.1.0)
|
|
145
146
|
rack (>= 1.0, < 3)
|
|
146
|
-
rails (5.2.
|
|
147
|
-
actioncable (= 5.2.
|
|
148
|
-
actionmailer (= 5.2.
|
|
149
|
-
actionpack (= 5.2.
|
|
150
|
-
actionview (= 5.2.
|
|
151
|
-
activejob (= 5.2.
|
|
152
|
-
activemodel (= 5.2.
|
|
153
|
-
activerecord (= 5.2.
|
|
154
|
-
activestorage (= 5.2.
|
|
155
|
-
activesupport (= 5.2.
|
|
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)
|
|
156
157
|
bundler (>= 1.3.0)
|
|
157
|
-
railties (= 5.2.
|
|
158
|
+
railties (= 5.2.2.1)
|
|
158
159
|
sprockets-rails (>= 2.0.0)
|
|
159
160
|
rails-dom-testing (2.0.3)
|
|
160
161
|
activesupport (>= 4.2.0)
|
|
161
162
|
nokogiri (>= 1.6)
|
|
162
163
|
rails-html-sanitizer (1.0.4)
|
|
163
164
|
loofah (~> 2.2, >= 2.2.2)
|
|
164
|
-
railties (5.2.
|
|
165
|
-
actionpack (= 5.2.
|
|
166
|
-
activesupport (= 5.2.
|
|
165
|
+
railties (5.2.2.1)
|
|
166
|
+
actionpack (= 5.2.2.1)
|
|
167
|
+
activesupport (= 5.2.2.1)
|
|
167
168
|
method_source
|
|
168
169
|
rake (>= 0.8.7)
|
|
169
170
|
thor (>= 0.19.0, < 2.0)
|
|
@@ -207,15 +208,17 @@ GEM
|
|
|
207
208
|
tzinfo (1.2.5)
|
|
208
209
|
thread_safe (~> 0.1)
|
|
209
210
|
uri-ssh_git (2.0.0)
|
|
210
|
-
websocket-driver (0.7.
|
|
211
|
+
websocket-driver (0.7.0)
|
|
211
212
|
websocket-extensions (>= 0.1.0)
|
|
212
|
-
websocket-extensions (0.1.
|
|
213
|
-
yard (0.9.
|
|
213
|
+
websocket-extensions (0.1.3)
|
|
214
|
+
yard (0.9.18)
|
|
214
215
|
|
|
215
216
|
PLATFORMS
|
|
216
217
|
ruby
|
|
217
218
|
|
|
218
219
|
DEPENDENCIES
|
|
220
|
+
bundler (~> 1.0)
|
|
221
|
+
diffy
|
|
219
222
|
git_clone_url
|
|
220
223
|
jquery-rails
|
|
221
224
|
juwelier (~> 2.1.0)
|
|
@@ -234,4 +237,4 @@ DEPENDENCIES
|
|
|
234
237
|
tzinfo-data
|
|
235
238
|
|
|
236
239
|
BUNDLED WITH
|
|
237
|
-
|
|
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.3
|
|
@@ -4,7 +4,7 @@ module WebGit
|
|
|
4
4
|
|
|
5
5
|
def status
|
|
6
6
|
Dir.chdir(Rails.root) do
|
|
7
|
-
|
|
7
|
+
@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
|
-
|
|
38
|
+
|
|
39
|
+
@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`
|
|
44
40
|
end
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
render "web_git/commands/status.html.erb", layout: "web_git/application"
|
|
41
|
+
|
|
42
|
+
render layout: "web_git/application"
|
|
48
43
|
end
|
|
44
|
+
|
|
49
45
|
end
|
|
46
|
+
|
|
50
47
|
end
|
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/lib/web_git.rb
CHANGED
data/web_git.gemspec
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
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.3 ruby lib
|
|
5
|
+
# stub: web_git 0.0.2.3 ruby lib
|
|
6
6
|
|
|
7
7
|
Gem::Specification.new do |s|
|
|
8
8
|
s.name = "web_git".freeze
|
|
9
|
-
s.version = "0.0.3"
|
|
9
|
+
s.version = "0.0.2.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]
|
|
13
|
+
s.authors = ["Raghu Betina".freeze, "Jelani Woods".freeze]
|
|
14
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
|
|
@@ -41,13 +41,12 @@ 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",
|
|
45
44
|
"app/views/web_git/commands/status.html.erb",
|
|
46
45
|
"config/routes.rb",
|
|
47
46
|
"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",
|
|
51
50
|
"web_git.gemspec"
|
|
52
51
|
]
|
|
53
52
|
s.homepage = "http://github.com/firstdraft/web_git".freeze
|
|
@@ -59,6 +58,7 @@ Gem::Specification.new do |s|
|
|
|
59
58
|
s.specification_version = 4
|
|
60
59
|
|
|
61
60
|
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,6 +67,7 @@ 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"])
|
|
70
71
|
s.add_development_dependency(%q<juwelier>.freeze, ["~> 2.1.0"])
|
|
71
72
|
s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
|
|
72
73
|
s.add_development_dependency(%q<pry>.freeze, ["~> 0"])
|
|
@@ -76,6 +77,7 @@ Gem::Specification.new do |s|
|
|
|
76
77
|
s.add_development_dependency(%q<pry-rescue>.freeze, ["~> 1"])
|
|
77
78
|
s.add_development_dependency(%q<pry-stack_explorer>.freeze, ["~> 0"])
|
|
78
79
|
else
|
|
80
|
+
s.add_dependency(%q<diffy>.freeze, [">= 0"])
|
|
79
81
|
s.add_dependency(%q<tzinfo-data>.freeze, [">= 0"])
|
|
80
82
|
s.add_dependency(%q<tether-rails>.freeze, [">= 0"])
|
|
81
83
|
s.add_dependency(%q<octicons_helper>.freeze, [">= 0"])
|
|
@@ -84,6 +86,7 @@ Gem::Specification.new do |s|
|
|
|
84
86
|
s.add_dependency(%q<git_clone_url>.freeze, [">= 0"])
|
|
85
87
|
s.add_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
|
86
88
|
s.add_dependency(%q<rdoc>.freeze, ["~> 3.12"])
|
|
89
|
+
s.add_dependency(%q<bundler>.freeze, ["~> 1.0"])
|
|
87
90
|
s.add_dependency(%q<juwelier>.freeze, ["~> 2.1.0"])
|
|
88
91
|
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
|
|
89
92
|
s.add_dependency(%q<pry>.freeze, ["~> 0"])
|
|
@@ -94,6 +97,7 @@ Gem::Specification.new do |s|
|
|
|
94
97
|
s.add_dependency(%q<pry-stack_explorer>.freeze, ["~> 0"])
|
|
95
98
|
end
|
|
96
99
|
else
|
|
100
|
+
s.add_dependency(%q<diffy>.freeze, [">= 0"])
|
|
97
101
|
s.add_dependency(%q<tzinfo-data>.freeze, [">= 0"])
|
|
98
102
|
s.add_dependency(%q<tether-rails>.freeze, [">= 0"])
|
|
99
103
|
s.add_dependency(%q<octicons_helper>.freeze, [">= 0"])
|
|
@@ -102,6 +106,7 @@ Gem::Specification.new do |s|
|
|
|
102
106
|
s.add_dependency(%q<git_clone_url>.freeze, [">= 0"])
|
|
103
107
|
s.add_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
|
104
108
|
s.add_dependency(%q<rdoc>.freeze, ["~> 3.12"])
|
|
109
|
+
s.add_dependency(%q<bundler>.freeze, ["~> 1.0"])
|
|
105
110
|
s.add_dependency(%q<juwelier>.freeze, ["~> 2.1.0"])
|
|
106
111
|
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
|
|
107
112
|
s.add_dependency(%q<pry>.freeze, ["~> 0"])
|
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.3
|
|
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
12
|
date: 2019-07-11 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
|
|
@@ -122,6 +137,20 @@ dependencies:
|
|
|
122
137
|
- - "~>"
|
|
123
138
|
- !ruby/object:Gem::Version
|
|
124
139
|
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'
|
|
125
154
|
- !ruby/object:Gem::Dependency
|
|
126
155
|
name: juwelier
|
|
127
156
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -265,13 +294,12 @@ files:
|
|
|
265
294
|
- app/controllers/web_git/commands_controller.rb
|
|
266
295
|
- app/controllers/web_git/commits_controller.rb
|
|
267
296
|
- app/views/layouts/web_git/application.html.erb
|
|
268
|
-
- app/views/web_git/commands/hello.html.erb
|
|
269
297
|
- app/views/web_git/commands/status.html.erb
|
|
270
298
|
- config/routes.rb
|
|
271
299
|
- lib/web_git.rb
|
|
300
|
+
- lib/web_git/diff.rb
|
|
272
301
|
- lib/web_git/engine.rb
|
|
273
302
|
- lib/web_git/version.rb
|
|
274
|
-
- web_git-0.0.2.gem
|
|
275
303
|
- web_git.gemspec
|
|
276
304
|
homepage: http://github.com/firstdraft/web_git
|
|
277
305
|
licenses:
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
We made it!
|
data/web_git-0.0.2.gem
DELETED
|
Binary file
|