G4t 1.2 → 2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/g4t +1 -0
- data/lib/g4t.rb +40 -174
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3444e27ffa161b5177255951d95af8d36a6ab092e16999750f658e28c31004d6
|
4
|
+
data.tar.gz: e346503def345173e3a349eb4f68e935e286be17ce575d9b91c0f4770fc4d8e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc57f81f30d916d78d865ad02ccb8b394d8c273ce6e8fce5f5ba4981e51d80a94567c24f50b9f208cb00d740a4cfcf5a9033f64e7ba4df778571fa3a67c8503a
|
7
|
+
data.tar.gz: e0507409baafae6d26821b61528501c428b433940ecca33ce92f796bc14d160cd42a479aff3fc685cd73d0d7b6c76a6d3b39d732e7ad1877f067adfbbee13899
|
data/bin/g4t
CHANGED
data/lib/g4t.rb
CHANGED
@@ -2,154 +2,32 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
require "os"
|
4
4
|
require "tty-prompt"
|
5
|
+
|
6
|
+
require_relative "g4tOptions"
|
5
7
|
require "etc"
|
6
8
|
|
7
9
|
module G4t
|
8
|
-
class
|
9
|
-
def initialize
|
10
|
-
$prompt = TTY::Prompt.new
|
11
|
-
end
|
12
|
-
def commit_files
|
13
|
-
$lastmsg = "Now that we commited the files"
|
14
|
-
msg = $prompt.ask("Commit message:")
|
15
|
-
|
16
|
-
if msg[0] != "\""
|
17
|
-
msg = "\"#{msg}"
|
18
|
-
end
|
19
|
-
|
20
|
-
if msg[-1] != "\""
|
21
|
-
msg = "#{msg}\""
|
22
|
-
end
|
23
|
-
|
24
|
-
puts msg
|
25
|
-
run_command("git commit -m #{msg}")
|
26
|
-
end
|
27
|
-
|
28
|
-
def add_files
|
29
|
-
$lastmsg = "Now that we added the files"
|
30
|
-
all_files = $prompt.yes?("Add all files?")
|
31
|
-
if all_files
|
32
|
-
cmd = "git add ."
|
33
|
-
puts("Adding all files...")
|
34
|
-
else
|
35
|
-
fname = $prompt.ask("File to add:")
|
36
|
-
cmd = "git add #{fname}"
|
37
|
-
end
|
38
|
-
run_command(cmd)
|
39
|
-
end
|
40
|
-
|
41
|
-
def logs
|
42
|
-
run_command("git log")
|
43
|
-
end
|
44
|
-
|
45
|
-
def push_branch
|
46
|
-
branch = $prompt.ask("Branch to push:")
|
47
|
-
run_command("git push origin #{branch}")
|
48
|
-
end
|
49
|
-
|
50
|
-
def remote_adress
|
51
|
-
$lastmsg = "Now that we the remote address"
|
52
|
-
uname = $prompt.ask("Your github username:")
|
53
|
-
repo = $prompt.ask("Your repository name:")
|
54
|
-
puts("Adding remote repository https://github.com/#{uname}/#{repo}...")
|
55
|
-
run_command("git remote add origin https://github.com/#{uname}/#{repo}.git")
|
56
|
-
end
|
57
|
-
|
58
|
-
def status
|
59
|
-
run_command("git status")
|
60
|
-
end
|
61
|
-
|
62
|
-
def clone_repo
|
63
|
-
uname = $prompt.ask("Username:")
|
64
|
-
repo = $prompt.ask("Repository name:")
|
65
|
-
run_command("git clone https://github.com/#{uname}/#{repo}/")
|
66
|
-
end
|
67
|
-
|
68
|
-
def restore
|
69
|
-
fname = $prompt.ask("File name:")
|
70
|
-
run_command("git restore #{fname}")
|
71
|
-
end
|
72
|
-
|
73
|
-
def reset
|
74
|
-
commit = $prompt.ask("Commit id:")
|
75
|
-
run_command("git reset --hard #{commit}")
|
76
|
-
end
|
77
|
-
|
78
|
-
def hard_reset
|
79
|
-
confirmation = $prompt.yes?("do you really want to hard reset?")
|
80
|
-
|
81
|
-
if confirmation
|
82
|
-
run_command("git reset --hard HEAD~")
|
83
|
-
else
|
84
|
-
puts "Cancelling operation"
|
85
|
-
end
|
86
|
-
|
87
|
-
end
|
88
|
-
|
89
|
-
def initialize_git
|
90
|
-
$lastmsg = "Now that we initialized .git"
|
91
|
-
puts("Initializing Git repository in '#{Dir.pwd}/.git'...")
|
92
|
-
run_command("git init")
|
93
|
-
end
|
94
|
-
|
95
|
-
def diff
|
96
|
-
run_command("git diff")
|
97
|
-
end
|
98
|
-
|
99
|
-
def change_branch
|
100
|
-
bname = $prompt.ask("Branch name:")
|
101
|
-
run_command("git checkout -b #{bname}")
|
102
|
-
end
|
103
|
-
|
104
|
-
def git_info
|
105
|
-
status = {
|
106
|
-
"Git branch" => IO.popen("git branch"),
|
107
|
-
"Repository url" => IO.popen("git config --get remote.origin.url")
|
108
|
-
}
|
109
|
-
status.each do |k, v|
|
110
|
-
puts("#{k}: #{v.read}")
|
111
|
-
end
|
112
|
-
puts("____________\n\n")
|
113
|
-
end
|
114
|
-
|
115
|
-
def remove_file
|
116
|
-
file_name = $prompt.ask("Enter the file name: ")
|
117
|
-
run_command("git rm #{file_name}")
|
118
|
-
end
|
119
|
-
|
120
|
-
def show_last_commit
|
121
|
-
run_command("git show")
|
122
|
-
end
|
123
|
-
|
124
|
-
def pull_changes
|
125
|
-
git_pull_options = ["rebase", "no-rebase", "ff-only"]
|
126
|
-
chose = $prompt.select("chose: ", git_pull_options)
|
127
|
-
run_command("git pull --#{chose}")
|
128
|
-
end
|
129
|
-
|
130
|
-
def run_command(cmd)
|
131
|
-
puts "Command: #{cmd}"
|
132
|
-
system(cmd)
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
class Run
|
10
|
+
class Core
|
137
11
|
def initialize
|
138
12
|
@opt = Options.new
|
139
|
-
|
13
|
+
@prompt = TTY::Prompt.new
|
140
14
|
start
|
141
15
|
end
|
142
16
|
|
143
17
|
def verify_system
|
144
|
-
if OS.windows
|
18
|
+
if OS.windows?
|
19
|
+
"C:\\Users\\#{Etc.getlogin}\\.gitconfig"
|
20
|
+
else
|
21
|
+
"/home/#{Etc.getlogin}/.gitconfig"
|
22
|
+
end
|
145
23
|
end
|
24
|
+
|
146
25
|
def git_init?
|
147
|
-
identify_user
|
148
26
|
unless File.directory?(".git")
|
149
27
|
begin
|
150
28
|
options = ["Clone a repo", "Initialize a repo", "Close"]
|
151
|
-
|
152
|
-
git_init_verify
|
29
|
+
userSelect = @prompt.select("The .git directory was not found, what do you want to do?", options)
|
30
|
+
git_init_verify(userSelect)
|
153
31
|
rescue TTY::Reader::InputInterrupt
|
154
32
|
abort("\nCloseed")
|
155
33
|
end
|
@@ -170,8 +48,8 @@ module G4t
|
|
170
48
|
def identify_user
|
171
49
|
if(File.exist?(verify_system)) == false
|
172
50
|
begin
|
173
|
-
email =
|
174
|
-
uname =
|
51
|
+
email = @prompt.ask("Github email: ")
|
52
|
+
uname = @prompt.ask("Github username: ")
|
175
53
|
@opt.run_command("git config --global user.email #{email} && git config --global user.name #{uname}")
|
176
54
|
rescue TTY::Reader::InputInterrupt
|
177
55
|
abort("\nYou closed the application")
|
@@ -180,7 +58,8 @@ module G4t
|
|
180
58
|
end
|
181
59
|
|
182
60
|
def show_panel
|
183
|
-
options = [
|
61
|
+
options = [
|
62
|
+
"Add remote address",
|
184
63
|
"Add files",
|
185
64
|
"Commit files",
|
186
65
|
"Push files to branch",
|
@@ -198,46 +77,33 @@ module G4t
|
|
198
77
|
]
|
199
78
|
|
200
79
|
begin
|
201
|
-
|
202
|
-
|
203
|
-
verify_option
|
80
|
+
Options.new.git_info
|
81
|
+
opt_select = @prompt.select("Select: ", options)
|
82
|
+
verify_option(opt_select)
|
204
83
|
rescue TTY::Reader::InputInterrupt
|
205
84
|
abort("\nYou has closed the application.")
|
206
85
|
end
|
207
86
|
end
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
@opt.remote_adress
|
212
|
-
|
213
|
-
@opt.
|
214
|
-
|
215
|
-
@opt.
|
216
|
-
|
217
|
-
@opt.
|
218
|
-
|
219
|
-
@opt.
|
220
|
-
|
221
|
-
@opt.
|
222
|
-
|
223
|
-
@opt.
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
when "Reset to the last commit" then
|
229
|
-
@opt.hard_reset
|
230
|
-
when "Change branch" then
|
231
|
-
@opt.change_branch
|
232
|
-
when "Remove a file" then
|
233
|
-
@opt.remove_file
|
234
|
-
when "Show the last commit" then
|
235
|
-
@opt.show_last_commit
|
236
|
-
when "Git pull changes" then
|
237
|
-
@opt.pull_changes
|
238
|
-
else
|
239
|
-
abort("Goodbye, closed.")
|
240
|
-
end
|
87
|
+
|
88
|
+
def verify_option(option)
|
89
|
+
switch = {
|
90
|
+
"Add remote address" => @opt.method(:remote_adress),
|
91
|
+
"Add files" => @opt.method(:add_files),
|
92
|
+
"Commit files" => @opt.method(:commit_files),
|
93
|
+
"Push files to branch" => @opt.method(:push_branch),
|
94
|
+
"Show git status" => @opt.method(:status),
|
95
|
+
"Show git logs" => @opt.method(:logs),
|
96
|
+
"Show diff" => @opt.method(:diff),
|
97
|
+
"Restore a file" => @opt.method(:restore),
|
98
|
+
"Reset to a commit" => @opt.method(:reset),
|
99
|
+
"Reset to the last commit" => @opt.method(:hard_reset),
|
100
|
+
"Change branch" => @opt.method(:change_branch),
|
101
|
+
"Remove a file" => @opt.method(:remove_file),
|
102
|
+
"Show the last commit" => @opt.method(:show_last_commit),
|
103
|
+
"Git pull changes" => @opt.method(:pull_changes)
|
104
|
+
}
|
105
|
+
|
106
|
+
return switch[option].call
|
241
107
|
end
|
242
108
|
|
243
109
|
def start
|
@@ -245,5 +111,5 @@ module G4t
|
|
245
111
|
end
|
246
112
|
end
|
247
113
|
|
248
|
-
|
114
|
+
Core.new
|
249
115
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: G4t
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '
|
4
|
+
version: '2.0'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- freazesss
|
@@ -48,7 +48,7 @@ extra_rdoc_files: []
|
|
48
48
|
files:
|
49
49
|
- bin/g4t
|
50
50
|
- lib/g4t.rb
|
51
|
-
homepage: https://github.com/
|
51
|
+
homepage: https://github.com/labsz/g4t
|
52
52
|
licenses:
|
53
53
|
- MIT
|
54
54
|
metadata: {}
|
@@ -67,7 +67,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
requirements: []
|
70
|
-
|
70
|
+
rubyforge_project:
|
71
|
+
rubygems_version: 2.7.6
|
71
72
|
signing_key:
|
72
73
|
specification_version: 4
|
73
74
|
summary: git
|