rails_auto_commiter 0.1.0 → 1.0.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 +4 -4
- data/README.md +24 -11
- data/lib/rails_auto_commiter.rb +23 -75
- data/lib/rails_auto_commiter/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10929dba21499d3c2e568dab9b538a6547e0bee6
|
4
|
+
data.tar.gz: 2622279310cc0355a6712909536c066ba758b69a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72ca1fcff071d01d233220abd4c8b40313abde2618b7cead6e78c4496b3a2826ca7c40c77c60322ab9c94aefe3a943c859429628968f50296eca437aad80fcff
|
7
|
+
data.tar.gz: 68ceba6aabe8d35d542d51b3f794a100c7f5b6e0189b730fc3fd381e23c850580824b0e0cb676d6b8bbedd463bf46309563b88210db1cf966c9124be244b5f24
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# RailsAutoCommiter
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
2
|
+
RailsAutoCommiter provides an auto commiter for Ruby on Rails.
|
3
|
+
If you run `rails [generate,destroy] ...`, files Rails changed will be automatically commited by it.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -22,15 +20,30 @@ Or install it yourself as:
|
|
22
20
|
|
23
21
|
## Usage
|
24
22
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
23
|
+
Run the rails commands as always. The changed files are automatically committed.
|
24
|
+
|
25
|
+
```zsh
|
26
|
+
% rails generate model Post hoge
|
27
|
+
Running via Spring preloader in process 78876
|
28
|
+
Expected string default value for '--jbuilder'; got true (boolean)
|
29
|
+
invoke active_record
|
30
|
+
create db/migrate/20170115144306_create_posts.rb
|
31
|
+
create app/models/post.rb
|
32
|
+
invoke test_unit
|
33
|
+
create test/models/post_test.rb
|
34
|
+
create test/fixtures/posts.yml
|
35
|
+
[master 0a9773b] result of 'rails generate model Post title body:text'.
|
36
|
+
4 files changed, 28 insertions(+)
|
37
|
+
create mode 100644 app/models/post.rb
|
38
|
+
create mode 100644 db/migrate/20170115144306_create_posts.rb
|
39
|
+
create mode 100644 test/fixtures/posts.yml
|
40
|
+
create mode 100644 test/models/post_test.rb
|
41
|
+
```
|
32
42
|
|
33
43
|
## Contributing
|
34
44
|
|
35
45
|
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rails_auto_commiter. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
46
|
|
47
|
+
## License
|
48
|
+
|
49
|
+
RailsAutoCommiter is released under the [MIT License](http://www.opensource.org/licenses/MIT).
|
data/lib/rails_auto_commiter.rb
CHANGED
@@ -1,101 +1,49 @@
|
|
1
1
|
require "rails_auto_commiter/version"
|
2
|
+
require 'rails/commands/commands_tasks'
|
2
3
|
|
3
4
|
module RailsAutoCommiter
|
4
5
|
@@rails_auto_commiter_sub_commands = []
|
5
|
-
@@
|
6
|
+
@@git_stashed = false
|
7
|
+
|
8
|
+
def self.git_stashed?
|
9
|
+
@@git_stashed
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.git_stashed=(bool)
|
13
|
+
@@git_stashed = bool
|
14
|
+
end
|
15
|
+
|
6
16
|
def self.sub_commands
|
7
17
|
@@rails_auto_commiter_sub_commands
|
8
18
|
end
|
9
19
|
def self.sub_commands=(sub_commands)
|
10
20
|
@@rails_auto_commiter_sub_commands = sub_commands
|
11
21
|
end
|
12
|
-
def self.commit_files
|
13
|
-
@@rails_auto_commiter_commit_files
|
14
|
-
end
|
15
|
-
def self.commit_files=(files)
|
16
|
-
@@rails_auto_commiter_commit_files = self.commit_files + files
|
17
|
-
end
|
18
|
-
|
19
|
-
module Thor
|
20
|
-
module Actions
|
21
|
-
module CreateFile
|
22
|
-
def invoke_with_conflict_check(&block)
|
23
|
-
unless exists? || pretend?
|
24
|
-
RailsAutoCommiter.commit_files << destination
|
25
|
-
end
|
26
|
-
super
|
27
|
-
end
|
28
|
-
|
29
|
-
def revoke!
|
30
|
-
#RailsAutoCommiter.sub_commands ||= ARGV.dup
|
31
|
-
if exists? && !pretend?
|
32
|
-
RailsAutoCommiter.commit_files << destination
|
33
|
-
end
|
34
|
-
super
|
35
|
-
end
|
36
|
-
|
37
|
-
protected
|
38
|
-
def on_conflict_behavior(&block)
|
39
|
-
options = base.options.dup.merge(config)
|
40
|
-
if !identical? && pretend?
|
41
|
-
RailsAutoCommiter.commit_files << destination
|
42
|
-
end
|
43
|
-
super
|
44
|
-
end
|
45
|
-
|
46
|
-
def force_or_skip_or_conflict(force, skip, &block)
|
47
|
-
if force && !pretend?
|
48
|
-
RailsAutoCommiter.commit_files << destination
|
49
|
-
end
|
50
|
-
super
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
22
|
|
56
23
|
module Rails
|
57
24
|
module CommandsTasks
|
58
25
|
def run_command!(command)
|
59
|
-
RailsAutoCommiter.sub_commands ||= []
|
26
|
+
#RailsAutoCommiter.sub_commands ||= []
|
60
27
|
RailsAutoCommiter.sub_commands << command
|
61
28
|
RailsAutoCommiter.sub_commands << ARGV.dup
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
module Generators
|
66
|
-
module Actions
|
67
|
-
module CreateMigration
|
68
|
-
def revoke!
|
69
|
-
say_destination = exists? ? relative_existing_migration : relative_destination
|
70
|
-
if exists? && !pretend?
|
71
|
-
RailsAutoCommiter.commit_files << say_destination
|
72
|
-
end
|
73
|
-
super
|
74
|
-
end
|
75
|
-
|
76
|
-
protected
|
77
|
-
def on_conflict_behavior
|
78
|
-
options = base.options.dup.merge(config)
|
79
|
-
if !identical? && options[:force] && !pretend?
|
80
|
-
RailsAutoCommiter.commit_files << existing_migration
|
81
|
-
end
|
82
|
-
super
|
83
|
-
end
|
29
|
+
unless `git status`.match(/nothing to commit, working directory clean/)
|
30
|
+
system('git stash')
|
31
|
+
RailsAutoCommiter.git_stashed = true
|
84
32
|
end
|
33
|
+
super
|
85
34
|
end
|
86
35
|
end
|
87
36
|
end
|
88
37
|
end
|
89
|
-
|
90
|
-
|
91
|
-
Thor::Actions::CreateFile.send(:prepend, RailsAutoCommiter::Thor::Actions::CreateFile)
|
92
|
-
Rails::Generators::Actions::CreateMigration.send(:prepend, RailsAutoCommiter::Rails::Generators::Actions::CreateMigration)
|
93
38
|
Rails::CommandsTasks.send(:prepend, RailsAutoCommiter::Rails::CommandsTasks)
|
39
|
+
|
94
40
|
at_exit do
|
95
|
-
|
41
|
+
unless `git status`.match(/nothing to commit, working directory clean/)
|
42
|
+
system('git add .')
|
96
43
|
sub_commands = RailsAutoCommiter.sub_commands.join(' ')
|
97
|
-
|
98
|
-
|
99
|
-
|
44
|
+
system("git commit -m \"result of 'rails #{sub_commands}'.\"")
|
45
|
+
end
|
46
|
+
if RailsAutoCommiter.git_stashed?
|
47
|
+
system('git stash pop')
|
100
48
|
end
|
101
49
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_auto_commiter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hiroki Shirai
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|