flooose-gemedit 0.10.3 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gemedit.rb +3 -2
- data/lib/gemedit/edit_command.rb +10 -7
- data/lib/gemedit/git_options.rb +68 -0
- data/lib/gemedit/system_commands.rb +7 -0
- data/lib/gemedit/version.rb +1 -1
- data/lib/rubygems_plugin.rb +1 -0
- metadata +7 -5
data/lib/gemedit.rb
CHANGED
data/lib/gemedit/edit_command.rb
CHANGED
@@ -50,10 +50,6 @@ class Gem::Commands::EditCommand < Gem::Command
|
|
50
50
|
"GEMNAME name of gem to open in your favorite editor"
|
51
51
|
end
|
52
52
|
|
53
|
-
def git?
|
54
|
-
system("which git")
|
55
|
-
end
|
56
|
-
|
57
53
|
def defaults_str # :nodoc:
|
58
54
|
"--version '#{OPTIONS[:version]}' --editor #{OPTIONS[:editor]} --no-dry-run"
|
59
55
|
end
|
@@ -84,13 +80,20 @@ class Gem::Commands::EditCommand < Gem::Command
|
|
84
80
|
paths.each do |path|
|
85
81
|
path.gsub!(/"/, '')
|
86
82
|
Dir.chdir("#{path}") do
|
87
|
-
|
83
|
+
if File.exists?('.git')
|
84
|
+
if(git_status.empty?)
|
85
|
+
alert(notify_of_clean_repo, "Press 'Enter' to continue")
|
86
|
+
else
|
87
|
+
alert(warn_of_unclean_repo)
|
88
|
+
while(carry_out_choice(choose_from_list('Which action would you like to pursue?: ', choices)))
|
89
|
+
#alert_warning(warn_of_unclean_repo, "Press 'Enter' to continue")
|
90
|
+
end
|
91
|
+
end
|
92
|
+
else
|
88
93
|
say "Initializing empty git repository in #{path}" if Gem.configuration.verbose
|
89
94
|
system('git init')
|
90
95
|
say "Creating initial commit" if Gem.configuration.verbose
|
91
96
|
system("git add . && git commit -m 'Gemedit generated commit'")
|
92
|
-
else
|
93
|
-
say "There seems to already be a git repository for this gem. Not initializing"
|
94
97
|
end
|
95
98
|
end
|
96
99
|
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
class Gem::Commands::EditCommand < Gem::Command
|
2
|
+
def git?
|
3
|
+
system("which git")
|
4
|
+
end
|
5
|
+
|
6
|
+
def git_status
|
7
|
+
`git status -s`
|
8
|
+
end
|
9
|
+
|
10
|
+
def git_status_full
|
11
|
+
`git status`
|
12
|
+
end
|
13
|
+
|
14
|
+
def git_init
|
15
|
+
system('git init')
|
16
|
+
end
|
17
|
+
|
18
|
+
def notify_of_clean_repo
|
19
|
+
<<-eos
|
20
|
+
\e[32mThere seems to already be a git repository for this gem.
|
21
|
+
Since there are no staged or unstaged comments, this just
|
22
|
+
serves as a heads-up.\e[0m
|
23
|
+
eos
|
24
|
+
|
25
|
+
#p method(:say)
|
26
|
+
end
|
27
|
+
|
28
|
+
def warn_of_unclean_repo
|
29
|
+
warning = <<-eos
|
30
|
+
\e[31mThere seems to be an existing git repository for this gem
|
31
|
+
and there are also staged and/or unstaged changes. Since
|
32
|
+
I will not overwrite existing git repositories and since changes
|
33
|
+
to files in this gem will be hard to track, you may want to
|
34
|
+
consider addressing this before actually editing the gem.\e[0m
|
35
|
+
eos
|
36
|
+
end
|
37
|
+
|
38
|
+
def carry_out_choice(choice)
|
39
|
+
case choice[0]
|
40
|
+
when /View status*/ then puts git_status_full; true
|
41
|
+
when /Permanantly remove*/ then
|
42
|
+
`rm -rf .git`
|
43
|
+
git_init
|
44
|
+
git_commit('Gemedit generated commit')
|
45
|
+
false
|
46
|
+
when /Perform a commit and edit gem anyway*/ then
|
47
|
+
git_commit
|
48
|
+
false
|
49
|
+
when /Skip commit and edit gem anyway*/ then
|
50
|
+
false
|
51
|
+
when /Get out of here*/ then
|
52
|
+
Process.exit!(0)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def choices
|
57
|
+
['View status',
|
58
|
+
'Permanantly remove repository (currently is effectively the same as option 3)',
|
59
|
+
'Perform a commit and edit gem anyway',
|
60
|
+
'Skip commit and edit gem anyway',
|
61
|
+
'Get out of here']
|
62
|
+
end
|
63
|
+
|
64
|
+
protected
|
65
|
+
def git_commit(commit_message="Automated commit message from Gemedit")
|
66
|
+
`git add . && git commit -m "#{commit_message}"`
|
67
|
+
end
|
68
|
+
end
|
data/lib/gemedit/version.rb
CHANGED
data/lib/rubygems_plugin.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flooose-gemedit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 51
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 11
|
9
|
+
- 0
|
10
|
+
version: 0.11.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- !binary |
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2010-
|
20
|
+
date: 2010-11-09 00:00:00 +01:00
|
21
21
|
default_executable:
|
22
22
|
dependencies: []
|
23
23
|
|
@@ -32,6 +32,8 @@ extra_rdoc_files: []
|
|
32
32
|
files:
|
33
33
|
- lib/gemedit.rb
|
34
34
|
- lib/gemedit/edit_command.rb
|
35
|
+
- lib/gemedit/git_options.rb
|
36
|
+
- lib/gemedit/system_commands.rb
|
35
37
|
- lib/gemedit/version.rb
|
36
38
|
- lib/rubygems_plugin.rb
|
37
39
|
has_rdoc: true
|