safe_pusher 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a876c76ac889ebc32081c281e6031204b65692de1bf0efda932028d14aff0afd
4
- data.tar.gz: 694782b608d3fd8595f0d6c2da75ef83c3afc6cce5257a7c0491fed149b9980a
3
+ metadata.gz: c05663b02c0ccf6604a9e3054e8ea9456ffcb5694e25440db41edf4e087cb827
4
+ data.tar.gz: edf3051adc55cd6492d35ae31f17c69f5444407e2f71a91a51239dad48f85f98
5
5
  SHA512:
6
- metadata.gz: bd8ef453a0adf63245ca38e5ae6cb71511adea87aa8bbc6f97dbb8da690dbe416b236683cd4cb59a7cf4b290c274d388e64edbc3f868d150fb6032cb32cd4585
7
- data.tar.gz: 1354cbb01df47f12cbfad8b08fa841377902ce3620641a6dd7071598b068ac4b447a04ab29f88eacc43986687944f3072b63968213fff4cf28e574225ee4d3f3
6
+ metadata.gz: d93caa5d43e32f373334afc458647266be8f4d505899d9f83c9ee23bfde83274c7f799b539630508818f11d708db84ffba46bd758989b4809c12031d79cd179c
7
+ data.tar.gz: 88dff6746dbd6543e40152e856a5a0e6040bdf27eaaedaafe561805e435947e6d3aef472a93c64b9df7325c45c0dc85f9bd44b3d891e89c78d5a1f91279ce162
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  This project adheres to [Semantic Versioning](http://semver.org)
4
4
 
5
+ ## [0.4.0] - 2019-11-29
6
+ Features:
7
+ - Add `add`, `commit` and `amend` commands to the cli
8
+
5
9
  ## [0.3.0] - 2019-09-30
6
10
  Improvement:
7
11
  - Reduce RSpec runner verbosity
data/README.md CHANGED
@@ -37,7 +37,7 @@ Create the `safe_pusher.yml` file at the root of your application:
37
37
  files_to_skip:
38
38
  - file/to/skip_1
39
39
  - file/to/skip/2
40
- base_branch: developement
40
+ base_branch: developement # default master
41
41
  app_base_directory: app
42
42
  repo_url: https://github.com/williampollet/safe_pusher
43
43
  ```
data/lib/safe_pusher.rb CHANGED
@@ -3,6 +3,7 @@ require 'thor'
3
3
  require 'colorize'
4
4
  require 'safe_pusher/cli'
5
5
  require 'safe_pusher/version'
6
+ require 'safe_pusher/git_runner'
6
7
  require 'safe_pusher/rspec_runner'
7
8
  require 'safe_pusher/pronto_runner'
8
9
  require 'safe_pusher/github_runner'
@@ -1,6 +1,16 @@
1
1
  module SafePusher
2
2
  class CLI
3
- attr_reader :arguments
3
+ SHORTCUTS = {
4
+ 't' => 'test',
5
+ 'l' => 'lint',
6
+ 'p' => 'push',
7
+ 'o' => 'open',
8
+ 'm' => 'amend',
9
+ 'a' => 'add',
10
+ 'c' => 'commit',
11
+ }.freeze
12
+
13
+ private_constant :SHORTCUTS
4
14
 
5
15
  def initialize(arguments:)
6
16
  @arguments = arguments
@@ -22,16 +32,13 @@ module SafePusher
22
32
 
23
33
  private
24
34
 
35
+ attr_reader :arguments
36
+
25
37
  def execute_command(command)
26
- case command
27
- when 'test', 't'
28
- test
29
- when 'lint', 'l'
30
- lint
31
- when 'open', 'o'
32
- open
33
- when 'push', 'p'
34
- push
38
+ if SHORTCUTS[command]
39
+ send(SHORTCUTS[command])
40
+ else
41
+ send(command)
35
42
  end
36
43
  end
37
44
 
@@ -64,6 +71,36 @@ module SafePusher
64
71
  exit results unless results == 0
65
72
  end
66
73
 
74
+ def amend
75
+ puts '###################################'.yellow
76
+ puts '## Amending your last commit... ###'.yellow
77
+ puts '###################################'.yellow
78
+
79
+ results = SafePusher::GitRunner.new.amend
80
+
81
+ exit results unless results == 0
82
+ end
83
+
84
+ def add
85
+ puts '######################'.yellow
86
+ puts '## Adding files... ###'.yellow
87
+ puts '######################'.yellow
88
+
89
+ results = SafePusher::GitRunner.new.add
90
+
91
+ exit results unless results == 0
92
+ end
93
+
94
+ def commit
95
+ puts '################################'.yellow
96
+ puts '## Commiting last changes... ###'.yellow
97
+ puts '################################'.yellow
98
+
99
+ results = SafePusher::GitRunner.new.commit
100
+
101
+ exit results unless results == 0
102
+ end
103
+
67
104
  def open
68
105
  puts '#########################################'.yellow
69
106
  puts '## Opening a pull request on Github... ##'.yellow
@@ -75,7 +112,14 @@ module SafePusher
75
112
  end
76
113
 
77
114
  def arguments_valid?
78
- arguments.join(' ') =~ /^(?!\s*$)(?:test|lint|push|open|t|l|p|o| )+$/
115
+ arguments.join(' ') =~ valid_commands_regexp
116
+ end
117
+
118
+ def valid_commands_regexp
119
+ valid_commands = "#{SHORTCUTS.keys.join('|')}|"\
120
+ "#{SHORTCUTS.values.join('|')}"
121
+
122
+ /^(?!\s*$)(?:#{valid_commands}| )+$/
79
123
  end
80
124
 
81
125
  def help
@@ -87,6 +131,9 @@ module SafePusher
87
131
  " ##########################################################\n"\
88
132
  " test (t) # run the test suite\n"\
89
133
  " lint (l) # run the linters\n"\
134
+ " amend (m) # amend your last commit \n"\
135
+ " add (a) # add changes to be committed \n"\
136
+ " commit (c) # commit your staged changes \n"\
90
137
  " push (p) # push on distant repository\n"\
91
138
  ' open (o) # open a pull request on the distant repository'
92
139
  end
@@ -0,0 +1,28 @@
1
+ require 'colorize'
2
+ require 'English'
3
+
4
+ module SafePusher
5
+ class GitRunner
6
+ def amend
7
+ system('git commit --amend')
8
+
9
+ $CHILD_STATUS.exitstatus
10
+ end
11
+
12
+ def add
13
+ system('git add --interactive')
14
+
15
+ $CHILD_STATUS.exitstatus
16
+ end
17
+
18
+ def commit
19
+ puts 'Enter a message for your commit:'
20
+
21
+ result = STDIN.gets.chomp
22
+
23
+ system("git commit -m '#{result}'")
24
+
25
+ $CHILD_STATUS.exitstatus
26
+ end
27
+ end
28
+ end
@@ -1,3 +1,3 @@
1
1
  module SafePusher
2
- VERSION = '0.3.0'.freeze
2
+ VERSION = '0.4.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: safe_pusher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Pollet
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-30 00:00:00.000000000 Z
11
+ date: 2019-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -191,6 +191,7 @@ files:
191
191
  - lib/safe_pusher.rb
192
192
  - lib/safe_pusher/cli.rb
193
193
  - lib/safe_pusher/configuration.rb
194
+ - lib/safe_pusher/git_runner.rb
194
195
  - lib/safe_pusher/github_runner.rb
195
196
  - lib/safe_pusher/pronto_runner.rb
196
197
  - lib/safe_pusher/rspec_runner.rb